I'm just trying out grails and it's already failing with this error:
grails> create-app
| Application created at /path/hello
| Initializing application. Please wait...
BUILD SUCCESSFUL
Total time: 2.553 secs
grails> run-app
| Running application...
java.lang.ExceptionInInitializerError
[stack trace]
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: Class org.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class org.codehaus.groovy.reflection.GroovyClassValuePreJava7 with modifiers "public"
[more stack trace]
Caused by: java.lang.IllegalAccessException: Class org.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class org.codehaus.groovy.reflection.GroovyClassValuePreJava7 with modifiers "public"
(GrailsAutoConfiguration.groovy:36)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/bin/java'' finished with non-zero exit value 1
I think there's some cache that's blocked up somewhere, but I've tried "grails clean" and "gradle clean" and "clean-all" but no luck there.
I'm really not doing anything more than what you see in the dump above- I create a new app and try to run it. What's going on?
I had same problems withs jvm 1.7.
Try to use jvm 1.8. Tested at 1.8.0_25.
Or you can try to run app using "grails run-app" command from app folder (works with jvm 1.7.0_80).
Related
I want to install grails on my windows 10 (x64). The grails version I have is 3.3.4, groovy version 2.4.14, JVM version 1.8.0_141. I can create an app but when I run it an error comes out:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'hello'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve org.grails:grails-gradle-plugin:3.3.4.
Required :
project :
Could not resolve org.grails:grails-gradle-plugin:3.3.4.
Could not get resource 'https://repo.grails.org/grails/core/org/grails/grails-gradle-plugin/3.3.4/grails-gradle-plugin-3.3.4.pom'.
Could not GET 'https://repo.grails.org/grails/core/org/grails/grails-gradle-plugin/3.3.4/grails-gradle-plugin-3.3.4.pom'.
Connect to repo.grails.org:443 [repo.grails.org/198.18.1.217] failed: Connection timed out: connect
Could not resolve org.grails.plugins:hibernate5:6.1.9.
Required by:
project :
Could not resolve org.grails.plugins:hibernate5:6.1.9.
Could not get resource
'https://repo.grails.org/grails/core/org/grails/plugins/hibernate5/6.1.9/hibernate5-6.1.9.pom'.
Could not GET 'https://repo.grails.org/grails/core/org/grails/plugins/hibernate5/6.1.9/hibernate5-6.1.9.pom'.
Connect to repo.grails.org:443 [repo.grails.org/198.18.1.217] failed: Connection timed out: connect
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
CONFIGURE FAILED
Total time: 1 mins 4.547 secs
Error Error initializing classpath: Connection timed out: connect (Use --stacktrace to see the full trace)
I have searched everywhere but haven't found a solution. Please help me to resolve this.
PS: Every time I try to run the app, strangely the net becomes unbelievably slow.
I'm trying to add ElasticSearch plugin in my Grails 3.1.6 project.
I installed plugin as:
dependencies {
//..
compile 'org.grails.plugins:elasticsearch:1.0.0.2'
//..}
And configured application.yml as
elasticSearch:
client:
node: local
datastoreImpl: hibernateDatastore
But when I try to run application, i'm getting error as below:
BUILD SUCCESSFUL
Total time: 5.118 secs
|Running application...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> A problem occurred starting process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe''
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error |
Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
I'm using IntellijIdea v2016 as IDE.
Would someone please help me to figure out the error spot please.
Thanks.
This isn't related to the plugin, it's a Boot/Gradle problem caused by having a classpath that causes the process to fail because the combined length of the process command is larger than the max Windows allows. This was fixed in 3.1.2 but you have to add a small config setting to build.gradle since it's not a problem in Linux or OSX:
grails {
pathingJar = true
}
See https://github.com/grails/grails-core/issues/9125 for more info.
seem to have more stupid issues with forked Execution in grails than anything else
using grails 2.4.4 on GGTS 3.6.3, groovy 2.3.7, 64bit
trying to repair another plugin (its out of date and i'm trying to fixit). had problems. pared all back to a simple plugin and demo project that includes the plugin from the local workspace
in DemoProject I do the local include of the plugin like this in buildConfig.groovy
grails.plugin.location.DummyPlugin = "../DummyPlugin"
so far so good. without adding an _Events.grooy and running the DemoProject all starts ok and plugin loads.
now add an _Events.groovy to the plugins /script folder. In that file I have this line right at top
import grails.util.BuildSettingsHolder as build
import groovy.xml.MarkupBuilder
includeTargets << grailsScript("_GrailsPackage")
now when you run the demo project you get an error like this
|Running Grails application
Error |
Error loading event script from file [E:\workspace\ggts3.6.2-workspace\DummyPlugin\scripts\_Events.groovy] No such property: classLoader for class: java.lang.Object (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
groovy.lang.MissingPropertyException: No such property: classLoader for class: java.lang.Object
at grails.util.BuildSettings$1.doCall(BuildSettings.groovy:409)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at _Events.run(_Events.groovy:29)
at org.grails.plugins.tomcat.fork.ForkedTomcatServer.createEventListener(ForkedTomcatServer.groovy:147)
at org.grails.plugins.tomcat.fork.ForkedTomcatServer.createTomcatRunner(ForkedTomcatServer.groovy:104)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.grails.plugins.tomcat.fork.ForkedTomcatServer.runInternal(ForkedTomcatServer.groovy:82)
at org.grails.plugins.tomcat.fork.ForkedTomcatServer.run(ForkedTomcatServer.groovy:66)
at org.grails.plugins.tomcat.fork.ForkedTomcatServer$run.call(Unknown Source)
at org.grails.plugins.tomcat.fork.ForkedTomcatServer.main(ForkedTomcatServer.groovy:60)
Error |
Error loading event script from file [E:\workspace\ggts3.6.2-workspace\DummyPlugin\scripts\_Events.groovy] No such property: classLoader for class: java.lang.Object
|Server running. Browse to http://localhost:8080/DemoDummyProject
if you got back to the DemoProject and stopped forked Execection by setting grails.project.fork =[] and run again it all works fine - no errors.
so essentially forked execution screws up the plugins includeTargets action.
how do you fix this whilst std forked config is now enabled as default - any clues? advice requested
I'm getting different test results when run from eclipse (STS) and from grails.
Under grails my tests error (ie dont even run) with a ClassNotFoundException
In eclipse they run successfully.
(And run-app still works fine when run from grails FWIW.)
Tests had been working in both environments for several days.
Then I deleted a number of files I didn't need (domains. controllers and the unit tests on them)
Now I have a problem.
Versions:
ubuntu 10.04
eclipse
eclipse / SpringToolSuite 3.4.0
- groovy compiler: groovy 2.07
- grails location: /home/nick/grails-2.3.6
- JDK compliance level 1.6
- JAVA_HOME=/usr/lib/jvm/java-6-openjdk
grails 2.3.6
- GRAILS_HOME=/home/nick/grails-2.3.6
- JAVA_HOME=/usr/lib/jvm/java-6-openjdk
eclipse / SpringToolSuite 3.4.0
Everything is still fine and dandy from inside eclipse / STS
select project
run as > junit test
runs 24 tests in 3 test classes
all succeed
grails 2.3.6
But from inside grails in a terminal the tests no longer run.
grails> test-app
| Compiling 2 source files.
| Error Fatal error running tests: Could not load class in test type 'unit' (Use --stacktrace to see the full trace)
| Compiling 2 source files..
| Tests FAILED - view reports in /home/nick/grails-2.3.6-workspace/imca2/target/test-reports
Browsing the test-reports shows: No tests executed.
Adding --stacktrace makes no difference, no stacktrace is provided and it still advises me to add --stacktrace.
grails test-app --stacktrace | tee /tmp/out
gives
| Loading Grails 2.3.6
| Configuring classpath
| Configuring classpath.
| Environment set to test
| Environment set to test.
| Environment set to test..
| Environment set to test...
| Environment set to test....
| Environment set to test.....
| Running without daemon...
| Compiling 1 source files
| Compiling 1 source files.
| Error Fatal error running tests: Could not load class in test type 'unit' (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.RuntimeException: Could not load class in test type 'unit'
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
Caused by: java.lang.ClassNotFoundException: com.ubergen.AdvocacyStaffSpec
... 5 more
| Error Fatal error running tests: Could not load class in test type 'unit'
| Compiling 1 source files..
| Tests FAILED - view reports in /home/nick/grails-2.3.6-workspace/imca2/target/test-reports
| Error Error running forked test-app: Could not load class in test type 'unit' (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.RuntimeException: Could not load class in test type 'unit'
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
Caused by: java.lang.ClassNotFoundException: com.ubergen.AdvocacyStaffSpec
... 5 more
| Error Error running forked test-app: Could not load class in test type 'unit'
| Error Forked Grails VM exited with error
I've tried grails clean and clean-all first. test-app then recompiles everything, but it makes no difference - eclipse still runs the tests successfully and grails still errors without running any of them; and it doesn't matter which order I run them in.
Nor does it make any difference which order I run tests in.
What should I do?
In case it helps anyone, I'm posting my own answer after tracking problem down.
As the stacktrace showed only one of the spock tests. Grails could run the others successfully.
On closer inspection the failing test turned out to have a mistyped class name. I hadn't looked closely enough as its name is only a convention, or so I thought.
So, assuming there is a class CorrectName that needs testing but the test is mistyped as WrongNameSpec instead of CorrectNameSpec...
Here is the mistyped test code in CorrectName.groovy:
[snip]
#TestFor(CorrectName)
class WrongNameSpec extends Specification {
[snip]
This runs in eclipse/STS and tests the CorrectName class successfully.
In grails it fails with a stacktrace that says:
| Error Fatal error running tests: Could not load class in test type 'unit'
Caused by: java.lang.ClassNotFoundException: com.ubergen.CorrectNameSpec
Grails and eclipse have different target areas to put the compiled code in. Here the class files are:
./target-eclipse/classes/com/ubergen/WrongNameSpec.class
./target/test-classes/unit/com/ubergen/WrongNameSpec.class
As the stack trace said, there is no CorrectNameSpec class.
This is the corrected code and runs ok in both:
[snip]
#TestFor(CorrectName)
class CorrectName extends Specification {
[snip]
Grails is doing something like building a list of tests from the #TestFor but assuming the test classname will follow the expected convention.
Summary:
In eclipse/sts the name of the unit test is a convention, its the #TestFor that matters. In grails the name of the unit test is not just a convention, you must name it as expected, because grails will assume there is a class file that matches that name and you will get a ClassNotFoundException.
I have a multi-project gradle build that has several Grails app.
One of these app contains many artefacts (controllers, services, groovy code, etc...).
When I run it using the gradle grails-run-app command, I get the following error:
| Error Server failed to start: PermGen space (Use --stacktrace to see the full trace)
We tried to add to buildConfig.groovy the following
disable.auto.recompile=true
and add the following to the gradle.properties
-XX:MaxPermSize=1G -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
But the error remain
I am using:
Grails 2.3.1, Gradle 1.8 and grails-gradle-plugin 2.0.0-SNAPSHOT
Any ideas ?
Eduardo
Add the following lines to the begin of your gradle.build
import org.grails.gradle.plugin.GrailsTask
tasks.withType(org.grails.gradle.plugin.GrailsTask) { Task t ->
t.jvmOptions {
jvmArgs '-Xms32m -Xmx1524m -XX:PermSize=32m -XX:MaxPermSize=512m -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC'.split(' ')
}
}
It runs every grails task with the specified jvm args.
Check this link