Issue
I am facing issue in deploying my web app on tomcat after I have implemented Maven for dependency management. Before Maven implementation, it was a plain web app where every thing was used to be managed manually. I started upgrading app with frameworks for learning and decided to implement Maven for dependency management as first step. While I implemented Maven and everything works fine from eclipse, it does not work when I deploy war file on a standalone tomcat.
I am defining path to my app in Catalina properties against shared.loader property and a context xml under Catalina folder within tomcat conf directory (see the directory structure below)
C:/Application/SNSS/SNSS_PROD/
|
|-->OpsMan
| |
| |-->WebApp
| | |->css
| | |->images
| | |->log (log4j2.xml)
| | |->jsp
| | |->resources
| | |->WEB-INF
| | |->
| |
| |-->WebApp_20220102
| | |->css
| | |->images
| | |->log (log4j2.xml)
| | |->jsp
| | |->resources
| | |->WEB-INF
|
|-->Tomcat9
| |->conf
| | |->Catalina
| | | |->localhost (blank folder)
| | | |->www.snss.com
| | | | |
| | | | |->OpsMan.xml
| | | |
| | |->catalina.properties
| | |->server.xml
| | |
| | |->Other conf files
| | |->resources
| | |->WEB-INF
| |
| |->(other folder like bin, lib etc)
Following are the relevant entries from Tomcat configuration
catalina.properties
shared.loader="C:\\Applications\\SNSS\\SNSS_PROD\\OpsMan\\WebApp"
server.xml (apart from default host tag, I have added one more for my app)
<Host name="www.snss.com" appBase="C:\\Applications\\SNSS\\SNSS_PROD\\OpsMan\\WebApp"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<alias>snss.com</alias>
</Host>
OpsMan.xml
<Context displayName="www.snss.com" docBase="C:\\Applications\\SNSS\\SNSS_PROD\\OpsMan\\WebApp" />
In "C:\Windows\system32\drivers\etc\hosts" file following entry has been created and port proxy set to redirect HTTP requests on port 80 to 8080.
127.0.0.1 www.snss.com
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" strict="false" name="ROM" packages="">
<Properties>
<Property name="root.dir">C:\\Applications\\SNSS\\SNSS_PROD\\OpsMan\\WebApp</Property>
<Property name="log.dir">${root.dir}/log</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile" fileName="${log.dir}/rom.log"
filePattern="${log.dir}/$${date:yyyy-MM}/rom-%d{yyyy-MM-dd-HH}-%i.log">
<PatternLayout>
<Pattern>[%t] - %d{yyyy-MMM-dd - HH:mm:ss,SSS} %-5p %C{1} %L - %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="6" modulate="true"/>
<SizeBasedTriggeringPolicy size="10 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>in.co.snss</groupId>
<artifactId>OpsMan</artifactId>
<version>22.01.1</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>9.0.27</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.15.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
jars in "WebApp\WEB-INF\lib" folder
jars in "WebApp_20220102\WEB-INF\lib" folder
web.xml in the "WebApp\WEB-INF" folder
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>OpsMan</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>HomeServlet</servlet-name>
<servlet-class>in.co.snss.opsman.web.servlet.HomeServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>in.co.snss.user.servlet.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HomeServlet</servlet-name>
<url-pattern>/Orders/*</url-pattern>
<url-pattern>/Notes/*</url-pattern>
<url-pattern>/Accounts/*</url-pattern>
<url-pattern>/Party/*</url-pattern>
<url-pattern>/Products/*</url-pattern>
<url-pattern>/Reports/*</url-pattern>
<url-pattern>/Users/*</url-pattern>
<url-pattern>/Inventory/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/index/*</url-pattern>
<url-pattern>/OpsMan/*</url-pattern>
<url-pattern>/login</url-pattern>
<url-pattern>/logout</url-pattern>
<url-pattern>/RegisterLicense</url-pattern>
</servlet-mapping>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>/log/log4j2.xml</param-value>
</context-param>
</web-app>
Now when I start tomcat I get error in deployment of OpsMan. Following is the console output
03-Jan-2022 16:19:03.299 WARNING [main] org.apache.tomcat.util.digester.Digester.endElement No rules found matching [Server/Service/Engine/Host/alias]
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.27
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Oct 7 2019 09:57:22 UTC
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.27.0
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jre1.8.0_311
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_311-b11
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Applications\SNSS\SNSS_PROD\Tomcat9
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Applications\SNSS\SNSS_PROD\Tomcat9
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=.\Tomcat9\conf\logging.properties
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=.\Tomcat9
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=.\Tomcat9
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=.\Tomcat9\temp
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0].
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
03-Jan-2022 16:19:03.299 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
03-Jan-2022 16:19:03.315 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1c 28 May 2019]
03-Jan-2022 16:19:03.549 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
03-Jan-2022 16:19:03.643 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
03-Jan-2022 16:19:03.643 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [520] milliseconds
03-Jan-2022 16:19:03.674 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
03-Jan-2022 16:19:03.674 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.27]
03-Jan-2022 16:19:03.690 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\docs]
03-Jan-2022 16:19:03.986 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\docs] has finished in [296] ms
03-Jan-2022 16:19:03.986 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\examples]
03-Jan-2022 16:19:04.377 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\examples] has finished in [391] ms
03-Jan-2022 16:19:04.377 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\host-manager]
03-Jan-2022 16:19:04.408 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\host-manager] has finished in [31] ms
03-Jan-2022 16:19:04.408 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\manager]
03-Jan-2022 16:19:04.439 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\manager] has finished in [31] ms
03-Jan-2022 16:19:04.439 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\ROOT]
03-Jan-2022 16:19:04.549 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\Tomcat9\webapps\ROOT] has finished in [110] ms
03-Jan-2022 16:19:04.564 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [C:\Applications\SNSS\SNSS_PROD\Tomcat9\conf\Catalina\www.snss.com\OpsMan.xml]
03-Jan-2022 16:19:07.222 SEVERE [main] org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying deployment descriptor [C:\Applications\SNSS\SNSS_PROD\Tomcat9\conf\Catalina\www.snss.com\OpsMan.xml]
java.lang.IllegalStateException: Error starting child
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:720)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:631)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1831)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:526)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:425)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[www.snss.com].StandardContext[/OpsMan]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
... 37 more
Caused by: java.lang.NoClassDefFoundError: LLogger;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:110)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:269)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:137)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:69)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:330)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:777)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5051)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 38 more
Caused by: java.lang.ClassNotFoundException: Logger
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
... 51 more
03-Jan-2022 16:19:07.238 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [C:\Applications\SNSS\SNSS_PROD\Tomcat9\conf\Catalina\www.snss.com\OpsMan.xml] has finished in [2,689] ms
03-Jan-2022 16:19:07.238 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\css]
03-Jan-2022 16:19:07.378 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\css] has finished in [140] ms
03-Jan-2022 16:19:07.378 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\images]
03-Jan-2022 16:19:07.503 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\images] has finished in [125] ms
03-Jan-2022 16:19:07.503 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\js]
03-Jan-2022 16:19:07.628 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\js] has finished in [125] ms
03-Jan-2022 16:19:07.628 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\jsp]
03-Jan-2022 16:19:07.738 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\jsp] has finished in [110] ms
03-Jan-2022 16:19:07.738 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\log]
03-Jan-2022 16:19:07.863 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\log] has finished in [125] ms
03-Jan-2022 16:19:07.863 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\Output]
03-Jan-2022 16:19:08.034 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\Output] has finished in [171] ms
03-Jan-2022 16:19:08.050 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\resources]
03-Jan-2022 16:19:08.159 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\resources] has finished in [109] ms
03-Jan-2022 16:19:08.159 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\script]
03-Jan-2022 16:19:08.284 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Applications\SNSS\SNSS_PROD\OpsMan\WebApp\script] has finished in [125] ms
03-Jan-2022 16:19:08.284 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
03-Jan-2022 16:19:08.284 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
03-Jan-2022 16:19:08.284 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [4,642] milliseconds
With the same setup if I rename "WebApp" to "WebApp_New" and "WebApp_20220102" to "WebApp" (basically the old app) then everything works fine without any problem.
I have compared all configuration files within "WebApp" folder, e.g. log4j2.xml, web.xml etc. but not able to figure out the problematic entry. I have also tried replacing jars from old app (WebApp_20220102\WEB-INF\lib) to the new app's lib folder but nothing changed. I continue to get the issue in deploying new app, but if I rename WebApp folders and launch old app, it works just fine.
Solution
Since I was able to run the app when deployed on tomcat within Eclipse, I started looking at differences in configuration of standalone tomcat and that within eclipse. I did not find any differences or I matched the config of both servers.
After this I decided to look at each and every file within Web App folder and I found difference in size of .class files. I realized that when eclipse is deploying it on the internal tomcat, it is compiling the output to the target folder but when this is done using maven, class files are generated in /target/classes folder. This folder is copied to the /WEB-INF/classes folder at the time of packaging.
In my case, I do not know how, I had classes folder within the project's WebContent/WEB-INF/classes directory. This directory had very old version of classes, with very small size (3KB Vs 10KB). I removed the classes directory from the WebContent/WEB-INF folder and maven started copying target/classes folder to WEB-INF/classes. This resolved the issue.
Answered By - RM_SNSS
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)