Failing to Deploy Web App to server at context path?

18,258

Solution 1

Kind of drive-by answering here, but I note a hanging end tag in the middle of your web.xml:

</servlet>

this would stop it parsing....

Solution 2

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).

Solution 3

Turns out there was some confusion about the web.xml files i was editing , and when found the correct web.xml and sorted the hanging servlet tag this sorted the problem . Thank you everyone for all your help and patience as I am completely new to maven.

Solution 4

One of the possible reasons for this is this sort of entry in ant

<zipfileset dir="./mywebcontent/" prefix="/" />

remove prefix="/", it spoils your archive

Share:
18,258
Chris
Author by

Chris

Updated on June 09, 2022

Comments

  • Chris
    Chris almost 2 years

    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

    • Chris
      Chris over 13 years
      Thanks Starkey will work on that I never realised i wasnt .
    • matt b
      matt b over 13 years
      You've posted the output of the maven tomcat plugin which tries to deploy your app to a Tomcat server. This output merely tells you while it failed - Maven won't know why Tomcat rejected it. Take a look at the logs in the Tomcat install directory to learn more.
    • Chris
      Chris over 13 years
      The tomcat logs state there is an error as the web.xml is not well formed , I have had a look at the current web.xml and there doesnt seem to be any problems with it so I am unsure as to why this is unable to parse.
    • Chris
      Chris over 13 years
      its failing on line 8 column 4 which is the servlet class tag stating the xml is not well formed.
  • Chris
    Chris over 13 years
    Thanks took that out but it hasnt made any difference to the deployment problem .
  • matt b
    matt b over 13 years
    taking out the </servlet> would be a problem as <servlet-class> and <servlet-name> should be inside a <servlet> element. The initial text posted has the problem that you have a closing </servlet> tag but no opening <servlet> tag. What you have is not valid according to the XML Doctype
  • Chris
    Chris over 13 years
    Could you possible provide more information on how to add that to the classpath
  • shinynewbike
    shinynewbike over 13 years
    @matt b: this comment should be part of your answer methinks.