mattcj / jacocotogo

A Maven Plugin for fetching JaCoCo data from remote servers.
http://jacocotogo.helmetsrequired.org/
Apache License 2.0
11 stars 9 forks source link

Cannot connect to WildFly via JMX #1

Open kriegaex opened 9 years ago

kriegaex commented 9 years ago

I am trying to instrument WARs inside WildFly 8.2.0 with JaCoCo via Arquillian for integration test coverage.

URL variant 1:

<serviceURL>service:jmx:http-remoting-jmx://localhost:9990</serviceURL>

Error variant 1:

[INFO] --- jacocotogo-maven-plugin:1.1:jmx (get_integration_test_coverage) @ sdv.okv.cbom.dokumentgenerierung.wildfly ---
[DEBUG] Configuring mojo org.helmetsrequired:jacocotogo-maven-plugin:1.1:jmx from plugin realm ClassRealm[plugin>org.helmetsrequired:jacocotogo-maven-plugin:1.1, parent: sun.misc.Launcher$AppClassLoader@6d06d69c]
[DEBUG] Configuring mojo 'org.helmetsrequired:jacocotogo-maven-plugin:1.1:jmx' with basic configurator -->
[DEBUG]   (s) failOnError = false
[DEBUG]   (s) outputFile = target/jacoco-it-dump.exec
[DEBUG]   (s) password = XXXXX
[DEBUG]   (s) resetAfterFetch = true
[DEBUG]   (s) serviceURL = service:jmx:http-remoting-jmx://localhost:9990
[DEBUG]   (s) username = XXXXX
[DEBUG] -- end configuration --
[DEBUG] Constructing JMXServiceURL from String: 'service:jmx:http-remoting-jmx://localhost:9990'
[DEBUG] Constructing JMXConnector for JMXServiceURL: 'service:jmx:http-remoting-jmx://localhost:9990'
[WARNING] Exception while running plugin.  failOnError = false. IOException while communicating with JMXServiceURL: 'service:jmx:http-remoting-jmx://localhost:9990'

URL variant 2:

<serviceURL>service:jmx:rmi:///jndi/rmi://localhost:9990</serviceURL>

Error variant 2:

