Webapp deployment fails after maven implemtation - java

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)
directoryStructure
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
lib folder with Maven
jars in "WebApp_20220102\WEB-INF\lib" folder
lib folder without Maven
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.

You're missing the log4j implementation JARs. "lib folder with Maven" lists the log4j-api JARs, but not the log4j-core implementation. Add
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
to the pom.xml

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.

Related

IntelliJ MVC Server Context initialization failed

Following a udemy course, I have encountered this issue, to which the answer I didn't find anywhere.
I've had issues with the model class, but that seems to be working now.
URL pattern is fixed, by just being a /
for webmvc i have updated the dependency to be 4.3.6.RELEASE
Code itself and the server was running just before adding changes to the controller, enabling it to pass message value to the model.
Any help would be greatly appreciated.
HelloWebServlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.luv2code.springdemo.mvc"/>
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp" />
</bean>
</beans>
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemeLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Spring MVC Application</display-name>
<!-- Step 1: Configure Spring MVC Dispatcher Servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/HelloWeb-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet -->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.luv2code.springweb</groupId>
<artifactId>spring-web-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>spring-web-demo Maven Webapp</name>
<url>http://localhost:8080/spring-web-demo</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.23</version>
</dependency>
</dependencies>
<build>
<finalName>spring-web-demo</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
HelloWorldController
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class HelloWorldController {
#RequestMapping("/showForm")
public String showForm() {
return "helloworld-form";
}
#RequestMapping("/processForm")
public String processForm() {
return "helloworld";
}
#RequestMapping("/processFormVersionTwo")
public String letsShoutDude(HttpServletRequest request, Model model) {
String theName = request.getParameter("studentName");
theName = theName.toUpperCase();
String result = "Yo! " + theName;
model.addAttribute("message", result);
return "helloworld";
}
}
The error log
C:\Users\Slimas\.jdks\openjdk-17\bin\java.exe -Dcatalina.home=C:\Users\Slimas\Desktop\apache-tomcat-9.0.67 -Dcatalina.base=C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo -Djava.io.tmpdir=C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo\temp -Djava.util.logging.config.file=C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo\conf\logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar=59958:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Slimas\Desktop\apache-tomcat-9.0.67\bin\bootstrap.jar;C:\Users\Slimas\Desktop\apache-tomcat-9.0.67\bin\tomcat-juli.jar org.apache.catalina.startup.Bootstrap start
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
05-Oct-2022 14:55:37.818 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.67
05-Oct-2022 14:55:37.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Sep 23 2022 11:22:29 UTC
05-Oct-2022 14:55:37.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.67.0
05-Oct-2022 14:55:37.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
05-Oct-2022 14:55:37.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
05-Oct-2022 14:55:37.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
05-Oct-2022 14:55:37.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Users\Slimas\.jdks\openjdk-17
05-Oct-2022 14:55:37.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 17+35-2724
05-Oct-2022 14:55:37.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
05-Oct-2022 14:55:37.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo
05-Oct-2022 14:55:37.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Users\Slimas\Desktop\apache-tomcat-9.0.67
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Users\Slimas\Desktop\apache-tomcat-9.0.67
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo\temp
05-Oct-2022 14:55:37.826 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo\conf\logging.properties
05-Oct-2022 14:55:37.827 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
05-Oct-2022 14:55:37.827 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar=59958:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\bin
05-Oct-2022 14:55:37.827 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dfile.encoding=UTF-8
05-Oct-2022 14:55:37.828 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.35] using APR version [1.7.0].
05-Oct-2022 14:55:37.829 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
05-Oct-2022 14:55:37.829 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
05-Oct-2022 14:55:37.831 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1q 5 Jul 2022]
05-Oct-2022 14:55:37.985 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
05-Oct-2022 14:55:37.998 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [298] milliseconds
05-Oct-2022 14:55:38.023 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
05-Oct-2022 14:55:38.024 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.67]
05-Oct-2022 14:55:38.030 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo\conf\Catalina\localhost\spring-web-demo.xml]
05-Oct-2022 14:55:38.939 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
05-Oct-2022 14:55:39.152 INFO [main] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'dispatcher': initialization started
05-Oct-2022 14:55:39.173 SEVERE [main] org.springframework.web.servlet.DispatcherServlet.initServletBean Context initialization failed
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.context.support.XmlWebApplicationContext]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/metrics/ApplicationStartup
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:102)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:628)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1117)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4958)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5265)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:690)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1889)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:583)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:473)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
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:946)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
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:772)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/metrics/ApplicationStartup
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:229)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:81)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:51)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.<init>(AbstractRefreshableWebApplicationContext.java:95)
at org.springframework.web.context.support.XmlWebApplicationContext.<init>(XmlWebApplicationContext.java:62)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 51 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.metrics.ApplicationStartup
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1412)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1220)
... 62 more
05-Oct-2022 14:55:39.188 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [C:\Users\Slimas\.SmartTomcat\spring-web-demo\spring-web-demo\conf\Catalina\localhost\spring-web-demo.xml] has finished in [1,157] ms
05-Oct-2022 14:55:39.190 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
05-Oct-2022 14:55:39.220 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [1222] milliseconds
http://localhost:8080/spring-web-demo/
And lastly, the project structure:Image of project structure
As per advise
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.6.RELEASE</version>
Was changed to:
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.23</version>
Now it works.
Cheers!

