JBoss EAP 7.0.4 java.lang.NoClassDefFoundError

Hi all,

I’m trying to deploy xwiki 9.5 in JBoss EAP 7.0.4. When I try to deploy the war I get the following error:

 15:56:21,793 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."xwiki-9.5.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."xwiki-9.5.war".POST_MODULE: WFLYSRV0153: Falha ao processar a fase POST_MODULE do deployment "xwiki-9.5.war"
	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: WFLYSRV0177: Ocorreu um erro ao obter a informação refletiva para o class com.codahale.metrics.jetty9.InstrumentedHandler$7 com o ClassLoader ModuleClassLoader for Module "deployment.xwiki-9.5.war:main" from Service Module Loader
	at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)
	at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:57)
	at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:106)
	at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:91)
	at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
	... 5 more
Caused by: java.lang.NoClassDefFoundError: Failed to link com/codahale/metrics/jetty9/InstrumentedHandler (Module "deployment.xwiki-9.5.war:main" from Service Module Loader): org/eclipse/jetty/server/handler/HandlerWrapper
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
	at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
	at org.jboss.modules.Module.loadModuleClass(Module.java:605)
	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Class.java:2575)
	at java.lang.Class.getDeclaredFields(Class.java:1908)
	at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:72)
	at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
	... 10 more

I think this is always the same problem: JBoss doesn’t isolate the webapp’s classloader from the rest of the libs it uses itself. There are some instructions at http://platform.xwiki.org/xwiki/bin/view/AdminGuide/InstallationJBoss

Now I’m curious why we’re bundling metrics jars and especially metrics-jetty:

vmassol ~/dev/xwiki/versions/xwiki-platform-distribution-flavor-jetty-hsqldb-9.5.1 $ ls -l webapps/xwiki/WEB-INF/lib/*metric*.jar
-rw-r--r--@ 1 vmassol  staff   43067 Feb 17 18:51 webapps/xwiki/WEB-INF/lib/gmetric4j-1.0.7.jar
-rw-r--r--@ 1 vmassol  staff  112558 Feb 17 18:51 webapps/xwiki/WEB-INF/lib/metrics-core-3.1.2.jar
-rw-r--r--@ 1 vmassol  staff    9219 Feb 17 18:51 webapps/xwiki/WEB-INF/lib/metrics-ganglia-3.1.2.jar
-rw-r--r--@ 1 vmassol  staff   20852 Feb 17 18:51 webapps/xwiki/WEB-INF/lib/metrics-graphite-3.1.2.jar
-rw-r--r--@ 1 vmassol  staff   19327 Feb 17 18:51 webapps/xwiki/WEB-INF/lib/metrics-jetty9-3.1.2.jar
-rw-r--r--@ 1 vmassol  staff   39280 Feb 17 18:51 webapps/xwiki/WEB-INF/lib/metrics-jvm-3.1.2.jar

I’ll try to find where this is coming from.

ok found it, these deps are actually brought by solr-core:

[INFO] --- maven-dependency-plugin:3.0.1:tree (default-cli) @ xwiki-platform-search-solr-server-plugin ---
[INFO] org.xwiki.platform:xwiki-platform-search-solr-server-plugin:jar:9.6-SNAPSHOT
[INFO] +- org.apache.solr:solr-core:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-analyzers-common:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-analyzers-kuromoji:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-analyzers-phonetic:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-backward-codecs:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-classification:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-codecs:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-core:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-expressions:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-grouping:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-highlighter:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-join:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-memory:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-misc:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-queries:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-queryparser:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-sandbox:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-spatial-extras:jar:6.4.2:provided
[INFO] |  +- org.apache.lucene:lucene-suggest:jar:6.4.2:provided
[INFO] |  +- org.apache.solr:solr-solrj:jar:6.4.2:provided
[INFO] |  +- com.carrotsearch:hppc:jar:0.7.1:provided
[INFO] |  +- com.facebook.presto:presto-parser:jar:0.122:provided
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.8.9:provided
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.8.9:provided
[INFO] |  +- com.github.ben-manes.caffeine:caffeine:jar:1.0.1:provided
[INFO] |  +- com.google.guava:guava:jar:20.0:provided
[INFO] |  +- com.google.protobuf:protobuf-java:jar:2.5.0:provided
[INFO] |  +- com.tdunning:t-digest:jar:3.1:provided
[INFO] |  +- commons-cli:commons-cli:jar:1.2:provided
[INFO] |  +- commons-codec:commons-codec:jar:1.10:provided
[INFO] |  +- commons-collections:commons-collections:jar:3.2.2:provided
[INFO] |  +- commons-configuration:commons-configuration:jar:1.10:provided
[INFO] |  +- commons-fileupload:commons-fileupload:jar:1.3.3:provided
[INFO] |  +- commons-io:commons-io:jar:2.5:provided
[INFO] |  +- commons-lang:commons-lang:jar:2.6:provided
[INFO] |  +- info.ganglia.gmetric4j:gmetric4j:jar:1.0.7:provided
[INFO] |  +- io.airlift:slice:jar:0.10:provided
[INFO] |  +- io.dropwizard.metrics:metrics-core:jar:3.1.2:provided
[INFO] |  +- io.dropwizard.metrics:metrics-ganglia:jar:3.1.2:provided
[INFO] |  +- io.dropwizard.metrics:metrics-graphite:jar:3.1.2:provided
[INFO] |  +- io.dropwizard.metrics:metrics-jetty9:jar:3.1.2:provided
[INFO] |  +- io.dropwizard.metrics:metrics-jvm:jar:3.1.2:provided
[INFO] |  +- joda-time:joda-time:jar:2.9.9:provided
[INFO] |  +- org.antlr:antlr4-runtime:jar:4.5.1-1:provided
[INFO] |  +- org.apache.commons:commons-exec:jar:1.3:provided
[INFO] |  +- org.apache.curator:curator-client:jar:2.8.0:provided
[INFO] |  +- org.apache.curator:curator-framework:jar:2.8.0:provided
[INFO] |  +- org.apache.curator:curator-recipes:jar:2.8.0:provided
[INFO] |  +- org.apache.hadoop:hadoop-annotations:jar:2.7.2:provided
[INFO] |  |  \- jdk.tools:jdk.tools:jar:1.8:system
[INFO] |  +- org.apache.hadoop:hadoop-auth:jar:2.7.2:provided
[INFO] |  +- org.apache.hadoop:hadoop-common:jar:2.7.2:provided
[INFO] |  +- org.apache.hadoop:hadoop-hdfs:jar:2.7.2:provided
[INFO] |  +- org.apache.htrace:htrace-core:jar:3.2.0-incubating:provided
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.3:provided
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.6:provided
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.5.3:provided
[INFO] |  +- org.apache.zookeeper:zookeeper:jar:3.4.6:provided
[...]

solr-core is probably drawing too many deps for us and we’ll need to add some dependency exclusions IMO.

Now this is pretty cool. I’ve been wanting to experiment with Dropwizard’s Metrics for a long time already for XWiki. I see that Solr is using it at Metrics Reporting | Apache Solr Reference Guide 6.6. That’s cool. Could even be useful to monitor Solr inside XWiki.

Anyway to solve your issue try to isolate the JBoss classloaders.

FTR someone asked the question here too (without answer): http://xwiki.475771.n2.nabble.com/xwiki-war-deploy-issue-td7603835.html

Fixed in Loading...