Search code examples
springmavenspring-mvctomcatbouncycastle

Tomcat Page not found error after deployment


After deployed code in the Tomcat server, I am getting a Not Found error message for all the pages viewed in the browser.

eg:- Not Found /BOOKS/web/Index.html.

I have the Index.html file under the web folder. It is a Spring-MVC framework application.

Here is the error log details.

Error log

INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 
org.apache.catalina.core.StandardEngine.startInternal Starting Serviet Engine: Apache Tomcat/8.5.45
INFO [localhost startStop-1] org.apache.jasper.servlet.TldScanner.scanlars 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. 
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web
application archive [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/BOOKS]


WARNING [localhost-startStop-1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used 
SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost(localhost].StandardContext[/BOOKS]] 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:970) 
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig-java:1841)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1149)
at java.util.concurrent.ThreadPoolExecutor$worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)


Caused by: java.lang.Illega1StateException: Unable to complete the scan for annotations for web application [/BOOKS] 
due to a StackoverflowError, Possible root causes include a too low setting for -Xss and Illegal cyclic Inheritance dependencies. The class hierarchy being processed was [org.bouncycastle.asn1.ASN1OutputStream->org.bouncycastle.asn1.DEROutputStream->org.bouncycastle.asn1.ASN1OutputStream)

at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2116)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2054) 
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:2000)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1970) 
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.Java:1923)
at org.apache.catalina.startup.ContextConfig.processClasses(ContextConfig.java:1230)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.Java:1134)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:769) 
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
at org.apache.catalina.util.Lifecyclebase.fireLifecyclefvent(LifecycleBase.java:94) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5063)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
... 10 more


SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/BOOKS] java.lang.IllegalStateException: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/BOOKS]] 
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:747)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:970) 
at org.apache.catalina.startup.HostConfig$Deploywar.run(HostConfig.java:1841)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/BOOKS] has finished in [9,774] ms 
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/examples]
INFO [localhost-startStop-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. 
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/examples] has finished in [1,357] ms
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/docs]

INFO [localhost-startStop-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.
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/docs] has finished in [1,166] ms
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/manager]
INFO [localhost-startStop-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.
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/manager] has finished in [827] ms 
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/host-manager]
INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScannerscanJars 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.
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory 
[/apps/opt/tomcat/apache-tomcat-8.5.45/webapps/host-manager] has finished in [843] ms 
INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8880"]
INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009"] 
INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 17571 ms

Please help.


Solution

  • You must have two versions of bcprov-* among your dependencies:

    1. An old one (up to version 1.46) where ASN1OutputStream extends DEROutputStream,
    2. A recent one (from version 1.47 onwards) where the hierarchy is reversed: DEROutputStream extends ASN1OutputStream.

    Look among your Maven dependencies for multiple dependencies whose name start with bcprov- and check if you don't have another version in the WEB-INF/lib folder of your application or Tomcat's common classloader (lib folder of $CATALINA_BASE and $CATALINA_HOME).

    Edit: For Bouncy Castle (and many long standing libraries) the problem of multiple versions might be exacerbated by multiple Maven artifacts (in two groups: bouncycastle and org.bouncycastle) using almost the same code: bcprov-jdk14, bcprov-jdk15on, bcprov-jdk15to18, etc. See this question for an example.