2

My application is using Java 11, Tomcat 9.0.13 and OpenWeBeans CDI 2.0.8. While starting my Tomcat server I get the following error:

Dec 19, 2018 9:59:04 AM org.apache.webbeans.servlet.WebBeansConfigurationListener contextInitialized
SEVERE: An error occurred while starting application context path : [/abcServer]
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.webbeans.servlet.WebBeansConfigurationListener
org.apache.webbeans.exception.WebBeansDeploymentException: java.lang.IllegalArgumentException
    at org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery.scan(AbstractMetaDataDiscovery.java:144)
    at org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(AbstractLifeCycle.java:132)
    at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:104)
    at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:87)
    at org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:85)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5110)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1694)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1684)
    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: java.lang.IllegalArgumentException
    at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
    at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
    at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
    at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1169)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:147)
    at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:160)
    at org.apache.webbeans.corespi.scanner.xbean.OwbAnnotationFinder.<init>(OwbAnnotationFinder.java:37)
    at org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery.initFinder(AbstractMetaDataDiscovery.java:107)
    at org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery.scan(AbstractMetaDataDiscovery.java:140)
    ... 13 more

Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.xyz.abc.application.impl.ApplicationControllerAdapter
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.xyz.abc.cleanup.CleanupJobController] is not found with the qualifiers 
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name :  cleanupJobController, Bean Owner : [null]
    at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:65)
    at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:271)
    at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:82)
    at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
    at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
    at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
    at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
    at com.xyz.abc.inject.CDIUtils.injectFields(CDIUtils.java:37)
    at com.xyz.abc.application.impl.ApplicationStarted.<init>(ApplicationStarted.java:149)
    at com.xyz.abc.application.impl.ApplicationControllerAdapter.contextInitialized(ApplicationControllerAdapter.java:34)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5110)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1694)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1684)
    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)

Dec 19, 2018 9:59:04 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/abcServer] startup failed due to previous errors
Dec 19, 2018 9:59:04 AM com.sun.xml.ws.transport.http.servlet.WSServletDelegate destroy
INFO: WSSERVLET15: JAX-WS servlet destroyed
Dec 19, 2018 9:59:04 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextDestroyed
INFO: WSSERVLET13: JAX-WS context listener destroyed
Dec 19, 2018 9:59:04 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class com.xyz.abc.application.impl.ApplicationControllerAdapter
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [com.xyz.abc.licensing.License] is not found with the qualifiers 
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name :  license, Bean Owner : [null]
    at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:65)
    at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:271)
    at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:82)
    at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
    at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
    at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
    at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
    at com.xyz.abc.inject.CDIUtils.injectFields(CDIUtils.java:37)
    at com.xyz.abc.application.impl.ApplicationStopped.<init>(ApplicationStopped.java:85)
    at com.xyz.abc.application.impl.ApplicationControllerAdapter.contextDestroyed(ApplicationControllerAdapter.java:27)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5157)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5830)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:221)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:149)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1694)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1684)
    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)

Please suggest how to resolve this issue. I have updated the opewebbeans CDI for Tomcat to the latest one, updated JaxB-api as well but nothing seems to work. Is there anyone who is using Tomcat 9 with Java 11 ?

Aditya Batra
  • 263
  • 1
  • 2
  • 18

1 Answers1

1

TL;DR: You updated OWB from 1.6 to 2.0 but failed to update their dependencies.

OpenWebBeans 2.0.8 depends on xbean-asm7-shaded-4.12 which implementes the class org.apache.xbean.asm7.ClassReader. Somehow your OWB use an older class org.apache.xbean.asm5.ClassReader to discover CDI annotated bean classes. But developers in 2015 failed to predict how to read Java 11 classes in 2018 (scnr).

Testing a bit I found you must also have an old xbean-finder-shaded-4.3 in your classpath which depends on and uses that old org.apache.xbean.asm5.ClassReader from xbean-asm5-shaded.

As a conclusion I'd suggest you get rid of those dependency conflicts pointed out by your exception stack trace. Additionally you may want to use a build tool like maven. This helps a lot getting through the depdendency hell mostly without getting burned.