Regarding problem in building Session factory

`
Using CATALINA_BASE: "C:\apache-tomcat-10.0.22"
Using CATALINA_HOME: "C:\apache-tomcat-10.0.22"
Using CATALINA_TMPDIR: "C:\apache-tomcat-10.0.22\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk-11.0.13"
Using CLASSPATH: "C:\apache-tomcat-10.0.22\bin\bootstrap.jar;C:\apache-tomcat-10.0.22\bin\tomcat-juli.jar"
Using CATALINA_OPTS: ""
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
01-Jul-2022 16:46:59.074 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/10.0.22
01-Jul-2022 16:46:59.079 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 2 2022 16:53:56 UTC
01-Jul-2022 16:46:59.079 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.0.22.0
01-Jul-2022 16:46:59.079 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
01-Jul-2022 16:46:59.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
01-Jul-2022 16:46:59.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
01-Jul-2022 16:46:59.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk-11.0.13
01-Jul-2022 16:46:59.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.13+10-LTS-370
01-Jul-2022 16:46:59.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
01-Jul-2022 16:46:59.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\apache-tomcat-10.0.22
01-Jul-2022 16:46:59.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\apache-tomcat-10.0.22
01-Jul-2022 16:46:59.106 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
01-Jul-2022 16:46:59.106 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
01-Jul-2022 16:46:59.106 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
01-Jul-2022 16:46:59.106 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
01-Jul-2022 16:46:59.106 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\apache-tomcat-10.0.22\conf\logging.properties
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dhttp.nonProxyHosts=localhost|127.0.0.1|DESKTOP-BBI82LE
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\apache-tomcat-10.0.22
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\apache-tomcat-10.0.22
01-Jul-2022 16:46:59.107 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\apache-tomcat-10.0.22\temp
01-Jul-2022 16:46:59.333 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0].
01-Jul-2022 16:46:59.333 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
01-Jul-2022 16:46:59.343 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022]
01-Jul-2022 16:46:59.891 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
01-Jul-2022 16:46:59.935 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1225] milliseconds
01-Jul-2022 16:47:00.045 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
01-Jul-2022 16:47:00.045 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.0.22]
01-Jul-2022 16:47:00.061 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [C:\apache-tomcat-10.0.22\conf\Catalina\localhost\mycart.xml]
01-Jul-2022 16:47:00.087 WARNING [main] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/mycart] in deployment descriptor [C:\apache-tomcat-10.0.22\conf\Catalina\localhost\mycart.xml] has been ignored
01-Jul-2022 16:47:02.383 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
01-Jul-2022 16:47:02.731 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [295] milliseconds.
01-Jul-2022 16:47:02.777 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [C:\apache-tomcat-10.0.22\conf\Catalina\localhost\mycart.xml] has finished in [2,716] ms
01-Jul-2022 16:47:02.779 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-10.0.22\webapps\docs]
01-Jul-2022 16:47:02.833 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-10.0.22\webapps\docs] has finished in [53] ms
01-Jul-2022 16:47:02.834 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-10.0.22\webapps\examples]
01-Jul-2022 16:47:03.557 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-10.0.22\webapps\examples] has finished in [723] ms
01-Jul-2022 16:47:03.559 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-10.0.22\webapps\host-manager]
01-Jul-2022 16:47:03.635 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-10.0.22\webapps\host-manager] has finished in [75] ms
01-Jul-2022 16:47:03.635 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-10.0.22\webapps\manager]
01-Jul-2022 16:47:03.715 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-10.0.22\webapps\manager] has finished in [80] ms
01-Jul-2022 16:47:03.716 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-10.0.22\webapps\ROOT]
01-Jul-2022 16:47:03.792 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-10.0.22\webapps\ROOT] has finished in [75] ms
01-Jul-2022 16:47:03.800 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
01-Jul-2022 16:47:04.176 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [4240] milliseconds
01-Jul-2022 16:49:37.103 INFO [http-nio-8080-exec-1] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/mycart]
01-Jul-2022 16:49:37.168 INFO [http-nio-8080-exec-7] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [C:\apache-tomcat-10.0.22\conf\Catalina\localhost\mycart.xml]
01-Jul-2022 16:49:37.170 WARNING [http-nio-8080-exec-7] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/mycart] in deployment descriptor [C:\apache-tomcat-10.0.22\conf\Catalina\localhost\mycart.xml] has been ignored
01-Jul-2022 16:49:38.991 INFO [http-nio-8080-exec-7] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
01-Jul-2022 16:49:38.997 INFO [http-nio-8080-exec-7] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [C:\apache-tomcat-10.0.22\conf\Catalina\localhost\mycart.xml] has finished in [1,829] ms
01-Jul-2022 16:49:39.004 INFO [http-nio-8080-exec-5] org.apache.catalina.util.LifecycleBase.start The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mycart]] after start() had already been called. The second call will be ignored.
01-Jul-2022 16:49:42.716 INFO [http-nio-8080-exec-2] org.hibernate.Version.logVersion HHH000412: Hibernate ORM core version 5.4.20.Final
org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 17 and column 27 in RESOURCE hibernate.cfg.xml. Message: cvc-complex-type.2.3: Element 'session-factory' cannot have character [children], because the type's content type is element-only.
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:134)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:66)
at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:234)
at org.hibernate.cfg.Configuration.configure(Configuration.java:258)
at com.learn.mycart.helper.FactoryProvider.getFactory(FactoryProvider.java:22)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:133)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:356)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:867)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1760)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 27; cvc-complex-type.2.3: Element 'session-factory' cannot have character [children], because the type's content type is element-only.]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:483)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:463)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:435)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:127)
... 34 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 27; cvc-complex-type.2.3: Element 'session-factory' cannot have character [children], because the type's content type is element-only.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:135)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:511)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3587)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(XMLSchemaValidator.java:3472)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3432)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3334)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2372)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:943)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.endElement(ValidatorHandlerImpl.java:584)
at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.endElement(ValidatingUnmarshaller.java:106)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.endElement(InterningXmlVisitor.java:81)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.handleEndElement(StAXEventConnector.java:234)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:135)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:460)
... 36 more
enter image description here
//hibernate_cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory> //this tag is used to configure and initialize the session factory settings for hibernate such as Dialect class and connection Driver class properties
<property name = "connection.driver_class">com.mysql.cj.jdbc.Driver"</property>
<property name = "connection.url">jdbc:mysql://localhost:3306/mycart</property>
<property name = "connection.username">root</property>
<property name = "connection.password">root</property>
<property name = "dialect">org.hibernate.dialect.MySQL57Dialect</property>
<property name = "hbm2ddl.auto">update </property>
<property name = "show_sql"> true</property>/>
</session-factory>
</hibernate-configuration>
//index.jsp
<%--
Document : index
Created on : 27-Jun-2022, 9:43:58 AM
Author : Pankaj Yadav
--%>
<%#page import="com.learn.mycart.helper.FactoryProvider"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<<h1> Creating session factory object</h1>
<%
out.println( FactoryProvider.getFactory());
%>
</body>
</html>
//FactoryProvider.java
package com.learn.mycart.helper;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
*
* #author Pankaj Yadav
*/
public class FactoryProvider
{
private static SessionFactory factory;
public static SessionFactory getFactory()
{
try
{
if(factory == null)
{
factory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
}
}catch(Exception e)
{
e.printStackTrace();
}
return factory;
}
}
<%--
Document : index
Created on : 27-Jun-2022, 9:43:58 AM
Author : Pankaj Yadav
--%>
<%#page import="com.learn.mycart.helper.FactoryProvider"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<<h1> Creating session factory object</h1>
<%
out.println( FactoryProvider.getFactory());
%>
</body>
</html>
//pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.mycompany</groupId>
<artifactId>mycart</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>mycart</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.20.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
`I am makinga an project and in building session factory object I am getting an error called "Caused by: javax.xml.bind.UnmarshalException
with linked exception:"
After running the code we should get the reference hash code for the session factory, and object of session factory implementation class,but I am getting null only. I am attaching the screenshot of the output that I am getting and the correct output. Also, I am sharing the "pom.xml" code, "hibernate.cfg.xml" code and "Factory Provider. java" code and "Indesx.jsp code" module of my project. Please check and do let me know where is the error? Please help
enter image description here
Caused by: javax.xml.bind.UnmarshalException
with linked exception:
enter image description here

