Thanks for coming up with this workaround. The issue is not really a big deal 
for us because it works from the command line and also using a different Maven 
installation in m2eclipse. Inside Eclipse we usually use the TestNG plugin 
anyways.

My question now is: Is this a bug in m2eclipse or a Maven issue? Should I 
create a JIRA ticket? As mentioned, the problem does not show up with Maven 
2.0.10 or 2.1-RC2 (neither externally nor withing m2eclipse), but with the 
embedded 2.1-SNAPSHOT only.

Reinhard


-----Original Message-----
From: stug23 [mailto:[email protected]] 
Sent: Wednesday, March 11, 2009 5:05 PM
To: [email protected]
Subject: Re: [m2eclipse-user] Error using javaagent in Surefire plugin


There is a workaround that doesn't require m2eclipse to resolve settings 
properties (although it most certainly should) that I found to work quite
nicely:

   <http://openejb.apache.org/3.0/javaagent-with-maven-surefire.html>



Reinhard Nägele wrote:
> 
> Hello,
> 
> We use JMockit and TestNG for unit tests. The Surefire plugin is 
> configured as follows:
> 
> <plugin>
>   <groupId>org.apache.maven.plugins</groupId>
>   <artifactId>maven-surefire-plugin</artifactId>
>   <version>2.4.3</version>
>   <configuration>
>    
> <argLine>-javaagent:"${settings.localRepository}/jmockit/jmockit/{jmockit.version}/jmockit-${jmockit.version}.jar"</argLine>
>   </configuration>
> </plugin>
> 
> Using the embedded Maven installation of m2eclipse 
> (0.9.7.200811301806), we get an error. From the console output it 
> seems that ${settings.localRepository} is not replaced, but 
> ${jmockit.version} actually is. The problem does not show up with 
> Maven 2.0.10 and 2.1.0-M1 (neither externally nor withing m2eclipse).
> 
> Reinhard
> 
> 
> [DEBUG] Using JVM: C:\Java\jdk1.5.0_16\jre\bin\java [INFO] Surefire 
> report directory: <...> Forking command line: cmd.exe /X /C 
> "C:\Java\jdk1.5.0_16\jre\bin\java 
> -javaagent:${settings.localRepository}/jmockit/jmockit/0.94/jmockit-0.
> 94.jar -jar C:\DOKUME~1\rnaegele\LOKALE~1\Temp\surefirebooter28747.jar
> C:\DOKUME~1\rnaegele\LOKALE~1\Temp\surefire28745tmp
> C:\DOKUME~1\rnaegele\LOKALE~1\Temp\surefire28746tmp"
> Error occurred during initialization of VM agent library failed to 
> init: instrument Error opening zip file:
> ${settings.localRepository}/jmockit/jmockit/0.94/jmockit-0.94.jar
> [DEBUG] disposing managed ClassRealm with id:
> /plugins/org.apache.maven.plugins:maven-surefire-plugin:2....@48/threa
> d:main [DEBUG] dissociating all components from managed ClassRealm 
> with id:
> /plugins/org.apache.maven.plugins:maven-surefire-plugin:2....@48/threa
> d:main [DEBUG] disposing managed ClassRealm with id:
> /plugins/org.apache.maven.plugins:maven-compiler-plugin:2....@48/threa
> d:main [DEBUG] dissociating all components from managed ClassRealm 
> with id:
> /plugins/org.apache.maven.plugins:maven-compiler-plugin:2....@48/threa
> d:main [DEBUG] disposing managed ClassRealm with id: 
> /projects/<...>/thread:main [DEBUG] dissociating all components from 
> managed ClassRealm with id:
> /projects/<...>/thread:main
> [DEBUG] disposing managed ClassRealm with id:
> /plugins/org.apache.maven.plugins:maven-resources-plugin:2...@48/thread
> :main [DEBUG] dissociating all components from managed ClassRealm with 
> id:
> /plugins/org.apache.maven.plugins:maven-resources-plugin:2...@48/thread
> :main [DEBUG] disposing managed ClassRealm with id:
> /extensions/org.apache.maven.wagon:wagon-webdav:1.0-beta-2/thread:main
> [DEBUG] dissociating all components from managed ClassRealm with id:
> /extensions/org.apache.maven.wagon:wagon-webdav:1.0-beta-2/thread:main
> [ERROR]
> 
> Mojo: 
> 
>     org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test
> 
> FAILED for project: 
> 
>     <...>
> 
> Reason:
> 
> There are test failures.
> 
> Please refer to <...> for the individual test results.
> 
> 
> 
> 
> 
> Error stacktrace:
> org.apache.maven.ProjectBuildFailureException: Build for project: 
> <...> failed during execution of mojo:
> org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:293)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:191)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:149)
>       at
> org.apache.maven.DefaultMaven.execute_aroundBody0(DefaultMaven.java:223)
>       at
> org.apache.maven.DefaultMaven.execute_aroundBody1$advice(DefaultMaven.java:304)
>       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:1)
>       at
> org.apache.maven.embedder.MavenEmbedder.execute_aroundBody2(MavenEmbedder.java:904)
>       at
> org.apache.maven.embedder.MavenEmbedder.execute_aroundBody3$advice(MavenEmbedder.java:304)
>       at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:1)
>       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:176)
>       at org.apache.maven.cli.MavenCli.main(MavenCli.java:63)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:585)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:408)
>       at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:351)
>       at org.codehaus.classworlds.Launcher.main(Launcher.java:31)
> Caused by: org.apache.maven.plugin.MojoFailureException: There are 
> test failures.
> 
> Please refer to <...> for the individual test results.
>       at
> org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:575)
>       at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:579)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:498)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:265)
>       ... 19 more
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 
> 

--
View this message in context: 
http://www.nabble.com/Error-using-javaagent-in-Surefire-plugin-tp22429241p22458377.html
Sent from the Maven Eclipse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to