Edit:

Regarding your comment see these questions:

Depending on your environment you may also need to add replacements for modules that have been deprecated in Java 9 and removed in Java 11:

Edit 2:

You can @Inject DocumentBuilderFactory instances using a producer method annotated with @Produces as descripbed in my answer to your followup question.

Selaron
  • 6,105
  • 4
  • 31
  • 39
  • Thanks @selaron I believe it did some trick as the error has changed.Please find attached the full logs for new error : https://pastebin.com/8UDe9fxp E - An error occurred while starting application context path : [/abcServer] 16:43:19,110 E - Exception sending context initialized event to listener instance of class [org.apache.webbeans.servlet.WebBeansConfigurationListener] org.apache.webbeans.exception.WebBeansConfigurationException: Error while sending SystemEvent to a CDI Extension! org.apache.webbeans.portable.events.generics.GProcessInjectionTarget – Aditya Batra Dec 19 '18 at 11:20
  • @AdityaBatra you are hitting one dependency issue after another caused by your heavy environmental upgrade (jdk 11, OWB, ...). In case of missing classes it's a good starting point to use search terms like `java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.internal.inject.Providers` etc. Nevertheless I added some furhter hints to my answer. – Selaron Dec 19 '18 at 12:38
  • Thanks. I paid my attention to these NoClassDefFoundError first, however the main issue remains the same which is related to CDI in my applicatioon. Please find attached the error logs: https://pastebin.com/7jCwJzb2 PS: Your links helped me in resolving remaining NoClassDefFoundError errors. – Aditya Batra Dec 20 '18 at 09:50
  • You have a field named `logMessages` of type `com.xyz.abc.tools.log.LogMessages` in some class that fails to `@Inject`. In other classes you have fields named `documentBuilderFactory` of type `javax.xml.parsers.DocumentBuilderFactory` that fail to `@Inject` either. – Selaron Dec 20 '18 at 11:41
  • Right, that's what the log says. Do you have any idea about why this is creating the issue with java 11 as it was working fine on Java 8. My logMessages class looks like @ApplicationScoped public class LogMessages { //code } – Aditya Batra Dec 21 '18 at 06:13
  • I'd need a [mcve] or little reproducer project as I can't reproduce these exceptions with Tomcat 9, jdk 11 and OWB 2.0.8 – Selaron Dec 21 '18 at 09:46
  • Hi @Selaron , can you please refer to https://stackoverflow.com/questions/54019932/nodelist-getlength-returning-0-in-java-11 for better idea. It appears it is not an isse with the CDI API, but an access on CDI which has turned illegal in Java 11. DocumentBuilderFactory object can not longer be injected at runtime. – Aditya Batra Jan 07 '19 at 07:08
  • @AdityaBatra how do you know this is illegal now in new CDI or Java? Isn't it possible you have multiple implementation classes of the `abstract DocumentBuilderFactory` in your class path and CDI framework now does not know which one to inject? – Selaron Jan 07 '19 at 15:38
  • Yes it may be the case since the instance of DocumentBuilderFactoryImpl is available in both org.apache..jaxp and the com.sun.org.apache.xerces.internal.jaxp packages. But this was true with Java 8 also, where it worked fine. The difference in Java 11 is that newInstance() method returns instance of the latter type while Run time returned the former. Can we exclude the implementation in JDK, so it pick the old one ?. – Aditya Batra Jan 08 '19 at 05:03
  • @AdityaBatra Added a hint regarding `DocumentBuilderFactory` injection to my answer. – Selaron Jan 08 '19 at 09:08
  • Thanks for the help. My injection provider classes were missing ApplicationScoped annotation, which worked fine in Java 8 but caused issue in Java 11. – Aditya Batra Jan 08 '19 at 12:15
  • yes this was a related issue to https://stackoverflow.com/questions/54019932/nodelist-getlength-returning-0-in-java-11 and got resolved. Thank you. – Aditya Batra Jan 10 '19 at 10:26
  • Asking because you did not yet mark it answered ;-D – Selaron Jan 10 '19 at 11:19