After Spock Grails Plugin Install, run-app fails with LinkageError (MBeanServer)

226 views
Skip to first unread message

David Padbury

unread,
Sep 29, 2010, 10:53:48 AM9/29/10
to Spock Framework - User
Hi Guys,

Sorry for the basic tech support nature of this message. Firstly, I've
just started using Spock and I'm really impressed. It's certainly one
of the most innovative and exciting testing frameworks I've seen in
quite a while.

So after investigating Spock for a couple of days, I decided to plug
it in to our Grails project using the plugin. (If it matters, the
project itself is being run via Maven). I'm able to run the spock
specifications perfectly (using the command: mvn grails:exec -
Dcommand="test-app" "unit:spock"). However when executing the run-app
command or trying the interaction tests, it fails with the following
message:

java.lang.LinkageError: loader constraint violation: loader (instance
of <bootloader>) previously initiated loading for a different type
with name "javax/management/MBeanServer"

I've been trying to investigate this for a little while but haven't
had much luck. Does anyone have any suggestions for how I could
attempt to fix this? I'm using grails 1.3.2, maven 2.2.1, and spock
plugin 0.4-groovy-1.7.

In case it's relevant, I did hit a bit of a bump installing the spock
plugin which is probably worth highlighting. I also tested this in a
fresh application created using the official grails instructions on
getting started via maven. The spock plugin installed correctly, but
on run-app I hit the following errror:

[groovyc] C:\dev\projects\grails-spock\my-app\plugins\spock-0.4-
groovy-1.7\src\groovy\grails\plugin\spock\FunctionalSpec.groovy: 19:
unable to resolve class spock.lang.Shared
[groovyc] @ line 19, column 1.
[groovyc] import spock.lang.Shared
[groovyc] ^

To resolve this in both my sample and my real project, I place a
dependency on spock in the project pom.xml:

<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>0.4-groovy-1.7</version>
</dependency>

After this, the sample application seems to work correctly, where as I
get the MBeanServer LinkageError in my real project.

Many thanks,

David Padbury.

David Padbury

unread,
Sep 29, 2010, 11:52:07 AM9/29/10
to Spock Framework - User
I managed to pin down the problem. In the plugin dependencies.groovy,
if I comment out the three "test" dependencies (htmlunit, xalan and
jetty), the spock unit specifications execute and the application is
able to run. I assume that one of these packages has a dependency on
the package including MBeanServer which is conflicting with a similar
dependency elsewhere in my project.

Is this a general problem, or unique to something I'm doing?

David.

Peter Niederwieser

unread,
Sep 29, 2010, 12:21:27 PM9/29/10
to spockfr...@googlegroups.com
Hi David, 

thanks for the detailed problem report. I'm guessing that somehow a JMX implementation gets pulled in. However, JDK 1.5 and above already ship with a JMX implementation, hence the conflict.
Maybe we can place an exclude somewhere to solve this problem for everyone (as we require JDK 1.5 anyway).
Dependency management for the Grails Spock plugin has proven to be a hard problem. That's why we have changed some internals in 0.5 (we now go through an intermediate grails-spock-support Jar). Please try 0.5-SNAPSHOT and see if it works for you.

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to spockfr...@googlegroups.com.
To unsubscribe from this group, send email to spockframewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.


----------------------------------------------------------------
Peter Niederwieser
Twitter: pniederw









David Padbury

unread,
Sep 29, 2010, 12:49:14 PM9/29/10
to Spock Framework - User
Hi Peter,

Thank you for the swift response. I've just tested out 0.5-groovy-1.7-
SNAPSHOT. The good news is that the issue requiring me to manually add
spock-core to the pom seems to have disappeared. Unfortunately, I
still have the MBeanServer issue, and now that I can't remove those
dependencies from the plugin, I can't seem to find any way to get it
to run.

I'll roll back to 0.4 for the time being. As there's none of our code
in it I've included the full stacktrace in case it's helpful.

Thanks again!

David.

java.lang.LinkageError: loader constraint violation: loader (instance
of <bootloader>) previously initiated loading for a different type
with name "javax/management/MBeanServer"
at
javax.management.MBeanServerBuilder.newMBeanServerDelegate(MBeanServerBuilder.java:
49)
at
javax.management.MBeanServerFactory.newMBeanServer(MBeanServerFactory.java:
302)
at
javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:
213)
at
javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:
174)
at
java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:
504)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:
164)
at grails.web.container.EmbeddableServer$start.call(Unknown
Source)
at _GrailsRun$_run_closure5_closure12.doCall(_GrailsRun.groovy:
159)
at _GrailsRun
$_run_closure5_closure12.doCall(_GrailsRun.groovy)
at _GrailsSettings
$_run_closure10.doCall(_GrailsSettings.groovy:282)
at _GrailsSettings$_run_closure10.call(_GrailsSettings.groovy)
at _GrailsRun$_run_closure5.doCall(_GrailsRun.groovy:150)
at _GrailsRun$_run_closure5.call(_GrailsRun.groovy)
at _GrailsRun.runInline(_GrailsRun.groovy:116)
at _GrailsRun.this$4$runInline(_GrailsRun.groovy)
at _GrailsRun$_run_closure1.doCall(_GrailsRun.groovy:59)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown
Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
at
org.grails.maven.plugin.AbstractGrailsMojo.runGrails(AbstractGrailsMojo.java:
277)
at
org.grails.maven.plugin.GrailsRunAppMojo.execute(GrailsRunAppMojo.java:
35)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:
490)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:
694)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:
569)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:
539)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:
387)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:
348)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:
180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:
328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:
138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:
60)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> pnied...@gmail.com
> Twitter: pniederw
Reply all
Reply to author
Forward
0 new messages