I am working on an API that is built on top of the Spark mini-framework (http://sparkjava.com/)
Whenever I build a package through Maven, which is then uploaded to the webapps/ folder under Tomcat 7.
(The real name have been replaced with TestProject to avoid disclosing anything propritary)
If I compile the project and name it TestProject.war, it is loaded with the following information:
Path: /TestProject
Version: None specified
Upon opening http://localhost:8080/TestProject/ I then get the expected output:
{"code":400,"message":"The authorization information was not specified in the request"}
If I then rename the file to TestProject##0.0.1-SNAPSHOT_20160308.161909.war and restart Tomcat, the application is loaded with the following details:
Path: /TestProject
Version: 0.0.1-SNAPSHOT_20160308.161909
Unfortunately, when opening the same url, Tomcat returns 404:
HTTP Status 404 - /
type Status report
message /
description The requested resource is not available. Apache
Tomcat/7.0.67
$ cat web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>RESTFul Web Service</display-name>
<filter>
<filter-name>SparkFilter</filter-name>
<filter-class>spark.servlet.SparkFilter</filter-class>
<init-param>
<param-name>applicationClass</param-name>
<param-value>TestProjectService</param-value>
</init-param>
</filter>
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,authorization,scope,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SparkFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
$ cat context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="true" path="/TestProject"/>
I simply don't know what causes the problem.. The only difference is the name of the .war
System information:
OS: Windows 10 x64
Java: java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
C:\OtherPrograms\apache-tomcat-7.0.67>bin\startup.bat
Using CATALINA_BASE: "C:\OtherPrograms\apache-tomcat-7.0.67"
Using CATALINA_HOME: "C:\OtherPrograms\apache-tomcat-7.0.67"
Using CATALINA_TMPDIR: "C:\OtherPrograms\apache-tomcat-7.0.67\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_73"
Using CLASSPATH: "C:\OtherPrograms\apache-tomcat-7.0.67\bin\bootstrap.jar;C:\OtherPrograms\apache-tomcat-7.0.67\bin\tomcat-juli.jar"