Grails Maven Plugin

Quartz conflicts with grails-bootstrap

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Major 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

Activity

Hide
Michael Werle added a comment -

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.

Show
Michael Werle added a comment - 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.
Hide
Peter Ledbrook added a comment -

I think renaming build.properties to grails.build.properties is a good idea. We should also look at making sure that the bootstrap is always first on the classpath. Graeme?

Show
Peter Ledbrook added a comment - I think renaming build.properties to grails.build.properties is a good idea. We should also look at making sure that the bootstrap is always first on the classpath. Graeme?
Hide
Graeme Rocher added a comment -

Seems like a good idea to me

Show
Graeme Rocher added a comment - Seems like a good idea to me
Hide
Martin Gerlach added a comment - - edited

Attached patch file for AbstractGrailsMojo.java (applies to V1.1 and V1.2.0 of the plugin)

Show
Martin Gerlach added a comment - - edited Attached patch file for AbstractGrailsMojo.java (applies to V1.1 and V1.2.0 of the plugin)
Hide
Ronny Løvtangen added a comment -

This is a problem in Grails 1.3.2 as well (using org.quartz-scheduler:quartz:1.8.0)

Show
Ronny Løvtangen added a comment - This is a problem in Grails 1.3.2 as well (using org.quartz-scheduler:quartz:1.8.0)
Hide
Peter Ledbrook added a comment -

Hmmm...this is probably because we throw a lot of the runtime dependencies on to the build classpath. Ideally, only the grails-bootstrap, Groovy, and Ant libraries would be on the classpath. That's something that would be fixed relatively easily with Gradle, but certainly renaming build.properties to grails.build.properties makes sense. We'd have to mark it as a breaking change, but only a minor one.

Show
Peter Ledbrook added a comment - Hmmm...this is probably because we throw a lot of the runtime dependencies on to the build classpath. Ideally, only the grails-bootstrap, Groovy, and Ant libraries would be on the classpath. That's something that would be fixed relatively easily with Gradle, but certainly renaming build.properties to grails.build.properties makes sense. We'd have to mark it as a breaking change, but only a minor one.
Hide
Ronny Løvtangen added a comment - - edited

4 days to scheduled 1.3.3 release date, and 64 unresolved Jiras, so I guess some Jiras will be pushed down to 1.3.4?
If it's not enough time to do both tasked described in this Jira (rename property file, fix classpath issue), could it be split into two Jiras so that at least renaming of build.properties can make it into 1.3.3? This is what now keeps me from upgrading from 1.2.1.

Show
Ronny Løvtangen added a comment - - edited 4 days to scheduled 1.3.3 release date, and 64 unresolved Jiras, so I guess some Jiras will be pushed down to 1.3.4? If it's not enough time to do both tasked described in this Jira (rename property file, fix classpath issue), could it be split into two Jiras so that at least renaming of build.properties can make it into 1.3.3? This is what now keeps me from upgrading from 1.2.1.
Hide
Graeme Rocher added a comment -

We are bringing forward 1.3.3 to fix the maven plugin resolution bug which means yes many issues will be pushed back to 1.3.4

Show
Graeme Rocher added a comment - We are bringing forward 1.3.3 to fix the maven plugin resolution bug which means yes many issues will be pushed back to 1.3.4
Hide
Darrin McCarthy added a comment -

Is this issue still scheduled to be fixed in 1.3.5?

Show
Darrin McCarthy added a comment - Is this issue still scheduled to be fixed in 1.3.5?
Hide
Ronny Løvtangen added a comment -

I wouldn't count on it. It has been on the list for the latest releases, but always been pushed down to next release when time is up. I have abandoned Quartz because of this, so I don't need it to be fixed anymore, but it's a blocker for projects using Quartz.

Show
Ronny Løvtangen added a comment - I wouldn't count on it. It has been on the list for the latest releases, but always been pushed down to next release when time is up. I have abandoned Quartz because of this, so I don't need it to be fixed anymore, but it's a blocker for projects using Quartz.

People

Vote (7)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: