Skip to content
This repository has been archived by the owner on Aug 21, 2021. It is now read-only.

java.lang.NoClassDefFoundError: javax/xml/bind/JAXB #25

Closed
aschepp opened this issue Jul 2, 2019 · 18 comments · Fixed by #28
Closed

java.lang.NoClassDefFoundError: javax/xml/bind/JAXB #25

aschepp opened this issue Jul 2, 2019 · 18 comments · Fixed by #28

Comments

@aschepp
Copy link

aschepp commented Jul 2, 2019

I tried to run the Crowd plugin 2.1.2 on Sonarqube 7.9 on OpenJDK 11 and I run into this problem on startup:

2019.07.02 14:41:31 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
java.lang.NoClassDefFoundError: javax/xml/bind/JAXB
at com.atlassian.crowd.integration.rest.service.RestExecutor.setBody(RestExecutor.java:204)
at com.atlassian.crowd.integration.rest.service.RestExecutor.post(RestExecutor.java:176)
at com.atlassian.crowd.integration.rest.service.RestCrowdClient.searchUsers(RestCrowdClient.java:511)
at com.atlassian.crowd.integration.rest.service.RestCrowdClient.testConnection(RestCrowdClient.java:500)
at org.sonar.plugins.crowd.CrowdRealm.init(CrowdRealm.java:97)
at org.sonar.server.user.SecurityRealmFactory.start(SecurityRealmFactory.java:87)
at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
at org.picocontainer.behaviors.Stored.start(Stored.java:110)
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)
at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:545)
at org.sonar.server.platform.Platform.start(Platform.java:211)
at org.sonar.server.platform.Platform.startLevel34Containers(Platform.java:185)
at org.sonar.server.platform.Platform.access$500(Platform.java:46)
at org.sonar.server.platform.Platform$1.lambda$doRun$0(Platform.java:119)
at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(Platform.java:371)
at org.sonar.server.platform.Platform$1.doRun(Platform.java:119)
at org.sonar.server.platform.Platform$AutoStarterRunnable.run(Platform.java:355)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXB
at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
... 25 common frames omitted

@frdeboffles
Copy link

I attempted to add javax.xml.bind:jaxb-api:2.3.0 to the pom dependencies but then I'm hitting some issues that it needs a jaxb implementation.

JAXBException: Implementation of JAXB-API has not been found on module path or classpath.

Therefore I also added javax.activation:activation:1.1, org.glassfish.jaxb:jaxb-runtime:2.3.0 to the pom with the same exact result... Finally I only kept javax.xml.bind:jaxb-api:2.3.0 in the plugin pom and manually added javax.activation:activation:1.1, org.glassfish.jaxb:jaxb-runtime:2.3.0 in the sonarqube-7.9/lib/common directory. This lead to the following error:

javax.xml.bind.DataBindingException: javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/opt/sonar/sonarqube-7.9/lib/common/jaxb-api-2.3.0.jar!/javax/xml/bind/JAXBContext.class to jar:file:/opt/sonar/sonarqube-7.9/data/web/deploy/plugins/crowd/META-INF/lib/jaxb-api-2.3.0.jar!/javax/xml/bind/JAXBContext.class.  Please make sure that you are specifying the proper ClassLoader.
	at javax.xml.bind.JAXB._marshal(JAXB.java:589)
	at javax.xml.bind.JAXB.marshal(JAXB.java:447)
	at com.atlassian.crowd.integration.rest.service.RestExecutor.setBody(RestExecutor.java:204)
	at com.atlassian.crowd.integration.rest.service.RestExecutor.post(RestExecutor.java:176)
	at com.atlassian.crowd.integration.rest.service.RestCrowdClient.searchUsers(RestCrowdClient.java:511)
	at com.atlassian.crowd.integration.rest.service.RestCrowdClient.testConnection(RestCrowdClient.java:500)
	at org.sonar.plugins.crowd.CrowdRealm.init(CrowdRealm.java:97)

@zrsm
Copy link

zrsm commented Jul 3, 2019

I've been working on this for a while. I believe that this issue isn't happening because of sonar-crowd, but because in Java11 JAXB has been completely removed.

I've found a number of different issues, but more importantly, the issue here:

https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/build.gradle