Logging with Log4j2 in Java Servlets running on Tomcat

I have done some web programming in other languages but I am new to Tomcat, Servlet, Log4j, and Maven.
I completed my first ever Servlet by following this tutorial:
The next thing I tried was to add some logs. With the change I made, the API still works, but I was not able to find the log files I tried to generate. I tried to debug this for hours but all I can find on the Internet is that log4j "just works" in Servlet 3.0 or newer.
System
Ubuntu 20.04
Tomcat 9 (Followed this install instruction)
Java 11
Maven 3.6.3
Directory structure
servlet-tutorial
├── pom.xml
└── src
└── main
├── java
│   └── com
│   └── example
│   ├── ApiServlet.java
│   └── SomeServlet.java
└── webapp
├── index.jsp
└── WEB-INF
├── classes
│   └── log4j2.xml
└── web.xml
Maven dependencies in pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.example</groupId>
<artifactId>servlet-tutorial</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>servlet-tutorial</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>servlet-tutorial</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Using Log4j
package com.example;
...
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
#WebServlet("/api")
public class ApiServlet extends HttpServlet {
private static final Logger logger = LogManager.getLogger(ApiServlet.class);
#Override
public void init() throws ServletException {
logger.warn("ApiServlet.init");
super.init();
}
#Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// None of these gets printed
logger.warn("ApiServlet.doGet");
logger.debug("ApiServlet.doGet");
logger.info("ApiServlet.doGet");
System.out.println("ApiServlet.doGet");
...
}
...
log4j2.xml
<?xml version="1.0" encoding="utf-8"?>
<Configuration status="info">
<Properties>
<Property name="logdir">/home/myuser/myfolder/</Property>
<Property name="layout">%d [%t] %-5p %c- %m%n</Property>
</Properties>
<Appenders>
<RollingFile name="LOCALHOST"
fileName="${logdir}/localhost.log"
filePattern="${logdir}/localhost.%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="${layout}"/>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="1 MB" />
</Policies>
<DefaultRolloverStrategy max="10" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="com.example" level="info" additivity="false">
<AppenderRef ref="LOCALHOST" />
</Logger>
<Root level="error"></Root>
</Loggers>
</Configuration>
I tried to follow another tutorial for this log4j2.xml file.
web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>My App</display-name>
</web-app>
Build and deploy
I first create a .war file running
$ mvn package
Then I copy the war file to /var/lib/tomcat9/webapps/, and run
sudo service tomcat9 start
I think by the running this command Tomcat unpacks the .war file and create a directory under /var/lib/tomcat9/webapps/. The unpacked directory looks like this:
servlet-tutorial
├── index.jsp
├── META-INF
│ ├── context.xml
│ ├── MANIFEST.MF
│ ├── maven
│ │ └── com.example
│ │ └── servlet-tutorial
│ │ ├── pom.properties
│ │ └── pom.xml
│ └── war-tracker
└── WEB-INF
├── classes
│ ├── com
│ │ └── example
│ │ ├── ApiServlet.class
│ │ └── SomeServlet.class
│ └── log4j2.xml
├── lib
│ ├── log4j-api-2.14.1.jar
│ ├── log4j-core-2.14.1.jar
│ └── log4j-web-2.14.1.jar
└── web.xml
Issue
I made an http request to make sure the Tomcat is up and the Servlet is loaded with the latest change I made, but I do not see any files in the log directory I specified in log4j2.xml.
Instead, I found some log files that I think that were generated by Tomcat in /var/lib/tomcat9/logs/catalina.2021-11-02.log but I still don't see any logs I tried to print nor any error messages here:
02-Nov-2021 11:41:22.806 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.31 (Ubuntu)
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Oct 20 2020 12:27:39 UTC
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.31.0
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 5.11.0-38-generic
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-11-openjdk-amd64
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.11+9-Ubuntu-0ubuntu2.20.04
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Ubuntu
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /var/lib/tomcat9
02-Nov-2021 11:41:22.807 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/share/tomcat9
02-Nov-2021 11:41:22.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
02-Nov-2021 11:41:22.820 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/var/lib/tomcat9/conf/logging.properties
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.awt.headless=true
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/var/lib/tomcat9
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/share/tomcat9
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/tmp
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.6.5].
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
02-Nov-2021 11:41:22.821 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
02-Nov-2021 11:41:22.825 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1f 31 Mar 2020]
02-Nov-2021 11:41:23.033 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
02-Nov-2021 11:41:23.055 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [406] milliseconds
02-Nov-2021 11:41:23.097 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
02-Nov-2021 11:41:23.097 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.31 (Ubuntu)]
02-Nov-2021 11:41:23.105 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [/etc/tomcat9/Catalina/localhost/host-manager.xml]
02-Nov-2021 11:41:23.115 WARNING [main] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/host-manager] in deployment descriptor [/etc/tomcat9/Catalina/localhost/host-manager.xml] has been ignored
02-Nov-2021 11:41:23.745 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
02-Nov-2021 11:41:23.778 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [/etc/tomcat9/Catalina/localhost/host-manager.xml] has finished in [673] ms
02-Nov-2021 11:41:23.778 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [/etc/tomcat9/Catalina/localhost/manager.xml]
02-Nov-2021 11:41:23.779 WARNING [main] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/manager] in deployment descriptor [/etc/tomcat9/Catalina/localhost/manager.xml] has been ignored
02-Nov-2021 11:41:24.157 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
02-Nov-2021 11:41:24.158 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [/etc/tomcat9/Catalina/localhost/manager.xml] has finished in [380] ms
02-Nov-2021 11:41:24.162 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/var/lib/tomcat9/webapps/servlet-tutorial.war]
02-Nov-2021 11:41:24.645 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
02-Nov-2021 11:41:24.970 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/var/lib/tomcat9/webapps/servlet-tutorial.war] has finished in [808] ms
02-Nov-2021 11:41:24.970 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/var/lib/tomcat9/webapps/ROOT]
02-Nov-2021 11:41:25.447 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
02-Nov-2021 11:41:25.449 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/var/lib/tomcat9/webapps/ROOT] has finished in [479] ms
02-Nov-2021 11:41:25.454 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
02-Nov-2021 11:41:25.463 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [2,405] milliseconds

