Thank you, Chris, for the inputs. I did try copying the war and trying to deploy the two copies. I didn't see any issues and both these copies got deployed as expected.
I will try this on different setups and will keep you posted with my observations. Thanks, Amit ________________________________ From: Christopher Schultz <ch...@christopherschultz.net> Sent: Tuesday, January 14, 2025 11:48 AM To: users@tomcat.apache.org <users@tomcat.apache.org> Subject: Re: Puzzling NoClassDefFoundErrors on Tomcat 10.1.x CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. If you believe this is a phishing email, use the Report to Cybersecurity icon in Outlook. Amit, On 1/13/25 3:33 PM, Amit Pande wrote: > Hello, > > Recently I ran into a very strange issue while deploying the web applications. > > The trigger to this issue was adding one more web application (war) under the > given app base. To be precise, moving this application from one app base to > another. > > During startup: > > java.lang.NoClassDefFoundError: myapp/mypackage/myclass1 > at myapp.MyContextListener.contextInitialized(MyAppContextListener.java:27) > at > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4008) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4436) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:599) > at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:571) > at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:654) at > org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:969) at > org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911) at > > java.lang.NoClassDefFoundError: myapp/mypackage/myclass2 > at myapp.MyContextListener.contextInitialized(MyAppContextListener.java:47) > at > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4008) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4436) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:599) > at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:571) > at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:654) at > org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:969) at > org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911) at > > java.lang.NoClassDefFoundError: myapp/mypackage1/myclass3 > at myapp.MyContextListener.contextInitialized(MyAppContextListener.java:37) > at > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4008) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4436) > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:599) > at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:571) > at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:654) at > org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:969) at > org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911) at > > > These errors are coming from an app which was already part of the same app > base, which hasn't been changed at all. > > And this wasn't reproducible on all the systems consistently. One of my test > setups has 24 cores and around 270GB ran, and this is issue is fairly > consistent on such a configuration. Not sure what's special about it given > that it works on a setup with more than 24 CPU cores. > > Little bit of debugging around the "startStopThreads=" setting in server.xml. > Both the "Engine" and "Host" has "startStopThreads=0" which means by default > the number of utility threads will be equal to the number of processors. > For testing purposes, I changed this "startStopThreads=1" and all the > applications were deployed as expected. For now, I have used this workaround. > > So, it seems like related to parallel deployment of web applications. > > Any input on how to debug this very strange further? FWIW, I am using Java 21 > and Tomcat 10.1.34. Also, does it matter that the applications being deployed > might have same set of third-party libraries packaged the war files? So you could reproduce this like this? $ cp -R $CATALINA_BASE/webapps/myapp $CATALINA_BASE/webapps/myapp2 ... and myapp2 will auto-deploy and throw NoClassDefFoundError(s)? Are there any other errors in any logs before you see the NoClassDefFoundError? If you stop Tomcat and start it again, do both copies of the application deploy successfully? -chris --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org