Shows that there is a dependency for JAXB being included. I have not been able to get this to work yet.. Currently looking for a way to manually install JAXB in the class path... Anyone have any suggestions? It would be nice to raise a PR for this on the Sonarqube side.

@zrsm
Copy link

zrsm commented Jul 4, 2019

I went even deeper... @frdeboffles you need to include

com.sun.xml.bind
jaxb-impl
2.1

in the sonar-crowd pom.xml file, also download jaxb-impl-2.1 into sonarqube-7.9/lib/common ... make sure that all of the dependencies match in version, otherwise you will get a REFLECTION error.

Then after all of that troubleshooting,

2019.07.03 20:18:39 INFO  web[][o.s.p.ProcessEntryPoint] Starting web
2019.07.03 20:18:40 INFO  web[][o.a.t.u.n.NioSelectorPool] Using a shared selector for servlet write/read
2019.07.03 20:18:41 ERROR web[][o.s.s.a.EmbeddedTomcat] Fail to start web server
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:427)
        at org.sonar.server.app.EmbeddedTomcat.start(EmbeddedTomcat.java:65)
        at org.sonar.server.app.WebServer.start(WebServer.java:52)
        at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:97)
        at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:81)
        at org.sonar.server.app.WebServer.main(WebServer.java:99)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 8 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:942)
        ... 12 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 common frames omitted
Caused by: org.apache.tomcat.util.MultiThrowable: null
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:946)
        ... 8 common frames omitted

I don't want to give up but, I think with all this hacked up stuff. i'm kind of out of options.

@deepy
Copy link
Owner

deepy commented Jul 4, 2019

Thank you all for the investigations! I'm currently in the process of moving so I won't be able to look at it this week, if someone has a PR I'll be able to test it on Sunday

@colin-sonarsource
Copy link

@deepy Is it alright if I move to mark Crowd v2.1.2 as incompatible with SonarQube v7.9 (compatibility ending at v7.8)?

@deepy
Copy link
Owner

deepy commented Jul 5, 2019

@colin-mueller-sonarsource that'd be great! Thank you!

@colin-sonarsource
Copy link

@deepy Done. As always, thanks for maintaining this project! Looking forward to a 7.9 compatible version :)

@frdeboffles
Copy link

Found an ugly way to fix this plugin. I'll create a PR soon.

frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 8, 2019
Force the thread context loader (use when authenticating) to use the plugin context loader.
frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 8, 2019
Added javax.xml.bind:jaxb-api:2.3.0, javax.activation:activation:1.1, com.sun.xml.bind:jaxb-core:2.3.0 and org.glassfish.jaxb:jaxb-runtime:2.3.0 dependencies.
Forced the thread context loader (use when authenticating) to use the plugin context loader.
frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 8, 2019
fixes deepy#25
Ref: deepy#25
Added javax.xml.bind:jaxb-api:2.3.0, javax.activation:activation:1.1, com.sun.xml.bind:jaxb-core:2.3.0 and org.glassfish.jaxb:jaxb-runtime:2.3.0 dependencies.
Forced the thread context loader (use when authenticating) to use the plugin context loader.
@zrsm
Copy link

zrsm commented Jul 8, 2019 via email

@frdeboffles
Copy link

@robmcelvenny Can you paste a bit more of your stacktrace?

@zrsm
Copy link

zrsm commented Jul 8, 2019 via email

@deepy
Copy link
Owner

deepy commented Jul 8, 2019

Had to recreate my testbed so I didn't have time to investigate further, but the PR is not working for me with sq 7.9 :-(

@zrsm
Copy link

zrsm commented Jul 8, 2019

Here was the error after fixing the jaxb-api / jaxb-impl / jaxb-core issue:

