Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing to Deploy Web App to server at context path?

I have a simple Jersey jax rs hello world application that I am trying to deploy to my tomcat server so i can call the resource url and check and see if it gives me the required output but when i set the context path in the web.xml it doesnt deploy to the server it does however when i take the servlet information out and just leave a blank web.xml meaning this must be my problem. Here is the contents of my 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>Web App</display-name>  
  <servlet-name>ServletContainer</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletContainer</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
</web-app>

As requested here is the stacktrace of the error

[INFO] [war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] Assembling webapp[app1] in [C:\Users\leo\4thYearUni\Project\app1\target\app1]
[INFO] Processing war project
[INFO] Copying webapp resources[C:\Users\leo\4thYearUni\Project\app1\src\main\webapp]
[INFO] Webapp assembled in[170 msecs]
[INFO] Building war: C:\Users\leo\4thYearUni\Project\app1\target\app1.war
[INFO] [tomcat:redeploy {execution: default-cli}]
[INFO] Deploying war to http://localhost:8080/app1
[INFO] OK - Undeployed application at context path /app1
[INFO] FAIL - Failed to deploy application at context path /app1

If anyone has any ideas or workarounds this would be much appreciated Thank you Chris

like image 226
Chris Avatar asked Nov 22 '10 20:11

Chris


People also ask

Where is context path in web application?

The typical way of getting the context path is through the HttpServletRequest class. Simply you can add a HttpServletRequest parameter to your controller method and then get the context path using getContextPath() method. Now that you get the context path, you can pass it to the services that need it.

What is context path in Java web application?

The context path is the portion of the request URI that is used to select the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".

Where is Tomcat context path?

A context path in Apache Tomcat refers to the name of the website as presented by the browser. For example, imagine I tell you to enter "localhost:8080/DemoWebsite/DateJSP. jsp" in your browser. The context path is "DemoWebsite".


1 Answers

First of all, if something is failing deployment, the first hint at a solution is to look at the logs of the application server to answer the question "Why is this failing?"

Things don't just "fail", they will give error messages and exceptions and stacktraces and information about what is actually occurring. Attempting to guess why something fails with none of this knowledge amounts to just guesswork.

As a guess, make sure that the class com.sun.jersey.spi.container.servlet.ServletContainer is on the classpath of the web application (i.e. in the WEB-INF/lib directory).

like image 137
matt b Avatar answered Sep 22 '22 10:09

matt b