[ERROR] Failed to execute goal org.helmetsrequired:jacocotogo-maven-plugin:1.1:jmx (get_integration_test_coverage) on project sdv.okv: A type incompatibility occured while executing org.helmetsrequired:jacocotogo-maven-plugin:1.1:jmx: com.sun.jndi.rmi.registry.RegistryContext cannot be cast to javax.management.remote.rmi.RMIServer
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.helmetsrequired:jacocotogo-maven-plugin:1.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/development/mvn-local-repository/org/helmetsrequired/jacocotogo-maven-plugin/1.1/jacocotogo-maven-plugin-1.1.jar
[ERROR] urls[1] = file:/C:/development/mvn-local-repository/org/slf4j/slf4j-jdk14/1.7.5/slf4j-jdk14-1.7.5.jar
[ERROR] urls[2] = file:/C:/development/mvn-local-repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
[ERROR] urls[3] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar
[ERROR] urls[4] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
[ERROR] urls[5] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar
[ERROR] urls[6] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-tools-annotations/3.2/maven-plugin-tools-annotations-3.2.jar
[ERROR] urls[7] = file:/C:/development/mvn-local-repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[8] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[9] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.2/maven-plugin-tools-api-3.2.jar
[ERROR] urls[10] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
[ERROR] urls[11] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar
[ERROR] urls[12] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[13] = file:/C:/development/mvn-local-repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[14] = file:/C:/development/mvn-local-repository/asm/asm/3.3.1/asm-3.3.1.jar
[ERROR] urls[15] = file:/C:/development/mvn-local-repository/asm/asm-commons/3.3.1/asm-commons-3.3.1.jar
[ERROR] urls[16] = file:/C:/development/mvn-local-repository/asm/asm-tree/3.3.1/asm-tree-3.3.1.jar
[ERROR] urls[17] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-archiver/2.1.1/plexus-archiver-2.1.1.jar
[ERROR] urls[18] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-io/2.0.3/plexus-io-2.0.3.jar
[ERROR] urls[19] = file:/C:/development/mvn-local-repository/com/thoughtworks/qdox/qdox/1.12.1/qdox-1.12.1.jar
[ERROR] urls[20] = file:/C:/development/mvn-local-repository/org/jacoco/org.jacoco.core/0.6.3.201306030806/org.jacoco.core-0.6.3.201306030806.jar
[ERROR] urls[21] = file:/C:/development/mvn-local-repository/org/ow2/asm/asm-all/4.1/asm-all-4.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.helmetsrequired:jacocotogo-maven-plugin:1.1:jmx (get_integration_test_coverage) on project sdv.okv: A type incompatibility occured while executing org.helmetsrequired:jacocotogo-maven-plugin:1.1:jmx: com.sun.jndi.rmi.registry.RegistryContext cannot be cast to javax.management.remote.rmi.RMIServer
-----------------------------------------------------
realm =    plugin>org.helmetsrequired:jacocotogo-maven-plugin:1.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/development/mvn-local-repository/org/helmetsrequired/jacocotogo-maven-plugin/1.1/jacocotogo-maven-plugin-1.1.jar
urls[1] = file:/C:/development/mvn-local-repository/org/slf4j/slf4j-jdk14/1.7.5/slf4j-jdk14-1.7.5.jar
urls[2] = file:/C:/development/mvn-local-repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
urls[3] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar
urls[4] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
urls[5] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar
urls[6] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-tools-annotations/3.2/maven-plugin-tools-annotations-3.2.jar
urls[7] = file:/C:/development/mvn-local-repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
urls[8] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
urls[9] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.2/maven-plugin-tools-api-3.2.jar
urls[10] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
urls[11] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar
urls[12] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[13] = file:/C:/development/mvn-local-repository/junit/junit/3.8.1/junit-3.8.1.jar
urls[14] = file:/C:/development/mvn-local-repository/asm/asm/3.3.1/asm-3.3.1.jar
urls[15] = file:/C:/development/mvn-local-repository/asm/asm-commons/3.3.1/asm-commons-3.3.1.jar
urls[16] = file:/C:/development/mvn-local-repository/asm/asm-tree/3.3.1/asm-tree-3.3.1.jar
urls[17] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-archiver/2.1.1/plexus-archiver-2.1.1.jar
urls[18] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-io/2.0.3/plexus-io-2.0.3.jar
urls[19] = file:/C:/development/mvn-local-repository/com/thoughtworks/qdox/qdox/1.12.1/qdox-1.12.1.jar
urls[20] = file:/C:/development/mvn-local-repository/org/jacoco/org.jacoco.core/0.6.3.201306030806/org.jacoco.core-0.6.3.201306030806.jar
urls[21] = file:/C:/development/mvn-local-repository/org/ow2/asm/asm-all/4.1/asm-all-4.1.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    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:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.apache.maven.plugin.PluginExecutionException: A type incompatibility occured while executing org.helmetsrequired:jacocotogo-maven-plugin:1.1:jmx: com.sun.jndi.rmi.registry.RegistryContext cannot be cast to javax.management.remote.rmi.RMIServer
-----------------------------------------------------
realm =    plugin>org.helmetsrequired:jacocotogo-maven-plugin:1.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/development/mvn-local-repository/org/helmetsrequired/jacocotogo-maven-plugin/1.1/jacocotogo-maven-plugin-1.1.jar
urls[1] = file:/C:/development/mvn-local-repository/org/slf4j/slf4j-jdk14/1.7.5/slf4j-jdk14-1.7.5.jar
urls[2] = file:/C:/development/mvn-local-repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
urls[3] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar
urls[4] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
urls[5] = file:/C:/development/mvn-local-repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar
urls[6] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-tools-annotations/3.2/maven-plugin-tools-annotations-3.2.jar
urls[7] = file:/C:/development/mvn-local-repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
urls[8] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
urls[9] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.2/maven-plugin-tools-api-3.2.jar
urls[10] = file:/C:/development/mvn-local-repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
urls[11] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar
urls[12] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[13] = file:/C:/development/mvn-local-repository/junit/junit/3.8.1/junit-3.8.1.jar
urls[14] = file:/C:/development/mvn-local-repository/asm/asm/3.3.1/asm-3.3.1.jar
urls[15] = file:/C:/development/mvn-local-repository/asm/asm-commons/3.3.1/asm-commons-3.3.1.jar
urls[16] = file:/C:/development/mvn-local-repository/asm/asm-tree/3.3.1/asm-tree-3.3.1.jar
urls[17] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-archiver/2.1.1/plexus-archiver-2.1.1.jar
urls[18] = file:/C:/development/mvn-local-repository/org/codehaus/plexus/plexus-io/2.0.3/plexus-io-2.0.3.jar
urls[19] = file:/C:/development/mvn-local-repository/com/thoughtworks/qdox/qdox/1.12.1/qdox-1.12.1.jar
urls[20] = file:/C:/development/mvn-local-repository/org/jacoco/org.jacoco.core/0.6.3.201306030806/org.jacoco.core-0.6.3.201306030806.jar
urls[21] = file:/C:/development/mvn-local-repository/org/ow2/asm/asm-all/4.1/asm-all-4.1.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:196)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 26 more
Caused by: java.lang.ClassCastException: com.sun.jndi.rmi.registry.RegistryContext cannot be cast to javax.management.remote.rmi.RMIServer
    at javax.management.remote.rmi.RMIConnector.narrowJRMPServer(RMIConnector.java:1968)
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1963)
    at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1924)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:249)
    at org.helmetsrequired.jacocotogo.JaCoCoToGo.getExecutionDataViaJMX(JaCoCoToGo.java:205)
    at org.helmetsrequired.jacocotogo.JaCoCoToGo.fetchJaCoCoDataOverJmx(JaCoCoToGo.java:82)
    at org.helmetsrequired.jacocotogo.JaCoCoToGoJmxMojo.execute(JaCoCoToGoJmxMojo.java:81)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    ... 27 more

I am a JMX newbie, so I cannot understand the error messages, sorry. Maybe you can. The JMX switch for the JaCoCo Maven Plugin is set, by the way.

mattcj commented 9 years ago

Thanks for reporting this. My first guess is that the newer versions of jacoco have likely changed some code and the jacocotogo plugin is likely not compatible without some code changes. I'll try to take a look soon. In the interim if you are able to use an older version of jacoco that may work for you.

kriegaex commented 9 years ago

I'd rather wait for a plugin update because I have tried to use the JaCoCo version defined in your plugin POM, but that one is so old, it does not even know the goals we are using, such as prepare-agent-integration.

mattcj commented 9 years ago

Ok, so I finally started looking at this, and part of the problem is actually just the serviceURL you are providing. It appears you are missing the "/jmxrmi" at the end of the URL.

<serviceURL>service:jmx:rmi:///jndi/rmi://localhost:9990/jmxrmi</serviceURL>

Try adding that and see if it corrects the issue. If it still fails after that I may need to create a new release with the updated JaCoCo dependency. The code change is easy, but getting it built and deployed out to central will require me to fix up my build environment.