I have a jersey web-app, use IntelliJ IDEA as IDE. I use maven (pom.xml) as the project manager tools ---- use for dependency lib manager.
I use this debug configuration:
Server -> Application Server: Tomcat 9.0.24 URL : http://localhost:8080/
Deployment -> :war exploded Application Context: /
then when I press the debug button, the project compile, and the artifact deployed, the browser open for welcome page (this is static page).
I use postman send GET or POST or PUT request, the correct response given.
when I Build/Artifacts..., IntelliJ IDEA created .war file.
I put the war file to remote Tomcat container webapps folder ---- all same as localhost ---- use ROOT.war name.
tomcat catalina.out file has this message:
20-Aug-2019 11:41:06.528 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"] 20-Aug-2019 11:41:06.546 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"] 20-Aug-2019 11:41:06.551 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [393] milliseconds 20-Aug-2019 11:41:06.587 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 20-Aug-2019 11:41:06.587 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.24] 20-Aug-2019 11:41:06.603 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/root/apache-tomcat-9.0.24/webapps/ROOT.war] 20-Aug-2019 11:41:08.434 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. 20-Aug-2019 11:41:08.469 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/root/apache-tomcat-9.0.24/webapps/ROOT.war] has finished in [1,867] ms
I use postman send same request, get 404 error. use postman access static page, It's ok.
I google some matter, but not suit my scene. Here not tomcat Application context correct, not war file incorrect.
My project is not web.xml file. but I append web.xml, not luck.
I append tomcat7-maven-plugin to pom.xml file. not effect.
append org.glassfish.jersey.bundles jaxrs-ri lib to pom.xml. same.
@ApplicationPath("/api")
public class RestApplication extends ResourceConfig {
I use this Application of JAX-RS. so I access http://host-name:8080/api/..., tomcat give me not found.
I lookup the tomcat access log(localhost_access_log.2019-MM-DD.txt), give me this message:
114.249.235.124 - - [20/Aug/2019:11:53:12 +0800] "GET /api/subjects HTTP/1.1" 404 1047
why IntelliJ IDEA startup tomcat and deploy the project is ok, I use IntelliJ IDEA build the war file and put it to tomcat webapps/ROOT.war not work?
may the problem at where?
Yes, the problem is solved. Caused by different Java versions. The Java on my machine is a high version, but the Java version on the Server is relatively low