In Eclipse, when I click run, it always go to the incorrect path on Eclipse browser. What I have done wrong?
For example; when I click testGet.java and click Run, Eclipse goes to http://localhost:8080/slwebservice/WEB-INF/classes/service/testGet.java. But, in the tutorial or Java Web video, Eclipse goes to a complete url like http://localhost:8080/slwebservice/test/ or something.
I'm using Windows 7, Java SDK 1.7, Eclipse Luna and Tomcat 7.0. I'm not familiar with Java.
Here is my web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>myrest</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>service</param-name>
<param-value>testGet</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myrest</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
When I click run, it seems that there are no exceptions on Tomcat. Here is my Tomcat log :
十月 05, 2015 9:07:28 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:slervice' did not find a matching property.
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/7.0.64
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Aug 19 2015 17:18:06 UTC
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.64.0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 7
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 6.1
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Program Files\Java\jdk1.7.0_79\jre
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.7.0_79-b15
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 7.0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0\endorsed
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=GBK
十月 05, 2015 9:07:28 下午 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.7.0_79\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/lib/amd64;C:\Program Files\Java\jdk1.7.0_79\bin;D:\JAVASDK\android_sdk\tools;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\PWRS\shared;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\BINN;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Sybase\SQL Anywhere 8\win32;C:\Program Files (x86)\Sybase\Shared\win32;C:\Program Files (x86)\Sybase\Shared\Sybase Central 4.1;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Sybase\Shared\PowerBuilder;;C:\Program Files (x86)\Sybase\SQL Anywhere 10\x64;C:\Program Files (x86)\Sybase\SQL Anywhere 10\win32;C:\Program Files (x86)\Sybase\SQL Anywhere 10\Sybase Central 5.0.0\win32;C:\Program Files\SQL Anywhere 12\bin64;C:\Program Files\SQL Anywhere 12\bin32;C:\Program Files (x86)\Sybase\PowerBuilder 12.5;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.4 & MySQL Utilities 1.5.4 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.4 & MySQL Utilities 1.5.4 1.5\Doctrine extensions for PHP\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\apache-maven\bin;;D:\eclipse;;.
十月 05, 2015 9:07:28 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
十月 05, 2015 9:07:28 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 698 ms
十月 05, 2015 9:07:28 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十月 05, 2015 9:07:28 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.64
十月 05, 2015 9:07:29 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\slervice\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
十月 05, 2015 9:07:30 下午 org.apache.catalina.startup.TldConfig execute
信息: 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, 2015 9:07:31 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
十月 05, 2015 9:07:31 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
十月 05, 2015 9:07:31 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 2515 ms
Any help would be appreciated.
Regards
Ken
What are you using here? SpringMVC? No idea what you are asking for... I assume because you are chinese...
Either way it looks like spring, therefore this segment should be changed,
<servlet-mapping>
<servlet-name>myrest</servlet-name>
<url-pattern>/</url-pattern> // remove the *
</servlet-mapping>
</web-app>
Related
I have created a simple spring mvc web app and after successfully running it on the server I pushed it on github. Later I cloned this project and have imported it as a maven project as shown below (now it is already imported)
Now I am trying to run it but unfortunately I get HTTP Status 404 error:
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/9.0.13
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Nov 2 2018 14:27:55 UTC
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 9.0.13.0
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 10
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.0
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_191
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_191-b12
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\Users\Alexander\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 9.0
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\Alexander\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\Alexander\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 9.0\endorsed
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Nov 27, 2018 9:58:50 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: 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\jre1.8.0_191\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_191/bin/server;C:/Program Files/Java/jre1.8.0_191/bin;C:/Program Files/Java/jre1.8.0_191/lib/amd64;C:\Program Files\Microsoft MPI\Bin\;C:\OracleHome\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;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\150\DTS\Binn\;C:\Program Files (x86)\dotnet\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\nodejs\;C:\Users\Alexander\AppData\Local\Microsoft\WindowsApps;C:\Users\Alexander\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Alexander\.dotnet\tools;C:\Users\Alexander\AppData\Local\GitHubDesktop\bin;C:\Users\Alexander\AppData\Roaming\npm;C:\Windows\system32;;.]
Nov 27, 2018 9:58:50 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8089"]
Nov 27, 2018 9:58:50 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Nov 27, 2018 9:58:50 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8010"]
Nov 27, 2018 9:58:50 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Nov 27, 2018 9:58:50 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 795 ms
Nov 27, 2018 9:58:51 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Nov 27, 2018 9:58:51 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/9.0.13
Nov 27, 2018 9:58:51 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: 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.
Nov 27, 2018 9:58:51 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8089"]
Nov 27, 2018 9:58:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8010"]
Nov 27, 2018 9:58:52 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1088 ms
I have seen several similar topics and it seems that everything is correct:
What I am missing?
Update 1:
https://github.com/AlexDev5/javaTesting
Update 2:
https://www.youtube.com/watch?v=CiTrERL4Htw&t=12s
package sampleJSN;
import java.io.IOException;
import java.util.Set;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Init implements ServletContainerInitializer {
#SuppressWarnings("serial")
#Override
public void onStartup(Set<Class<?>> arg0, ServletContext arg1) throws ServletException {
System.out.println("ssd");
HttpServlet serv = new HttpServlet() {
#Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.getWriter().write("<b>JSN</b>");
}
#Override
public void init(ServletConfig config) throws ServletException {
System.out.println("sirappu");
super.init(config);
}
};
Dynamic dyc = arg1.addServlet("Name", serv);
dyc.addMapping("/jsn");
}
}
I was writing a programme to test ServletContainerInitializer.the problem is ServletContainerInitializer itself works properly and ServletContainerInitializer.onStartup is called "ssd" is printed however the ServletContext.addServlet does not register my servlet and hence init method is not called. please check the log bellow
Apr 11, 2018 12:18:45 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:CheckWeb' did not find a matching property.
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.36
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jun 9 2016 13:55:50 UTC
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.36.0
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 8.1
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.3
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jdk1.8.0_161\jre
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_161-b12
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\Users\BalajiGold\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\tomcat-8
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:63748
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\BalajiGold\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\tomcat-8
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\BalajiGold\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\tomcat-8\endorsed
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Apr 11, 2018 12:18:45 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: 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_161\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Java\jdk1.8.0_161\jre\bin;C:/Program Files/Java/jdk1.8.0_121/jre/bin/server;C:/Program Files/Java/jdk1.8.0_121/jre/bin;C:/Program Files/Java/jdk1.8.0_121/jre/lib/amd64;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows;C:\Program Files\QuickTime\QTSystem;C:\cygwin64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\MinGW\bin;C:\MinGW\MSYS\1.0\bin;C:\Program Files\Git\bin;C:\Users\BalajiGold\AppData\Local\Programs\Eclipse Che\eclipse-che-5.0.0\tools\jre\bin;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\Java\jdk1.8.0_161\bin;C:\Program Files\Docker Toolbox;C:\apache-maven-3.5.2\bin;C:\Users\BalajiGold\Desktop;;.
Apr 11, 2018 12:18:45 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Apr 11, 2018 12:18:45 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Apr 11, 2018 12:18:45 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Apr 11, 2018 12:18:45 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Apr 11, 2018 12:18:45 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 941 ms
Apr 11, 2018 12:18:45 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 11, 2018 12:18:45 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.36
Apr 11, 2018 12:18:48 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: 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.
Apr 11, 2018 12:18:50 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: 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.
ssd
Apr 11, 2018 12:18:54 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Apr 11, 2018 12:18:54 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Apr 11, 2018 12:18:54 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 9179 ms
dyc.setLoadOnStartup(0);
this code solved the above problem for me
PS: Don't forget to add META-INF/services/javax.servlet.ServletContainerInitializer
I have already looked at many tutorials, but I can't get my simple JAX-RS application to work. Tomcat always returns Error 404.
The Application to get Classes:
package api;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
#ApplicationPath("/resources")
public class MyApplication extends Application {
// All request scoped resources and providers
#Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>();
classes.add(AuthenticationEndpoint.class);
return classes;
}
}
My JAX-RS file:
package api;
#Path("/hello")
public class AuthenticationEndpoint {
#GET
public Response getUser() {
return Response.status(200).entity("getUser is called").build();
}
}
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" version="3.1">
<display-name>MSM-Master</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>MyApplication</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>api</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyApplication</servlet-name>
<url-pattern>/resources</url-pattern>
</servlet-mapping>
</web-app>
Under "Web Project Settings" my Context root is: "MSM-Master"
The url I tried to call was:
http://localhost:8080/MSM-Master/resources/hello/
Edit:
added Tomcat Console output:
Dez 14, 2017 4:32:39 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MSM-Master' did not find a matching property.
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server version: Apache Tomcat/8.0.30
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server built: Dec 1 2015 22:30:46 UTC
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Server number: 8.0.30.0
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: OS Name: Windows 7
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: OS Version: 6.1
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Architecture: amd64
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Java Home: C:\Program Files\Java\jre1.8.0_66
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: JVM Version: 1.8.0_66-b18
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: JVM Vendor: Oracle Corporation
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: CATALINA_BASE: C:\Users\u016975\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 8.0
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dcatalina.base=C:\Users\u016975\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.0
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dwtp.deploy=C:\Users\u016975\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.0\endorsed
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMATION: Command line argument: -Dfile.encoding=Cp1252
Dez 14, 2017 4:32:39 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMATION: 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\jre1.8.0_66\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jre1.8.0_66/bin/server;C:/Program Files/Java/jre1.8.0_66/bin;C:/Program Files/Java/jre1.8.0_66/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Java\jdk1.8.0_66\bin;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\u016975\AppData\Roaming\npm\;C:\Users\u016975\apache-ant-1.9.7\bin;C:\Users\u016975\AppData\Local\Android\android-sdk\tools;C:\Users\u016975\AppData\Local\Android\android-sdk\platform-tools;C:\windows\system32; C:\windows; C:\windows\System32\Wbem;C:\Applications\Atlassian\atlassian-plugin-sdk-6.2.14\bin;C:\Users\u016975\AppData\Local\Apps\cURL\bin;C:\Applications\Atlassian\atlassian-plugin-sdk-6.2.15\bin;node_modules\npm;C:\Program Files\nodejs\;C:\Users\u016975\apache-ant-1.9.7\bin;C:\Users\u016975\AppData\Local\Android\android-sdk\tools;C:\Users\u016975\AppData\Local\Android\android-sdk\platform-tools;C:\windows\system32; C:\windows; C:\windows\System32\Wbem;C:\Applications\Atlassian\atlassian-plugin-sdk-6.2.14\bin;C:\Users\u016975\AppData\Local\Apps\cURL\bin;C:\Applications\Atlassian\atlassian-plugin-sdk-6.2.15\bin;node_modules\npm;C:\Users\u016975\AppData\Roaming\npm;C:\Program Files\Microsoft VS Code\bin;C:\Users\u016975\Downloads\eclipse-jee-mars-1-win32-x86_64\eclipse;;.
Dez 14, 2017 4:32:39 PM org.apache.coyote.AbstractProtocol init
INFORMATION: Initializing ProtocolHandler ["http-nio-8080"]
Dez 14, 2017 4:32:39 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMATION: Using a shared selector for servlet write/read
Dez 14, 2017 4:32:39 PM org.apache.coyote.AbstractProtocol init
INFORMATION: Initializing ProtocolHandler ["ajp-nio-8009"]
Dez 14, 2017 4:32:39 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMATION: Using a shared selector for servlet write/read
Dez 14, 2017 4:32:39 PM org.apache.catalina.startup.Catalina load
INFORMATION: Initialization processed in 621 ms
Dez 14, 2017 4:32:39 PM org.apache.catalina.core.StandardService startInternal
INFORMATION: Starting service Catalina
Dez 14, 2017 4:32:39 PM org.apache.catalina.core.StandardEngine startInternal
INFORMATION: Starting Servlet Engine: Apache Tomcat/8.0.30
Dez 14, 2017 4:32:46 PM org.apache.jasper.servlet.TldScanner scanJars
INFORMATION: 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.
Dez 14, 2017 4:32:46 PM org.apache.catalina.core.StandardContext startInternal
SCHWERWIEGEND: Error during ServletContainerInitializer processing
javax.servlet.ServletException: java.lang.InstantiationException: org.glassfish.tyrus.server.TyrusServerConfiguration
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:88)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.InstantiationException: org.glassfish.tyrus.server.TyrusServerConfiguration
at java.lang.Class.newInstance(Unknown Source)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:74)
... 8 more
Caused by: java.lang.NoSuchMethodException: org.glassfish.tyrus.server.TyrusServerConfiguration.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
... 10 more
Dez 14, 2017 4:32:46 PM org.apache.catalina.core.StandardContext startInternal
SCHWERWIEGEND: Context [/MSM-Master] startup failed due to previous errors
Dez 14, 2017 4:32:46 PM org.apache.coyote.AbstractProtocol start
INFORMATION: Starting ProtocolHandler ["http-nio-8080"]
Dez 14, 2017 4:32:46 PM org.apache.coyote.AbstractProtocol start
INFORMATION: Starting ProtocolHandler ["ajp-nio-8009"]
Dez 14, 2017 4:32:46 PM org.apache.catalina.startup.Catalina start
INFORMATION: Server startup in 6457 ms
#ApplicationPath provided by JAX – RS which is used to develop a restful web services application with out web.xml. So you can delete your web.xml
Then try overriding getProperties
#ApplicationPath("/resources")
public class MyApplication extends Application {
// All request scoped resources and providers
#Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<>();
classes.add(AuthenticationEndpoint.class);
return classes;
}
#Override
public Map<String, Object> getProperties() {
final Map<String, Object> properties = new HashMap<>();
properties.put("jersey.config.server.provider.packages",
"api");//api-->here mention your yourpackage.to.scan"
return properties;
}
}
When I try to load servlet in my eclipse neon, it gives me "Error instantiating servlet class com.Test" error stating that "The server encountered an internal error that prevented it from fulfilling this request." I can load .jsp page successfully but while trying to load servlet page it gives me following error in eclipse borwser.
and console generates following error.
Sep 07, 2016 9:03:01 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Demo' did not find a matching property.
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.70
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jun 15 2016 16:27:45 UTC
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.70.0
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_101
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_101-b13
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: D:\darshana\eWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 7.0
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=D:\darshana\eWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=D:\darshana\eWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0\endorsed
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Sep 07, 2016 9:03:01 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: 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\jre1.8.0_101\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_101/bin/server;C:/Program Files/Java/jre1.8.0_101/bin;C:/Program Files/Java/jre1.8.0_101/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\PuTTY\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\nodejs\;C:\Program Files\MongoDB\Server\3.2\bin;C:\Users\darshana.ahalpara\AppData\Roaming\npm;C:\Program Files\MongoDB\Server\3.2\bin;C:\Program Files\Java\jdk1.8.0_101\bin;;C:\Users\darshana.ahalpara\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Eclipse;;.
Sep 07, 2016 9:03:01 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8085"]
Sep 07, 2016 9:03:01 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 07, 2016 9:03:01 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 731 ms
Sep 07, 2016 9:03:02 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 07, 2016 9:03:02 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.70
Sep 07, 2016 9:03:02 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8085"]
Sep 07, 2016 9:03:02 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 07, 2016 9:03:02 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 954 ms
Sep 07, 2016 9:03:27 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Demo as unavailable
Sep 07, 2016 9:03:27 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet Demo
java.lang.ClassNotFoundException: com.Test
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1891)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1146)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:866)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Following is my directory structure.
here my Test.java
package com.abc;
import java.io.IOException;
import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Test
*/
//#WebServlet("/Test")
public class Test extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* #see HttpServlet#HttpServlet()
*/
public Test() {
super();
// TODO Auto-generated constructor stub
}
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Hello....!!!!!! ");//.append(request.getContextPath());
}
}
Here is web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>Demo</servlet-name>
<servlet-class>com.abc.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Demo</servlet-name>
<url-pattern>/demo</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>example</servlet-name>
<jsp-file>/exmpl.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>example</servlet-name>
<url-pattern>/example</url-pattern>
</servlet-mapping>
</web-app>
This question is asked multiple times here but due to my little knowledge of using tomcat 7 with Eclipse IDE for J2EE Dev and Gradle as a build tool I am not able to fully utilize the help peovided by the members. Thus, this question.
IDE:
Eclipse Java EE IDE for Web Developers.
Version: Luna Service Release 1 (4.4.1)
Build tool Gradle 1.3
Server tomcat 7 - configured in Eclipse
Error trace:
Mar 05, 2015 9:49:36 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:com.expedia.globalpayments.incentiverecon' did not find a matching property.
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.57
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Nov 3 2014 08:39:16 UTC
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.57.0
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME: C:\Expedia\Java\jdk1.7.0_71\jre
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.7.0_71-b14
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: D:\Office\project\workspace_2015_april\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: D:\Office\tomcat\tomcat-7
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=D:\Office\project\workspace_2015_april\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=D:\Office\tomcat\tomcat-7
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=D:\Office\project\workspace_2015_april\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=D:\Office\tomcat\tomcat-7\endorsed
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Denvironment.properties.location=D:\Office\incentiverecon\irEnvironmentProperties\environment.properties
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dir.log.dir=D:\Office\incentiverecon\irlogs
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Mar 05, 2015 9:49:36 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Expedia\Java\jdk1.7.0_71\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Expedia\Java\jdk1.7.0_71\bin;C:\gradle\gradle-1.3\bin;C:\Expedia\SQLServer(x86)\100\Tools\Binn\VSShell\Common7\IDE\;C:\Expedia\SQLServer(x86)\100\Tools\Binn\;C:\Expedia\SQLServerShared\100\Tools\Binn\;C:\Expedia\SQLServer(x86)\100\DTS\Binn\;C:\Expedia\SQLServerShared\100\DTS\Binn\;C:\Program Files (x86)\Git\cmd;C:\Program Files\MongoDB 2.6 Standard\bin;C:\Expedia\KDiff3;.
Mar 05, 2015 9:49:36 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Mar 05, 2015 9:49:36 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Mar 05, 2015 9:49:36 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 378 ms
Mar 05, 2015 9:49:36 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 05, 2015 9:49:36 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
Mar 05, 2015 9:49:36 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [249] milliseconds.
Mar 05, 2015 9:49:37 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(D:\Office\project\workspace_2015_april\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\com.expedia.globalpayments.incentiverecon\WEB-INF\lib\javax.servlet-2.3.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Mar 05, 2015 9:49:40 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Mar 05, 2015 9:49:40 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Mar 05, 2015 9:49:40 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 05, 2015 9:49:40 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Mar 05, 2015 9:49:41 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\Office\project\workspace_2015_april\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\com.expedia.globalpayments.incentiverecon\WEB-INF\classes\com\expedia\globalpayments\ir\checker\HealthCheckFilter.class]; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:301)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2957)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2957)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:63)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:82)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:277)
... 32 more
Mar 05, 2015 9:49:41 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 05, 2015 9:49:41 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/com.expedia.globalpayments.incentiverecon] startup failed due to previous errors
Mar 05, 2015 9:49:41 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Mar 05, 2015 9:49:41 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:921)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:841)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5035)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5687)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Mar 05, 2015 9:49:41 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/com.expedia.globalpayments.incentiverecon] appears to have started a thread named [AsyncAppender-Dispatcher-Thread-1] but has failed to stop it. This is very likely to create a memory leak.
Mar 05, 2015 9:49:41 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/com.expedia.globalpayments.incentiverecon] appears to have started a thread named [AsyncAppender-Dispatcher-Thread-2] but has failed to stop it. This is very likely to create a memory leak.
Mar 05, 2015 9:49:41 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Mar 05, 2015 9:49:41 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Mar 05, 2015 9:49:41 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4906 ms
You shouldn't include a JAR with javax.servlet.Servlet as it is provided by Tomcat. See this question for details on how to mark the dependency as provided. Conveniently enough, the top rated answer provides an example related to the Servlet API.
Tomcat is smart enough to not load this JAR and instead logs a warning, so that particular message is not what's causing your startup/deployment failure.
While you should address the warning, the IncompatibleClassChangeError is your main issue. This is most likely caused by mixing different versions of Spring in the same project. For example, some JARs from Spring 3.1 and others from 3.2. Try running gradle dependencies and check that all of your Spring JARs are from the same release.