0
votes

As per this question I have created a class that implements the Catalina LifecycleListener class.

How to run script on Tomcat startup?

When I place my JAR file in webapps/ROOT/WEB-INF/lib, Tomcat fails to startup with a class not found exception:

java.lang.ClassNotFoundException: net.company.tomcat.StartupEventHookListener

But when I place the file in appserver/lib it starts up and then runs the code as expected, when the app has finished starting.

My understanding is that all JAR files in the WEB-INF/lib are available to my webapp (ROOT), and I am trying to hook into the event lifecycle for my webapp.

Am I actually hooking into Tomcat's lifecycle, hence I need to use the appserver/lib library?

Did I just answer my own question?

1
Yes you did answer your own question.bmargulies

1 Answers

1
votes

Tomcat startup happens before any webapps are launched, even the ROOT webapp. And the classpath used for things configured in the Tomcat lifecycle never includes any jar files or .class files from any webapp, even the ROOT webapp.