[ https://issues.apache.org/jira/browse/TOMEE-2458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16750833#comment-16750833 ] Donald Kwakkel commented on TOMEE-2458: --------------------------------------- I found a similair issue about tccl not used here: TOMEE-877. [~romain.manni-bucau] is this the same issue? > Loading Beans causes ClassNotFoundException when using custom context classloader > --------------------------------------------------------------------------------- > > Key: TOMEE-2458 > URL: https://issues.apache.org/jira/browse/TOMEE-2458 > Project: TomEE > Issue Type: Bug > Components: TomEE Core Server > Affects Versions: 8.0.0-M1 > Reporter: Gerwin > Priority: Major > Attachments: myclassloader.jar, myclassloader.jar.withtccl, myexception.jar, myexception.jar.withbean, repro.war > > > h4. Steps to reproduce > # Create a custom Exception and put it in {{CATALINA_HOME/myexception.jar}} > {code:java} > public class MyException extends Exception { > } > {code} > # Create a custom ClassLoader and put it in {{CATALINA_HOME/myclassloader.jar}} > {code:java} > public class MyClassLoader extends WebappClassLoader { > public MyClassLoader(ClassLoader parent)throws MalformedURLException { > super(parent); > addURL(Paths.get(System.getProperty("catalina.home"), "myexception.jar").toUri().toURL()); > } > } > {code} > # Put the classloader on the classpath > {code:none|title=CATALINA_HOME/conf/catalina.properties} > common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar","${catalina.home}/myclassloader.jar" > {code} > # Use the classloader in the context > {code:xml|title=CATALINA_HOME/webapps/repro/META-INF/context.xml} > > > > {code} > # Create a bean with the {{MyException}} in the method signature > {code:java|title=CATALINA_HOME/webapps/repro/WEB-INF/classes/MyBean.class} > @Stateless(name = "MyBeanEJB") > public class MyBean { > public String hello() throws MyException { > return "hello"; > } > } > {code} > # Use the bean > {code:java|title=CATALINA_HOME/webapps/repro/index.jsp} > <%@ page import="MyBean" %> > <%@ page contentType="text/html;charset=UTF-8" language="java" %> > > > <% > MyBean myBean = new MyBean(); > out.println(myBean.hello()); > %> > > > {code} > h4. Actual result > {code:none|title=CATALINA_HOME/logs/catalina.0.log} > jan 23, 2019 4:37:17 PM sun.reflect.DelegatingMethodAccessorImpl invoke > INFO: Starting Servlet Engine: Apache Tomcat (TomEE)/9.0.12 (8.0.0-SNAPSHOT) > jan 23, 2019 4:37:17 PM sun.reflect.DelegatingMethodAccessorImpl invoke > INFO: Deploying web application archive [C:\Program Files\TomEE\webapps\repro.war] > jan 23, 2019 4:37:17 PM org.apache.tomee.catalina.TomcatWebAppBuilder init > INFO: ------------------------- localhost -> /repro > jan 23, 2019 4:37:17 PM org.apache.openejb.config.ConfigurationFactory configureApplication > INFO: Configuring enterprise application: C:\Program Files\TomEE\webapps\repro > jan 23, 2019 4:37:17 PM sun.reflect.NativeMethodAccessorImpl invoke > SEVERE: ContainerBase.addChild: start: > org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/repro]] > at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) > at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743) > at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719) > at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703) > at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) > at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1858) > 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:772) > at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:426) > at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1585) > at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308) > at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) > at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424) > at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367) > at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:969) > at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) > at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) > 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:944) > at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.startup.Catalina.start(Catalina.java:682) > 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492) > Caused by: java.lang.NoClassDefFoundError: test/MyException > at java.lang.Class.getDeclaredMethods0(Native Method) > at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) > at java.lang.Class.privateGetPublicMethods(Class.java:2902) > at java.lang.Class.getMethods(Class.java:1615) > at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.processApplicationExceptions(AnnotationDeployer.java:3058) > at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:2566) > at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:1991) > at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:384) > at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420) > at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1037) > at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1286) > at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1130) > at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:134) > at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) > at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5007) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > ... 38 more > Caused by: java.lang.ClassNotFoundException: test.MyException > at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:186) > at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83) > ... 54 more > jan 23, 2019 4:37:17 PM sun.reflect.NativeMethodAccessorImpl invoke > SEVERE: Error deploying web application archive [C:\Program Files\TomEE\webapps\repro.war] > java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/repro]] > at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:747) > at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719) > at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703) > at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986) > at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1858) > 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:772) > at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:426) > at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1585) > at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308) > at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) > at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424) > at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367) > at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:969) > at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) > at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) > 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:944) > at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) > at org.apache.catalina.startup.Catalina.start(Catalina.java:682) > 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492) > jan 23, 2019 4:37:17 PM sun.reflect.DelegatingMethodAccessorImpl invoke > INFO: Deployment of web application archive [C:\Program Files\TomEE\webapps\repro.war] has finished in [469] ms > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)