vick_4444
vick_4444

Reputation: 353

EJB application fails to start on TomcatEE due to classloader issue

I am on the path to migrate my application from Weblogic to TomcatEE (Tomcat with EJB). I have removed weblogic specific config files from the war and when I try to deploy this on to apache-tomee-plus-8.0.16 (with Java 8), I get below error. I understanding reading other posts that it is due to classloader loading another class with the same name prior to this error. But how do I pinpoint where that is? how do I go about debugging this for a resolution?

19-Nov-2024 18:38:38.888 INFO [main] org.apache.openejb.cdi.OpenEJBLifecycle.startApplication OpenWebBeans Container is starting...
19-Nov-2024 18:38:38.904 INFO [main] org.apache.webbeans.plugins.PluginLoader.startUp Adding OpenWebBeansPlugin : [CdiPlugin]
19-Nov-2024 18:22:20.812 SEVERE [main] sun.reflect.NativeMethodAccessorImpl.invoke Error deploying web application archive [C:\2024\Architecture_stuff\pickle\apache-tomee-plus-8.0.16\webapps\portal.war]
        java.lang.IllegalStateException: Error starting child
                at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:686)
                at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:658)
                at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:661)
                at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1023)
                at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1910)
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
                at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
                at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
                at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:824)
                at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
                at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1617)
                at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:318)
                at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:114)
                at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
                at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:345)
                at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:893)
                at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:794)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
                at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
                at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
                at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
                at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
                at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
                at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:248)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
                at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
                at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
                at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
                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:498)
                at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347)
                at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
        Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/portal]]
                at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:419)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:186)
                at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:683)
                ... 37 more
        Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of java/net/URLClassLoader) 
        previously initiated loading for a different type with name "org/eclipse/microprofile/openapi/models/OpenAPI"
                at java.lang.ClassLoader.defineClass1(Native Method)
                at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
                at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
                at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
                at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
                at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
                at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
                at java.lang.Class.forName0(Native Method)
                at java.lang.Class.forName(Class.java:348)
                at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
                at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
                at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
                at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
                at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
                at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
                at sun.reflect.generics.repository.FieldRepository.getGenericType(FieldRepository.java:85)
                at java.lang.reflect.Field.getGenericType(Field.java:247)
                at org.apache.webbeans.util.GenericsUtil.resolveType(GenericsUtil.java:608)
                at org.apache.webbeans.portable.AnnotatedFieldImpl.<init>(AnnotatedFieldImpl.java:47)
                at org.apache.webbeans.portable.AnnotatedTypeImpl$State.<init>(AnnotatedTypeImpl.java:294)
                at org.apache.webbeans.portable.AnnotatedTypeImpl$State.<init>(AnnotatedTypeImpl.java:236)
                at org.apache.webbeans.portable.AnnotatedTypeImpl.getState(AnnotatedTypeImpl.java:227)
                at org.apache.webbeans.portable.AnnotatedTypeImpl.getFields(AnnotatedTypeImpl.java:162)
                at org.apache.webbeans.portable.AnnotatedTypeImpl$State.<init>(AnnotatedTypeImpl.java:312)
                at org.apache.webbeans.portable.AnnotatedTypeImpl$State.<init>(AnnotatedTypeImpl.java:236)
                at org.apache.webbeans.portable.AnnotatedTypeImpl.getState(AnnotatedTypeImpl.java:227)
                at org.apache.webbeans.portable.AnnotatedTypeImpl.getConstructors(AnnotatedTypeImpl.java:153)
                at org.apache.webbeans.inject.impl.InjectionPointFactory.buildInjectionPoints(InjectionPointFactory.java:70)
                at org.apache.webbeans.portable.ExtensionProducer.<init>(ExtensionProducer.java:39)
                at org.apache.webbeans.component.ExtensionProducerFactory.createProducer(ExtensionProducerFactory.java:49)
                at org.apache.webbeans.component.BuiltInOwbBean.<init>(BuiltInOwbBean.java:48)
                at org.apache.webbeans.component.ExtensionBean.<init>(ExtensionBean.java:43)
                at org.apache.webbeans.component.creation.ExtensionBeanBuilder.buildBean(ExtensionBeanBuilder.java:55)
                at org.apache.webbeans.portable.events.ExtensionLoader.createExtensionBean(ExtensionLoader.java:238)
                at org.apache.webbeans.portable.events.ExtensionLoader.addExtensions(ExtensionLoader.java:201)
                at org.apache.webbeans.portable.events.ExtensionLoader.loadExtensionServices(ExtensionLoader.java:101)
                at org.apache.webbeans.portable.events.ExtensionLoader.loadExtensionServices(ExtensionLoader.java:89)
                at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:218)
                at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196)
                at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:269)
                at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:62)
                at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1465)
                at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1162)
                at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134)
                at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:114)
                at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4820)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
                ... 38 more

The error in question is for a class 'org.eclipse.microprofile.openapi.models.OpenAPI' which come with the tomcat binary (tomcat/lib) folder. My application war does not have this jar as a dependency. Much appreciated if anyone can point me in the right direction.

Upvotes: 0

Views: 22

Answers (0)

Related Questions