Grails ClassPath Error, when update to 3.2.1 - grails

After upgrading from 3.1.12 to 3.2.1 I get the following error:
Error:
ClassPathScanner - The application defines a Groovy source using the default package. Please move all Groovy sources into a package.
Caused by: java.lang.ClassNotFoundException: org.grails.datastore.gorm.plugin.support.ConfigSupport
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
The message seems clear, but I cannot find any source which don't have a package.
Can any body help me either with a solution or an idea how to debug it.
Thanks

It's probably BootStrap.groovy (under grails-app/init) or UrlMappings.groovy (under grails-app/controllers)

I had same error as OP #Torsten.
Per #Burt Beckwith's suggestion, ran grails console and ctx.grailApplication..... . It showed Bootstrap. So I moved Bootstrap.groovy from grails-app/init folder to grails-app/init/my/package/name folder where Application.groovy was.
When re-ran grails run-app the ClassPathScanner.... error is gone !
Thanks OP and Burt Beckwith to post question and answer. It helped me.
PS: I wanted to add comment to Burt BeckWith's answer, but I don't have enough reputation yet.

Related

Grails error initializing application: null

When I try to run "grails run-app", I get the error and small stacktrace:
context.GrailsContextLoaderListener Error initializing the application: null
java.lang.NullPointerException
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
I'm using Grails 2.5.0 and Java 1.8.0_51.
How can I get more information about what's going wrong?
edit: I've tried grails clean and grails refresh-dependencies in all related projects.
I think this is related to reloading or recompilation. Could you retry booting after a grails clean
Our app consists of two projects. Project 1 has all the Bootstrap files and Project 2 all the domain/view/controller files. The branch I was on for Project 1 had a bootstrap file which used a domain object that was on a different branch of Project 2, so I commented out the bootstrap file. As it turns out, this is what was causing the error. To fix it, I had to DELETE the bootstrap file to get the app to run.
I guess Grails doesn't like it when there's a Bootstrap file with no code in it..

Grails 2.4.0 - Error: ClassNotFoundException: grails.plugin.spock.test.GrailsSpecTestType

Whenever I enter the grails command: test-app I get this error:
Error executing script TestApp: java.lang.ClassNotFoundException: grails.plugin.spock.test.GrailsSpecTestType (Use --stacktrace to see the full trace)
In my BuildConfig.groovy I have:
grails.project.dependency.resolution = {
...
plugins {
...
compile ":spock:0.7"
}
}
I've tried replacing it with test ":spock:0.7" . I've also tried cleaning the application and refreshing the dependencies but no luck.
Any ideas what it could be and how I could fix it?
Thanks
With Grails 2.4.0 you don't need to make any mention of Spock in BuildConfig.groovy. See the sample project at https://github.com/jeffbrown/spockdemo.
When you can, you should look at upgrading to the latest in the 2.4.x line. A number of issues have been addressed since 2.4.0 was released.
I hope that helps.
#zzKozak is correct - you should upgrade. It has no bearing here, but getting to the latest version of Grails within your minor version (in this case 2.4.3) should happen before you ask others for help with issue that could have been fixed youself with a simple upgrade.
In 2.4, Grails switched to Spock tests by default, and you have to uninstall the old plugin since they're incompatible. Delete that line in BuildConfig.groovy and change your base classes to core the new Grails/Spock base classes. For integration queries, use grails.test.spock.IntegrationSpec. For unit tests and more information about this, check out the testing section in the docs: http://grails.org/doc/latest/guide/testing.html

Grails JMS Plugin - Unable to resolve classes

I'm pretty new to grails so it's possible that i've missed something obvious, but I am trying to utilise the JMS plugin. I've included the following within the plugins section of my BuildConfig.groovy
compile ":jms:1.2"
However when I compile the app I get lots of "unable to resolve class" exceptions for imports within the jms plugin (40 in total, javax.jms.* and org.springframework.jms.* mostly).
e.g.
| Error Compilation error: startup failed:
C:\dev\prj\grails\tApp\target\work\plugins\jms-1.2\grails-app\utils\DefaultJmsBe
ans.groovy: 16: unable to resolve class org.springframework.jms.listener.Default
MessageListenerContainer
# line 16, column 1.
import org.springframework.jms.listener.DefaultMessageListenerContainer
^
C:\dev\prj\grails\tApp\target\work\plugins\jms-1.2\grails-app\services\grails\pl
ugin\jms\JmsService.groovy: 22: unable to resolve class javax.jms.Message
# line 22, column 1.
import javax.jms.Message
Is anyone able to point me in the right direction? The issue can be reproduced just by adding the plugin to the BuildConfig.groovy as mentioned above to a new grails project .
Grails version 2.3.3
Many thanks
Tom
While doing a Grails 2.2 -> 2.3.4 upgrade I ran into a similar issue and was able to get things working by manually adding spring-jms to my dependencies in BuildConfig.groovy:
compile 'org.springframework:spring-jms:3.2.5.RELEASE'
It's odd that this would stop working now of course, since the jms plugin hasn't changed in a very long time. My guess is that it depends on the spring-jms lib, but didn't have it listed as a dependency, instead relying on grails to bring it in. According to the 2.3.x upgrade guide, there have been changes to what grails brings in now, so perhaps spring-jms stopped getting a free ride.
The Grails MX website has a write-up that might help; it's built using 2.3.4:
http://grails.org.mx/2013/12/20/quickstart-jms-en-grails/
It was pretty helpful to me in getting a sample application up and running. It's in Spanish though, so may need to have Google translate it for you...
Have you tried executing the command grails refresh-dependencies before running grails run-app?
I wrote a blog post on installing a Grails plugin if you need more details.

Grails hangs on command line

I just downloaded Grails 2.0.1.
Created a new project and then tried adding the mysql connector as per the documentation but Grails hangs at command prompt without any message. I tried to execute in verbose and stacktrace mode but it prints nothing.
I tried cleaning and re-executing but all the grails commands are getting stuck.
They don't print anything beyond "configuring classpath" message .
Please help.
Thanks
Cleaning .ivy cache helps
$HOME/.grails/ivy-cache
Had the same problem on grails 2.0.4.
The cause was one of the repos not responding and grails waits for it to timeout.
Setting log "verbose" in BuildConfig.groovy helped me find which repository caused the problem.
Try to add --offline to te command
$ grails clean --offline
worked for me, as I was stuck on configuring classpath due to unresolved dependencies.

Grails: server crashes when I recompile a file (when using datasources)

I'm using datasources in my Grails project.
When I edit a groovy file with server running I get the following error:
Running Grails application.. java.lang.IllegalArgumentException: Must
supply a resource type for JNDI configuration
How can I configure grails.naming.entries in Config.groovy to fix this?
Note: I'm using grails 1.3.6
Tks
I'm using 1.3.7 and hit the same issue. There's a couple bugs in the JIRA about this, looks like they were finally fixed in 2.0-M1. There's a patch for 1.3.1+ versions here, but I haven't tested that yet.
Link to possible patch: http://jira.grails.org/browse/GRAILS-7021

Resources