java.lang.NoClassDefFoundError: com/sun/istack/Pool at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1156) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:165) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:297) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:286) at javax.xml.bind.ContextFinder.find(ContextFinder.java:409) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662) at javax.xml.bind.JAXB$Cache.<init>(JAXB.java:127) at javax.xml.bind.JAXB.getContext(JAXB.java:154) at javax.xml.bind.JAXB._marshal(JAXB.java:578) at javax.xml.bind.JAXB.marshal(JAXB.java:447) at com.atlassian.crowd.integration.rest.service.RestExecutor.setBody(RestExecutor.java:204) at com.atlassian.crowd.integration.rest.service.RestExecutor.post(RestExecutor.java:176) at com.atlassian.crowd.integration.rest.service.RestCrowdClient.searchUsers(RestCrowdClient.java:511) at com.atlassian.crowd.integration.rest.service.RestCrowdClient.testConnection(RestCrowdClient.java:500) at org.sonar.plugins.crowd.CrowdRealm.init(CrowdRealm.java:97) at org.sonar.server.user.SecurityRealmFactory.start(SecurityRealmFactory.java:87) at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40) at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) at org.picocontainer.behaviors.Stored.start(Stored.java:110) at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016) at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009) at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135) at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90) at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:545) at org.sonar.server.platform.Platform.start(Platform.java:211) at org.sonar.server.platform.Platform.startLevel34Containers(Platform.java:185) at org.sonar.server.platform.Platform.access$500(Platform.java:46) at org.sonar.server.platform.Platform$1.lambda$doRun$0(Platform.java:119) at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(Platform.java:371) at org.sonar.server.platform.Platform$1.doRun(Platform.java:119) at org.sonar.server.platform.Platform$AutoStarterRunnable.run(Platform.java:355) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.ClassNotFoundException: com.sun.istack.Pool at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 40 common frames omitted

frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 8, 2019
fixes deepy#25
Ref: deepy#25
Added javax.xml.bind:jaxb-api:2.3.0, javax.activation:activation:1.1, com.sun.xml.bind:jaxb-core:2.3.0 and org.glassfish.jaxb:jaxb-runtime:2.3.0 dependencies.
Forced the thread context loader (use when authenticating) to use the plugin context loader.
frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 8, 2019
fixes deepy#25
Ref: deepy#25
Added javax.xml.bind:jaxb-api:2.3.0, javax.activation:activation:1.1, com.sun.xml.bind:jaxb-core:2.3.0 and org.glassfish.jaxb:jaxb-runtime:2.3.0 dependencies.
Forced the thread context loader (use when authenticating) to use the plugin context loader.
frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 8, 2019
fixes deepy#25
Added javax.xml.bind:jaxb-api:2.3.0, javax.activation:activation:1.1, com.sun.xml.bind:jaxb-core:2.3.0 and org.glassfish.jaxb:jaxb-runtime:2.3.0 dependencies.
Forced the thread context loader (use when authenticating) to use the plugin context loader.
@frdeboffles
Copy link

@robmcelvenny, @deepy, did some updates to the PR. It should work now.

@shivendrakd
Copy link

Can someone please share jar file having fixed commit 020274b ?

frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 10, 2019
fixes deepy#25
Added javax.xml.bind:jaxb-api:2.3.0, javax.activation:activation:1.1, com.sun.xml.bind:jaxb-core:2.3.0 and org.glassfish.jaxb:jaxb-runtime:2.3.0 dependencies.
Forced the thread ClassLoader to use the class ClassLoader on all public methods in this package.
AOP weaving done at compile time by aspectj-maven-plugin.
frdeboffles pushed a commit to frdeboffles/sonar-crowd that referenced this issue Jul 10, 2019
fixes deepy#25
Added javax.xml.bind:jaxb-api:2.3.0, javax.activation:activation:1.1, com.sun.xml.bind:jaxb-core:2.3.0 and org.glassfish.jaxb:jaxb-runtime:2.3.0 dependencies.
Forced the thread ClassLoader to use the class ClassLoader on all public methods in this package.
AOP weaving done at compile time by aspectj-maven-plugin.
Uses com.nickwongdev:aspectj-maven-plugin:1.12.1 maven plugin to also build using jdk 11.
@deepy deepy closed this as completed in #28 Jul 14, 2019
@shivendrakd
Copy link

New crowd plugin is avaialbel for SonarQube 7.9 ?

Please share if available

@kamal951
Copy link

The version 2.1.3 is working with Sonarqube 7.9. You can found it here https://github.com/deepy/sonar-crowd/releases

@aschepp
Copy link
Author

aschepp commented Jul 22, 2019

Thanks, I just installed 2.1.3 and it works again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants