Unable to load class, to missing dependency - grails

I need to upload file:
def newTeam(String nameTeam){
render '123 ' + nameTeam
if(request instanceof MultipartHttpServletRequest) {
MultipartHttpServletRequest mpr = (MultipartHttpServletRequest)request
CommonsMultipartFile f = (CommonsMultipartFile) mpr.getFile("myFile");
}
}
i have error:
2017-04-11 23:22:37.416 ERROR --- [ Thread-12]
grails.boot.GrailsApp : Compilation Error: startup
failed: General error during class generation:
java.lang.NoClassDefFoundError: Unable to load class
org.springframework.web.multipart.commons.CommonsMultipartFile due to
missing dependency Lorg/apache/commons/fileupload/FileItem;
java.lang.RuntimeException: java.lang.NoClassDefFoundError: Unable to
load class
org.springframework.web.multipart.commons.CommonsMultipartFile due to
missing dependency Lorg/apache/commons/fileupload/FileItem; at
more....
It is fix. But i do not know how to use it. I have to write the dsl code in my resources.groovy.

Try adding the following to build.gradle:
dependencies {
....
compile 'commons-fileupload:commons-fileupload:1.3.2'
}

Related

Adding a file in bootstrap.groovy in grails 3?

I would like to add a file in the bootstrap.groovy file in grails 3.3.9 version.
In the bootstrap.groovy:
package com.nuevaconsulting
import com.nuevaconsulting.embrow.*
class BootStrap {
def init = { servletContext ->
def filePath = "C:/Grails/embrow/grails-app/conf/resourcesresources/1.csv"
new File(filePath).splitEachLine(',')
{
fields ->
def employee = new Employee(
mirId: fields[0].trim(),
cancer : fields[1].trim(),
profile : fields[1].trim(),
pubmed : fields[1].trim()
)
if ( employee.hasErrors() || employee.save(flush: true) == null) {
log.error("Could not import employee ${ employee.errors}")
}
log.debug("Importing employee ${ employee.toString()}")
}
def destroy = {}}}
When I execute run-app, I ended-up with the following error
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bootRun'.
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_201\bin\java.exe'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:369)
Error Failed to start server (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.util.concurrent.ExecutionException: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-bin.zip'.
Caused by: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-bin.zip'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':bootRun'.
at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74)
at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bootRun'.
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
... 44 more
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_201\bin\java.exe'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:369)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
... 78 more
| Error Failed to start server
How can I add and visualize ?

Spring Cloud Dataflow scriptable-transform fails for python language

Recently, I download the 1.7.0 release and tried to deploy the following
stream create amqp-to-hdfs --definition "mqtt-source-rabbit
--username=admin --password=pwd --url=/path/to/host--topics=dmj/ccs/sms/stream |
scriptable-transform --language=python --script='return \"payload\"' |
hdfs --fs-uri=hdfs://path/to/hdfs:9000 --directory=/path/to/recording --file-name=ingest"
However, this failed to start due to the following issue:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.stream.app.scriptable.transform.processor.ScriptableTransformProcessorConfiguration':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transformer' defined in
org.springframework.cloud.stream.app.scriptable.transform.processor.ScriptableTransformProcessorConfiguration:
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: javax.script.ScriptEngineManager is
unable to create a script engine for language 'python'
This is odd because I do have python installed and if I change the language and script values to ruby-based code, everything works. However, I need to use Python for this task.
Any ideas
The scriptable transformer will require you to have function declared and you will call that function at the end of the function defination
def myFunction(firstVar, lastVar):
return firstVar +" some addition "+ lastVar;
myFunction("First ", " Second ")

Grails profile plugin issue

I am working to add the Grails profile plugin the documentation says I should add...
log4j {
...
logger {
...
com.linkedin.grails = "info"
}
...
}
This seems to suggest it should be something more like...
com.linkedin.grails "info"
But when I run that I get...
Error | log4j:ERROR Property missing when configuring log4j: com Error
| log4j:ERROR WARNING: Exception occured configuring log4j logging: No
signature of method: groovy.util.ConfigObject.grails() is applicable
for argument types: (java.lang.String) values: [info]
Can someone help with what I am missing
You have the order backwards. First comes loglevel, then comes the package.
info "com.linkedin.grails"

Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean

I'm trying to deploy a simple webapp with an embedded instance of Jetty. My embedded test code is:
public static void main(String[] args) throws Exception{
Server server = new Server(8181);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar(ContUtil.warPath + ContUtil.warName);
server.setHandler(webAppContext);
logger.info("starting jetty...");
server.start();
server.join();
}
but I got the following error:
Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/C:/Users/lingguo/AppData/Local/Temp/jetty-0.0.0.0-8181-MemCloud-Web-1.0-SNAPSHOT.war-_-any-6830790104248388668.dir/webapp/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:29:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:232)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 23 more
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:/D:/Program%20Files%20(x86)/apache-maven-2.2.1/repo/org/apache/struts/struts2-core/2.2.1/struts2-core-2.2.1.jar!/struts-default.xml:29:72 - bean - jar:file:/C:/Users/lingguo/AppData/Local/Temp/jetty-0.0.0.0-8181-MemCloud-Web-1.0-SNAPSHOT.war-_-any-6830790104248388668.dir/webapp/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:29:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
... 26 more
I've referenced many similar answers about this problems, for example: Struts2 Error when Deploying: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory; Most of the similar problems are caused by jar packages conflict of different versions. But my problem is a little different. I ensure that there is only one version of struts2-core (2.2.1) in my classpath.
I checked the error message, I think that jetty creates a tmp file, that is: /C:/Users/lingguo/AppData/Local/Temp/jetty-0.0.0.0-8181-MemCloud-Web-1.0-SNAPSHOT.war-_-any-6830790104248388668.dir,and the jar struts2-core-2.2.1 is confict with the jar in my local maven repository.
Could anybody know where is going wrong? Thanks in advance!

No such property: GormEncryptedStringType when installing jasypt in grails

I'm trying to use Jasypt plugin on my grails project. I followed the setup described on the wiki but I got the following exception:
ERROR context.GrailsContextLoader - Error executing bootstraps: Error evaluating ORM mappings block for domain [domain.Branch]: No such property: GormEncryptedStringType for class: org.codehaus.groovy.grails.orm.hibernate.cfg.HibernateMappingBuilder
Message: Error evaluating ORM mappings block for domain [domain.Branch]: No such property: GormEncryptedStringType for class: org.codehaus.groovy.grails.orm.hibernate.cfg.HibernateMappingBuilder
Does any body have any idea how to solve this?
Thanks,
It might be as simple as a missing import line:
import com.bloomhealthco.jasypt.GormEncryptedStringType

Resources