Deploy java REST service on tomcat docker

I'm trying to deploy a simple REST service to a tomcat that is running on a docker, but I can't seam to reach the service that I tried to deploy.
The simple service that I created is in this class:
#Path("/test")
public class RestTest {
public static final String JSON_RPC = "2.0";
#GET
#Path("/hello")
#Produces(MediaType.APPLICATION_JSON)
public Response processHelloRequestGet() {
String answer = "Hello There!";
JsonRpcResponse rpcResponse = new JsonRpcResponse();
rpcResponse.setId("42");
rpcResponse.setJsonRpc(JSON_RPC);
rpcResponse.setResult(answer);
return Response.status(Status.OK).entity(rpcResponse).build();
}
}
It just creates a simple, static answer in form of a JSON-RPC response.
My web.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>REST Test</display-name>
<servlet>
<servlet-name>jerseyServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>net.jfabricationgames.rest_test</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jerseyServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
and my pom.xml looks like this:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.jfabricationgames.rest_test</groupId>
<artifactId>RestTest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>RestTest Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- JAX-RS for REST -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1-m07</version><!-- <version>2.0</version> -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jdk-http</artifactId>
<version>2.26</version><!-- <version>2.10.1</version> -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.26</version><!-- <version>2.10.1</version> -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.26</version><!-- <version>2.10.1</version> -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.owlike</groupId>
<artifactId>genson</artifactId>
<version>0.99</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/asm/asm -->
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-bundle -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-server -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-core -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19.2</version>
</dependency>
</dependencies>
<build>
<finalName>RestTest</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/rest_test</path>
<port>8080</port>
</configuration>
</plugin>
</plugins>
</build>
</project>
Now if I run the project on a tomcat server from within eclipse everything is working just as expected (using the run configuration Base directory: ${workspace_loc:/RestTest} and Goals: tomcat7:run) and I can reach the service using the URL http://localhost:8080/rest_test/rest/test/hello.
The problem now is that I want my service to run on a tomcat inside a docker on a server, which doesn't seem to be working.
What I tried so far is exporting the project into a .war file (using maven (gloals: clean install compile) or the eclipse export function), placing them in the directory from where I build the docker file, creating the docker file and running it.
The Dockerfile I'm using (following this tutorial) looks like this:
FROM tomcat:8.0-alpine
LABEL maintainer="deepak#softwareyoga.com"
ADD rest_test.war /usr/local/tomcat/webapps/
EXPOSE 8080
CMD ["catalina.sh", "run"]
When running the docker container using the command docker run -p 80:8080 mywebapp I get the following output (which seems to be correct to me):
docker run -p 80:8080 mywebapp
21-Oct-2019 16:49:55.404 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.53
21-Oct-2019 16:49:55.407 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 29 2018 14:42:45 UTC
21-Oct-2019 16:49:55.408 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.53.0
21-Oct-2019 16:49:55.408 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
21-Oct-2019 16:49:55.408 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 5.0.0-31-generic
21-Oct-2019 16:49:55.409 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
21-Oct-2019 16:49:55.409 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-1.7-openjdk/jre
21-Oct-2019 16:49:55.409 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_181-b01
21-Oct-2019 16:49:55.410 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
21-Oct-2019 16:49:55.410 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
21-Oct-2019 16:49:55.411 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
21-Oct-2019 16:49:55.411 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
21-Oct-2019 16:49:55.412 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
21-Oct-2019 16:49:55.412 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
21-Oct-2019 16:49:55.412 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
21-Oct-2019 16:49:55.413 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
21-Oct-2019 16:49:55.413 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
21-Oct-2019 16:49:55.413 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
21-Oct-2019 16:49:55.414 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
21-Oct-2019 16:49:55.414 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.17 using APR version 1.6.3.
21-Oct-2019 16:49:55.414 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
21-Oct-2019 16:49:55.418 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2o 27 Mar 2018)
21-Oct-2019 16:49:55.528 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
21-Oct-2019 16:49:55.556 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
21-Oct-2019 16:49:55.561 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1095 ms
21-Oct-2019 16:49:55.677 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
21-Oct-2019 16:49:55.677 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.53
21-Oct-2019 16:49:55.760 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webapps/rest_test.war
21-Oct-2019 16:49:56.810 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/webapps/rest_test.war has finished in 1,050 ms
21-Oct-2019 16:49:56.820 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webapps/sample.war
21-Oct-2019 16:49:56.911 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/webapps/sample.war has finished in 91 ms
21-Oct-2019 16:49:56.913 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
21-Oct-2019 16:49:56.986 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 73 ms
21-Oct-2019 16:49:56.992 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
21-Oct-2019 16:49:57.799 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 807 ms
21-Oct-2019 16:49:57.801 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/ROOT
21-Oct-2019 16:49:57.882 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/ROOT has finished in 82 ms
21-Oct-2019 16:49:57.885 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
21-Oct-2019 16:49:57.984 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 99 ms
21-Oct-2019 16:49:57.993 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
21-Oct-2019 16:49:58.081 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 88 ms
21-Oct-2019 16:49:58.088 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
21-Oct-2019 16:49:58.156 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
21-Oct-2019 16:49:58.187 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2625 ms
What is working so far is that the docker container seems to be started correctly and that I can reach the tomcat 'homepage' by entering localhost into the browser (see the picture below). Also my .war file seems to be added and extracted correctly (there is a rest_test.war file and a rest_test directory in the directory webapps of the tomcat docker container). Also everything is working just fine when starting it from within eclipse.
What is NOT working yet is to reach the rest service I created and deployed. I tried to access it using the url localhost/rest_test/rest/test/hello but I get an HTTP error 404 - Not Found.
What is kinda strange is that I don't get a Message in the HTTP error 404 when calling the url localhost/rest_test/rest/..., but I get a message when calling any other url (like shown in the pictures below), which makes me think that it's not completely wrong, what I'm trying.
Thanks in advance.
EDIT: Updated to tomcat 9 using the docker image tomcat:9.0-alpine, but that didn't seem to change anything. The content of the .war file looks like this:
It seems that the war file is not built correctly. The WEB-INF/libs directory containing the jar application dependencies is missing. More about the directory Layout of a Web Application Archive file here.
Exceptions thrown during startup are logged into /usr/local/tomcat/logs/localhost.<timestamp>.log. That is the reason everything seems to work normally. localhost.log should contain the error:
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
As mentioned in the comments jersey 2.26 cannot run with java 1.7.0_181. As the libraries don't get loaded during application startup, there are no java version incompatibility errors in the output.
Now, assuming you run with tomcat 9 and java 8, the first step is to fix the build. I suggest running maven from command line. Your pom.xml looks just fine and it should create a valid war.
Next step is to set the scope of javax.ws.rs-api library to provided. The jersey-bundle library has a slightly different version of the javax.ws.rs classes and if you keep both your may run into classloading issues.
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
This will fix things but the configuration still has issues because you are mixing jersey 1.x with jersey 2.x libraries. In addition the jersey-bundle should not be used with maven. The bundle is only intended for developers that do not use Maven's dependency system.
A basic dependency configuration using the jersey 2 libraries should be like the following:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jersey2.version>2.26</jersey2.version>
<jaxrs.version>2.1.1</jaxrs.version>
</properties>
<dependencies>
<!-- JAX-RS -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${jaxrs.version}</version>
</dependency>
<!-- Jersey -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey2.version}</version>
</dependency>
</dependencies>
The web.xml should be modified too:
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>net.jfabricationgames.rest_test</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Hope it helps.

