Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
If you have quartz as a dependency in your project it might happen that you are unable start grails with "mvn grails:run-app" getting:
Application expects grails version [1.1.1], but GRAILS_HOME is version [null]
The problem is that BuildSettings.groovy loads properties from the build.properties file in the grails-bootstrap artifact.
However, a property file with the same name is also located in the quartz artifact. Depending on your luck the class loader will look into the correct artifact first - but maybe not. Its completely random because a Set is used for the artifacts.
This problem was also mentioned here:
http://javagrailsetc.blogspot.com/2009/04/problem-solved-application-expects.html
The best way to fix this seem to be to renamed the property file to something like "grails.build.properties".
Alternatively, the maven plugin should ensure that the grails-bootstrap artifact comes first in the classpath.
I used this approach for my workaround. I added in AbstractGrailsMojo#runGrails:
// make sure grails-bootstrap comes first Artifact[] sortedDeps = new Artifact[deps.size()]; int i = 1; for (Iterator iter = deps.iterator(); iter.hasNext();) { Artifact artifact = (Artifact) iter.next(); if ("org.grails".equals(artifact.getGroupId()) && "grails-bootstrap".equals(artifact.getArtifactId())) { sortedDeps[0] = artifact; } else { sortedDeps[i] = artifact; i++; } }
And changed
for (Iterator iter = deps.iterator(); iter.hasNext();) {
to
for (Iterator iter = Arrays.asList(sortedDeps).iterator(); iter.hasNext();) {
Regards,
Markus
Note that IDEA 9 (Maia) currently has a bug in its run configuration that includes libraries from plugins in a --classpath argument (IDEA-24117). Unfortunately, this makes it impossible to run any Grails application in Maia that uses the Quartz plugin.