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.
You must have two versions of bcprov-* among your dependencies:
An old one (up to version 1.46) where ASN1OutputStream extends DEROutputStream,
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.
I have followed multiple videos and documents to create WAR file for spring boot web application.
When I run the application as JAVA application from eclipes it works fine but if I copy the WAR file in webapps folder of tomcat it doesn't work.
Here is the pom file
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<start-class>com.demo.DemoApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>demo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Here is the java file
package com.demo;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
#SpringBootApplication
#RestController
public class DemoApplication extends SpringBootServletInitializer{
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication.class);
}
public static void main(String[] args) {
System.out.println("Starting app");
SpringApplication.run(DemoApplication.class, args);
System.out.println("Waiting in app");
}
#GetMapping("/test")
#ResponseBody
public String test() {
System.out.println("reached REST API");
return "App running";
}
}
I am using the url localhost:8080/demo/test but it always gives me error 404.
My System.out.println are logging while running the program from eclipse as Java application but those loggings don't come while deploying WAR in tomcat though catalina.out shows demo.war is successfully deployed and I see the demo directory is created with my DemoApplication class as expected.
I have not created any web.xml. During the project creation I chose wizard "spring starter project" and then in spring starter project dependencies I have selected only "spring-web".
What am I missing? Any help will be appreciated.
Catalina.out
04-Apr-2021 23:16:50.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/10.0.4
04-Apr-2021 23:16:50.749 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Mar 5 2021 11:07:15 UTC
04-Apr-2021 23:16:50.749 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.0.4.0
04-Apr-2021 23:16:50.749 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
04-Apr-2021 23:16:50.760 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
04-Apr-2021 23:16:50.760 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
04-Apr-2021 23:16:50.760 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.282-1\jre
04-Apr-2021 23:16:50.760 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_282-b08
04-Apr-2021 23:16:50.760 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Red Hat, Inc.
04-Apr-2021 23:16:50.760 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 10.0
04-Apr-2021 23:16:50.760 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 10.0
04-Apr-2021 23:16:50.761 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 10.0
04-Apr-2021 23:16:50.761 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 10.0
04-Apr-2021 23:16:50.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 10.0\temp
04-Apr-2021 23:16:50.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
04-Apr-2021 23:16:50.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 10.0\conf\logging.properties
04-Apr-2021 23:16:50.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
04-Apr-2021 23:16:50.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: abort
04-Apr-2021 23:16:50.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
04-Apr-2021 23:16:50.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
04-Apr-2021 23:16:50.766 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [C:\Program Files\Apache Software Foundation\Tomcat 10.0\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.282-1\jre\bin;C:\Program Files (x86)\RSA SecurID Token Common;C:\Program Files\RSA SecurID Token Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\1E\NomadBranch;C:\Program Files\Dell\Dell Data Protection\Encryption;C:\Program Files\RedHat\java-11-openjdk-11.0.10-1\bin;C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.282-1\bin;C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.282-1\jre\bin;C:\WINDOWS\ServiceProfiles\LocalService\AppData\Local\Microsoft\WindowsApps;.]
04-Apr-2021 23:16:51.036 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
04-Apr-2021 23:16:51.051 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [450] milliseconds
04-Apr-2021 23:16:51.075 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
04-Apr-2021 23:16:51.076 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.0.4]
04-Apr-2021 23:16:51.098 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\testp.war]
04-Apr-2021 23:16:53.234 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.
04-Apr-2021 23:16:54.302 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [1,040] milliseconds.
04-Apr-2021 23:16:54.318 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\demo.war] has finished in [3,220] ms
04-Apr-2021 23:16:54.319 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\manager]
04-Apr-2021 23:16:54.365 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\manager] has finished in [46] ms
04-Apr-2021 23:16:54.365 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\ROOT]
04-Apr-2021 23:16:54.398 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\ROOT] has finished in [33] ms
04-Apr-2021 23:16:54.401 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
04-Apr-2021 23:16:54.415 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [3363] milliseconds
localhost-access-log
0:0:0:0:0:0:0:1 - - [04/Apr/2021:23:19:25 +0530] "GET /demo/test HTTP/1.1" 404 764
tomcat10-stdout
2021-04-04 23:16:50 Apache Commons Daemon procrun stdout initialized.
tomcat10-stderr last few lines
04-Apr-2021 23:16:54.365 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\ROOT]
04-Apr-2021 23:16:54.398 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 10.0\webapps\ROOT] has finished in [33] ms
04-Apr-2021 23:16:54.401 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
04-Apr-2021 23:16:54.415 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [3363] milliseconds
I had the same problem.
Tomcat 10 changed from Java EE to Jakarta EE. Spring does not support Jakarta EE yet. Jakarta EE support is planned for Spring6 and SpringBoot3 expected at the end of the year.
You have two ways.
Deploy the war to the webapps-javaee directory instead of the webapps directory. Tomcat will convert it automatically using a conversion tool. I solved the same problem with this.
Use Tomcat 9 with Java EE support
Below are some of the changes in Tomcat 10.
The Apache Tomcat Project is proud to announce the release of version 10.0.13 of Apache Tomcat. This release implements specifications that are part of the Jakarta EE 9 platform.
Applications that run on Tomcat 9 and earlier will not run on Tomcat 10 without changes. Java EE based applications designed for Tomcat 9 and earlier may be placed in the $CATALINA_BASE/webapps-javaee directory and Tomcat will automatically convert them to Jakarta EE and copy them to the webapps directory. This conversion is performed using the Apache Tomcat migration tool for Jakarta EE tool which is also available as a separate download for off-line use.
The notable changes in this release are:
Experimental OpenSSL support through the Panama API incubating in Java 17, with support for OpenSSL 1.1+
Add support for custom caching strategies for web application resources. This initial implementation allows control over whether or not a resource is cached.
Improve robustness of JNDIRealm for exceptions occurring when getting the connection.
Full details of these changes, and all the other changes, are available in the Tomcat 10 changelog.
The issue got resolved after replacing tomcat 10 with tomcat 9.
Yes, issue got resolved after replacing tomcat 10 with tomcat 9.
On my local machine Windows 10 (64 bit) I start docker Toolbox. Then I pull Tomcat image and run it like this:
docker run -it tomcat
It's success run.
31-Dec-2019 17:54:27.598 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]
31-Dec-2019 17:54:28.849 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/ROOT] has finished in [1,246] ms
31-Dec-2019 17:54:28.851 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/host-manager]
31-Dec-2019 17:54:29.029 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/host-manager] has finished in [178] ms
31-Dec-2019 17:54:29.031 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/docs]
31-Dec-2019 17:54:29.128 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/docs] has finished in [90] ms
31-Dec-2019 17:54:29.129 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/manager]
31-Dec-2019 17:54:29.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/manager] has finished in [122] ms
31-Dec-2019 17:54:29.254 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/examples]
31-Dec-2019 17:54:30.480 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/examples] has finished in [1,226] ms
31-Dec-2019 17:54:30.499 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
31-Dec-2019 17:54:30.592 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
31-Dec-2019 17:54:30.621 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 3185 ms
But when I open my browser and input
http://127.0.0.1:8080/
But page not found
Why?
#DavidMaze is right: there are simultaneously several issues (at least two, maybe more, see below) in the situation you describe, and each issue individually prevents a browser on the Windows host from accessing the web application deployed in the Docker container:
The web application needs to listen to the 0.0.0.0 special IP address (not localhost).
The -p (--publish) option of docker run is required. Let's say the web-app listens for port 8080, then to publish this exposed port to the 80 port on the host: docker run -p 80:8080 […] (but the two ports can be the same)
Finally as you use Docker Toolbox on Windows, you need to identify the Docker Machine IP where the web-app will be available (not localhost): if this information is not directly displayed by Docker Toolbox at startup, you may want to run: docker-machine ip dev.
For more details
Regarding items 1. 2., see also How to convert a Spring-Boot web service into a Docker image?
Regarding item 3., see e.g. Can't access Spring Boot with my docker image
(albeit these threads deal with Spring-Boot, the details there are quite generic)
I am trying to get a Spring Boot WAR to deploy to a private Tomcat 7.0.68 instance hosted by DailyRazor. I cannot figure out why the Spring Boot application will not work. I do not seem to get any errors. Locally, I have gotten this to work with STS 3.8.4, Tomcat 7.0.78, Tomcat 8.5.11, and a couple other versions of Tomcat.
I never see the Spring Boot banner display on the DailyRazor instance nor much of the other logging indicating that my Spring Boot application is starting and loading all of the beans. This is the only logging I see:
INFO main org.apache.catalina.core.StandardService - Stopping service Catalina
INFO main org.apache.catalina.core.AprLifecycleListener - The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/tomcat/users/user_id/jdk/jre/lib/amd64/server:/usr/local/tomcat/users/user_id/jdk/jre/lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
INFO main org.apache.catalina.startup.Catalina - Initialization processed in 2299 ms
INFO main org.apache.catalina.core.StandardService - Starting service Catalina
INFO main org.apache.catalina.core.StandardEngine - Starting Servlet Engine: Apache Tomcat/7.0.68
INFO foobar.com-startStop-1 org.apache.catalina.startup.TldConfig - 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 foobar.com-startStop-1 org.apache.catalina.util.SessionIdGeneratorBase - Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [271] milliseconds.
INFO foobar.com-startStop-1 org.apache.catalina.startup.HostConfig - Deploying web application archive /home/user_id/tomcat/webapps/foobar.com/ROOT.war
INFO foobar.com-startStop-1 org.apache.catalina.startup.TldConfig - 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 foobar.com-startStop-1 org.apache.catalina.startup.HostConfig - Deployment of web application archive /home/user_id/tomcat/webapps/foobar.com/ROOT.war has finished in 1,603 ms
INFO foobar.com-startStop-1 org.apache.catalina.startup.HostConfig - Deploying web application archive /home/user_id/tomcat/webapps/foobar.com/plant-service-0.0.1-SNAPSHOT.war
INFO foobar.com-startStop-1 org.apache.catalina.startup.TldConfig - 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 foobar.com-startStop-1 org.apache.catalina.core.ContainerBase.[Catalina].[foobar.com].[/plant-service-0.0.1-SNAPSHOT] - 3 Spring WebApplicationInitializers detected on classpath
INFO foobar.com-startStop-1 org.apache.catalina.core.ContainerBase.[Catalina].[foobar.com].[/plant-service-0.0.1-SNAPSHOT] - Initializing Spring embedded WebApplicationContext
INFO foobar.com-startStop-1 org.apache.catalina.startup.HostConfig - Deployment of web application archive /home/user_id/tomcat/webapps/foobar.com/plant-service-0.0.1-SNAPSHOT.war has finished in 21,769 ms
INFO main org.apache.catalina.startup.Catalina - Server startup in 26534 ms
INFO ajp-bio-127.0.0.1-9592-exec-1 org.apache.catalina.core.ContainerBase.[Catalina].[foobar.com].[/plant-service-0.0.1-SNAPSHOT] - Initializing Spring FrameworkServlet 'dispatcherServlet'
I have following the instructions for packaging as a WAR, extending SpringBootServletInitializer, overriding configure(...), etc. Again, this all works locally on multiple versions of Tomcat. I have tried to adjust the logging, but I do not see anything useful.
Any hints? Suggestions?
EDIT
Not sure if it is related, but when shutting down Tomcat, I see the following:
INFO main org.apache.catalina.core.StandardService - Stopping service Catalina
ERROR foobar.com-startStop-2 org.apache.catalina.loader.WebappClassLoaderBase - The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
INFO foobar.com-startStop-2 org.apache.catalina.core.ContainerBase.[Catalina].[foobar.com].[/plant-service-0.0.1-SNAPSHOT] - Destroying Spring FrameworkServlet 'dispatcherServlet'
INFO foobar.com-startStop-2 org.apache.catalina.core.ContainerBase.[Catalina].[foobar.com].[/plant-service-0.0.1-SNAPSHOT] - Closing Spring root WebApplicationContext
ERROR foobar.com-startStop-2 org.apache.catalina.loader.WebappClassLoaderBase - The web application [/plant-service-0.0.1-SNAPSHOT] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
ERROR foobar.com-startStop-2 org.apache.catalina.loader.WebappClassLoaderBase - The web application [/plant-service-0.0.1-SNAPSHOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
Could you please ensure you did all of this correctly ?
From Create a deployable war file (Spring boot documentation) :
Create a deployable war file
The first step in producing a deployable war file is to provide a
SpringBootServletInitializer subclass and override its configure
method. This makes use of Spring Framework’s Servlet 3.0 support and
allows you to configure your application when it’s launched by the
servlet container. Typically, you update your application’s main class
to extend SpringBootServletInitializer:
#SpringBootApplication
public class Application extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
The next step is to update your build configuration so that your
project produces a war file rather than a jar file. If you’re using
Maven and using spring-boot-starter-parent (which configures Maven’s
war plugin for you) all you need to do is to modify pom.xml to
change the packaging to war:
<packaging>war</packaging>
EDIT
Do you have spring-boot-starter-web and spring-boot-starter-tomcat dependencies ?
To build a war file that is both executable and deployable into an
external container you need to mark the embedded container
dependencies as “provided”, e.g:
<?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">
<!-- ... -->
<packaging>war</packaging>
<!-- ... -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- ... -->
</dependencies>
</project>
I've put the file apache-solr-3.5.0.war in folder C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps.
A folder "apache-solr-3.5.0" is created automatically. And when I go to: http://localhost:8080/apache-solr-3.5.0/ .
I can see the message "Welcome to Solr!".
Now, when I do the exact same with the file solr-4.3.1.war in the folder C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps
A folder solr-4.3.1 is created automatically. But now when I go to:
http://localhost:8080/solr-4.3.1/ OR to http://localhost:8080/solr-4.3.1/admin.html
I see the error:
HTTP Status 404 - type Status report
Message: description The requested resource is not available.
Apache Tomcat/6.0.37
What am I missing?
Update:
This is shown in the Tomcat console window:
INFO: Solr
home set to 'solr/' 12-jul-2013 18:27:36
org.apache.solr.core.SolrResourceLoader <init> INFO: Solr home set to
'solr\.\' 12-jul-2013 18:27:36 org.apache.solr.common.SolrException
log SEVERE: java.lang.RuntimeException: Can't find resource
'solrconfig.xml' in class sath or 'solr\.\conf/', cwd=C:\Program
Files\Apache Software Foundation\Tomcat
6.0
at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoad
er.java:268)
12-jul-2013 18:27:36 org.apache.solr.servlet.SolrDispatchFilter init
INFO: user.dir=C:\Program Files\Apache Software Foundation\Tomcat 6.0
12-jul-2013 18:27:36 org.apache.solr.servlet.SolrDispatchFilter init
INFO: SolrDispatchFilter.init() done 12-jul-2013 18:27:36
org.apache.solr.servlet.SolrServlet init INFO: SolrServlet.init()
12-jul-2013 18:27:36 org.apache.solr.core.SolrResourceLoader
locateSolrHome INFO: No /solr/home in JNDI 12-jul-2013 18:27:36
org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: solr home
defaulted to 'solr/' (could not find system property or JNDI)
12-jul-2013 18:27:36 org.apache.solr.servlet.SolrServlet init INFO:
SolrServlet.init() done 12-jul-2013 18:27:36
org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: No
/solr/home in JNDI 12-jul-2013 18:27:36
org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: solr home
defaulted to 'solr/' (could not find system property or JNDI)
12-jul-2013 18:27:36 org.apache.solr.servlet.SolrUpdateServlet init
INFO: SolrUpdateServlet.init() done 12-jul-2013 18:27:36
org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web
application archive solr-4.3.1.war 12-jul-2013 18:27:36
org.apache.catalina.core.StandardContext start SEVERE: Error
filterStart 12-jul-2013 18:27:36
org.apache.catalina.core.StandardContext start SEVERE: Context
[/solr-4.3.1] startup failed due to previous errors 12-jul-2013
18:27:36 org.apache.catalina.startup.HostConfig deployDirectory INFO:
Deploying web application directory ROOT 12-jul-2013 18:27:36
org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote
HTTP/1.1 on http-8080 12-jul-2013 18:27:36
org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on
/0.0.0.0:8009 12-jul-2013 18:27:36 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/56 config=null 12-jul-2013 18:27:36
org.apache.catalina.startup.Catalina start INFO: Server startup in 880
ms
My unpacked Solr folder contains these folders:
css
img
js
META-INF
tpl
WEB-INF
Update
After adding this to my environment variables:
JAVA_OPTS = $JAVA_OPTS -Dsolr.solr.home=C:/Databases/solr-4.3.1/example/solr
I get these 2 errors after startup:
SEVERE: org.apache.solr.common.SolrException: Invalid luceneMatchVersion 'LUCENE_43', valid values are: [LUCENE_20, LUCENE_21, LUCENE_22, LUCENE_23, LUCENE_24,LUCENE_29, LUCENE_30, LUCENE_31, LUCENE_32, LUCENE_33, LUCENE_34,LUCENE_35, LUCENE_CURRENT] or a string in format 'V.V'
SEVERE: Exception starting filter SolrRequestFilter org.apache.solr.common.SolrException: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used.
Full log:
SEVERE: org.apache.solr.common.SolrException: Invalid luceneMatchVersion 'LUCENE _43', valid values are: [LUCENE_20, LUCENE_21, LUCENE_22, LUCENE_23, LUCENE_24, LUCENE_29, LUCENE_30, LUCENE_31, LUCENE_32, LUCENE_33, LUCENE_34, LUCENE_35, LUC ENE_CURRENT] or a string in format 'V.V'
at org.apache.solr.core.Config.parseLuceneVersionString(Config.java:353)
13-jul-2013 13:46:02 org.apache.solr.servlet.SolrDispatchFilter init INFO: user.dir=C:\Program Files\Apache Software Foundation\Tomcat 6.0
13-jul-2013 13:46:02 org.apache.solr.servlet.SolrDispatchFilter init INFO: SolrDispatchFilter.init() done 13-jul-2013 13:46:02 org.apache.solr.servlet.SolrServlet init INFO: SolrServlet.init()
13-jul-2013 13:46:02 org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: No /solr/home in JNDI 13-jul-2013 13:46:02 org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: using system property solr.solr.home: C:\Databases\solr-4.3.1\exam ple\solr
13-jul-2013 13:46:02 org.apache.solr.servlet.SolrServlet init INFO: SolrServlet.init() done 13-jul-2013 13:46:02 org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: No /solr/home in JNDI 13-jul-2013 13:46:02 org.apache.solr.core.SolrResourceLoader locateSolrHome INFO: using system property solr.solr.home: C:\Databases\solr-4.3.1\exam ple\solr
13-jul-2013 13:46:02 org.apache.solr.servlet.SolrUpdateServlet init INFO: SolrUpdateServlet.init() done
13-jul-2013 13:46:02 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive solr-4.3.1.war 13-jul-2013 13:46:03 org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter SolrRequestFilter org.apache.solr.common.SolrException: Could not find necessary SLF4j logging jar s. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext direct ory. For other containers, the corresponding
directory should be used. For more information, see:
http://wiki.apache.org/solr/SolrLogging
UPDATE 3
I'm now getting a "HTTP Status 503 - Server is shutting down" error.
14-jul-2013 14:21:57 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performanc
e in production environments was not found on the java.library.path: C:\Program
Files\Apache Software Foundation\Tomcat 6.0\bin;C:\Windows\Sun\Java\bin;C:\Windo
ws\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Li
ve;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\
system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShe
ll\v1.0\;C:\Program Files\TortoiseSVN\bin;c:\msxsl;C:\Program Files (x86)\Window
s Live\Shared;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program File
s (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows
Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110
\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Prog
ram Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQ
L Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL S
erver\110\DTS\Binn\;C:\Program Files (x86)\Java\jre6\bin;C:\Program Files\Java\j
re631\bin;.
14-jul-2013 14:21:57 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
14-jul-2013 14:21:57 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 283 ms
14-jul-2013 14:21:57 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
14-jul-2013 14:21:57 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.37
14-jul-2013 14:21:57 org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
14-jul-2013 14:21:57 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive solr-4.3.1.war
log4j:WARN No appenders could be found for logger (org.apache.solr.servlet.SolrD
ispatchFilter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in
fo.
14-jul-2013 14:21:58 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
14-jul-2013 14:21:58 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
14-jul-2013 14:21:58 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
14-jul-2013 14:21:58 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/55 config=null
14-jul-2013 14:21:58 org.apache.catalina.startup.Catalina start
INFO: Server startup in 719 ms
I read something on this error here, but after adding my logging.properties.
Install Solr in Tomcat
Pre Requirements
1 – Machine with Windows OS (Windows 7,8,Xp.. ..etc)
2 – Java 6 or Above
3 - Solr 4.0.0 or Above
4 – Apache-tomcat 6 or Above.
Steps to get Solr up on Tomcat Server
1.Install Tomcat on your machine and make sure it is ready to start.(Check using localhost:8080)
2.Install Solr4.0 distribution package apache-solr-4.0.0.zip and unzip it in your local directory like C:\apache-solr-4.0.0.
3.Make a folder with name solr-home in your local machine like C:\solr_home.
4.Go back to the solr distribution package that you downloaded C:\apache-solr-4.0.0. Have a peek inside the Examples/solr ("C:\solr-4.4.0\example\solr") folder. Copy all those files into the C:\solr_home folder.(server shutting down exception will come)
5.Look into C:\solr-home\solr and you will see two folders with name collection1 and bin, copy these two folders a step up to C:\solr_home.(if lib not copy "severe error filterstart" Exception come)
6.Copy lib from C:\apache-solr-4.0.0\example\lib\ext SLF4J and log4j.jar file to Tomcat Lib folder C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib
(https://wiki.apache.org/solr/SolrLogging#Using_the_example_logging_setup_in_containers_other_than_Jetty)
7.Copy apache-solr-4.0.war (rename to solr.war) from "C:\solr-4.4.0\dist" directory to webapps directory inside Tomcat.(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps)
8.If tomact is already start then solr folder will create go to "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\solr\WEB-INF\web.xml" edit web.xml
uncomment entry and edit like following(Exception SolrCore 'collection1' is not available due to init failure)
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>C:\solr_home\solr</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
9.Start Tomcat and check localhost:8080/solr dashBoard will come
It got solved for me by on a different forum, here are the steps I followed:
Extract solr431 package. In my case I did in
"E:\solr-4.3.1\example\solr"
Now copied solr dir from extracted package (E:\solr-4.3.1\example\solr)
into TOMCAT_HOME dir.
In my case TOMCAT_HOME dir is pointed to E:\Apache\Tomcat 6.0.
I can refer now SOLR_HOME as " E:\Apache\Tomcat 6.0\solr" (please
remember this)
Copy the solr.war file from extracted package to SOLR HOME dir i.e
E:\Apache\Tomcat 6.0\solr. This is required to create the context. As I
donot want to pass this as JAVA OPTS
Also copy solr.war file into TOMCAT_HOME\webapps for deployment purpose
If you start tomcat you will get errors as mentioned by Shawn. S0 you
need to copy all the 5 jar files from solr extracted package (
E:\solr-4.3.1\example\lib\ext ) to TOMCAT_HOME\lib dir:
jul-to-slf4j-1.6.6,
jcl-over-slf4j-1.6.6,
slf4j-log4j12-1.6.6,
slf4j-api-1.6.6,
log4j-1.2.16
Also copy the log4js.properties file from
E:\solr-4.3.1\example\resources dir to TOMCAT_HOME\lib dir.
Now if you start the tomcat you wont having any problem.
The way that logging works with Solr was updated with Solr 4.3.0 (and higher). If you check your Tomcat logs you will most likely see a "Filter Exception" error. Please refer to the Solr Logging - Using the example logging setup in containers other than Jetty for the steps required to get Solr 4.3.0 and higher to run on Tomcat.
According to my notes (I did that procedure some time ago), I had to add an extra line in the Tomcat "caralina.sh" (or catalina.bat if you use windows):
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/opt/solr/example/solr"
This is used to specify where the solr "configuration" and "data" directories (where your data will be stored). In my case it is "/opt/solr/example/solr", but you need to use the directory where you have the "configuration" files and "data" directory in your system. For example you should use "C:\solr-4.3.1\examples\solr\" if you extracted the downloaded Solr package in C: in windows. This means, that you will deploy the "Solr.war" in Tomcat (you already did that), but the configuration of Solr and "data" stored will be in that directory you specify in catalina.bat (JAVA_OPS, e.g.: C:\solr-4.3.1\examples\solr).
Good instructions to install Solr in a Tomcat in windows: http://liuweipingblog.cn/java/install-lucene-solar-with-tomcat-on-windows/
This error is occurred due to the separate logging mechanism of solr. After researching I have found that, you need to add slf4j log jar in your tomcat lib. ( as per my local machine it is : C:\xampp\tomcat\lib )
download from below url and copy the jar file in tomcat lib
http://www.slf4j.org/download.html
After doing the above step it is working fine in my local system.
The errors about the lucene version indicate that you are still deploying the 3.5 version. I mean, I'm sure you put the 4.x war but for somewhat reason (forgot to delete the war, tmp files) the 3.5 is still there.
When you indicates the solr.home using a system property it will be read by "all" solr you are deploying.
So in your case, the 4.3.1 is happy about the given solr home (which contains LUCENE43) but the 3.5 throws the exception (4.3 is unknown to 3.5)
It includes few steps
Download solr-XXX.zip and extract into solr-XXX.
Copy solr-XXX.war (from solr-XXX/dist folder after unzipping the .zip) into Tomcat/webapps. Then unzip the .war file (using WinZip etc.). This will create folder solr-XXX. Copy log4j-XXX.jar,slf4j-api-XXX.jar,slf4j-log4j12-XXX.jar,commons-logging-XXX.jar into Tomcat/webapps/solr-XXX/WEB-INF/lib. And create a folder Tomcat/webapps/solr-XXX/WEB-INF/classes and copy log4j.properties here from solr-XXX\example\resources
Create a directory MySolrHome anywhere and copy content of solr-XXX\example\solr folder here
Add JAVA_OPTS=-Dsolr.solr.home=Path/to/MySolrHome/
Start Tomcat