HTTP Status 404 – Not Found while app is running

I have a problem with my spring app. While I run it, I am getting below exception:
It had worked correctly, but app didn't see changes in .jsp files and loaded the same page every time.
I faced with this problem in the past? but unfortunately I couldn't resolve this, and recreated project.
My project struct:
My spring-mvc-demo-servlet.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Step 3: Add support for component scanning -->
<context:component-scan base-package="com.spring" />
<!-- Step 4: Add support for conversion, formatting and validation support -->
<mvc:annotation-driven/>
<!-- Step 5: Define Spring MVC view resolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
My web.xml:
<?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_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>spring-mvc-demo</display-name>
<!-- Spring MVC Configs -->
<!-- Step 1: Configure Spring MVC Dispatcher Servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/spring-mvc-demo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet -->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Maybe there is a problem with artifacts or tomcat configuration, because I changed it while tried resolve this error.
My pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.spring</groupId>
<artifactId>SpringgMVC</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>LATEST</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jsp-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>8.5.39</version>
<type>pom</type>
</dependency>
</dependencies>
Update:::
I created a new artfacts, and received a new error:
my artifacts:
Although there are problem in web.xml.
Tomcat Log
"C:\Program Files\Apache Software Foundation\Tomcat 8.5\bin\catalina.bat" run
[2019-05-16 03:36:54,591] Artifact SpringgMVC:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\__it\.IntelliJIdea2018.3\system\tomcat\Unnamed_SpringgMVC"
Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Tomcat 8.5"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 8.5\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_151"
Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Tomcat 8.5\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 8.5\bin\tomcat-juli.jar"
16-May-2019 15:36:55.256 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.39
16-May-2019 15:36:55.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Mar 14 2019 11:24:26 UTC
16-May-2019 15:36:55.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.39.0
16-May-2019 15:36:55.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
16-May-2019 15:36:55.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
16-May-2019 15:36:55.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
16-May-2019 15:36:55.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_151\jre
16-May-2019 15:36:55.257 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_151-b12
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\__it\.IntelliJIdea2018.3\system\tomcat\Unnamed_SpringgMVC
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 8.5
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\__it\.IntelliJIdea2018.3\system\tomcat\Unnamed_SpringgMVC\conf\logging.properties
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\__it\.IntelliJIdea2018.3\system\tomcat\Unnamed_SpringgMVC
16-May-2019 15:36:55.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.5
16-May-2019 15:36:55.259 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 8.5\temp
16-May-2019 15:36:55.259 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_151\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\ProgramData\Boxstarter;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin;C:\Program Files\dotnet\;C:\Program Files\Calibre2\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\TortoiseGit\bin;C:\Python27\gnuplot\binary;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\__it\AppData\Local\Microsoft\WindowsApps;C:\Users\__it\AppData\Local\Yarn\.bin;C:\Program Files\MongoDB\Server\3.4\bin;c:\Program Files\PhantomJS 2.1.1\bin;C:\ProgramData\Oracle\Java\javapath;;D:\PyCharm Community Edition 2018.3.5\bin;;.]
16-May-2019 15:36:55.334 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
16-May-2019 15:36:55.343 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
16-May-2019 15:36:55.355 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
16-May-2019 15:36:55.357 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
16-May-2019 15:36:55.357 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 381 ms
16-May-2019 15:36:55.372 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
16-May-2019 15:36:55.372 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.39
16-May-2019 15:36:55.378 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
16-May-2019 15:36:55.384 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
16-May-2019 15:36:55.384 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 27 ms
Connected to server
[2019-05-16 03:36:55,667] Artifact SpringgMVC:war exploded: Artifact is being deployed, please wait...
16-May-2019 15:36:57.032 INFO [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2019-05-16 03:36:57,076] Artifact SpringgMVC:war exploded: Artifact is deployed successfully
[2019-05-16 03:36:57,077] Artifact SpringgMVC:war exploded: Deploy took 1 410 milliseconds
16-May-2019 15:37:05.382 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\manager]
16-May-2019 15:37:05.442 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 8.5\webapps\manager] has finished in [60] ms
Error is: Can not resolve servlet 'dispatcher'.
Pom.xml updated too above.
You can try maven tomcat plugin
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>9000</port> //Configure port number
<path>/spring5-webmvc-demo</path> //Configure application root URL
</configuration>
</plugin>
Then you can do a build mvn clean install and then mvn tomcat7:run
At least I resolved my problem. As told M. Deinum I have moved an web.xml, view, and spring-mvc-demo-servlet.xml to WEB-INF, because I have:
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
Then I regenerated an Artifacts.

Categories

Resources