User45
User45

Reputation: 74

My Spring based Restful webservice gives 404 when deploy to standalone tomcat instead of Eclipse's Tomcat

I am using Spring, Jpa Hibernate to create a Restful Webservices. It worked fine with Eclipse's Setup of tomcat server. But when I tried to deploy its war file to standalone tomcat's webapp folder and restart the server, it gives 404 error.

What could be the cause? Am I missing some steps while deploying to standalone tomcat?

Edit:

Turns out when packaging the war through mvn clean install, its not packaging my web.xml and springcontext.xml. When I manually copy these file to the deployed war, the project work fine.

Now the question is, do any have idea why its not packaging those file.

Upvotes: 0

Views: 603

Answers (2)

K.Nicholas
K.Nicholas

Reputation: 11551

By default Eclipse projects put web stuff in a folder called WebContent. This is not where maven expects it, so you should convert your Eclipse project to a maven project by using Right Click on Project->Configure->Convert to Maven project. This will build a pom.xml that references the WebContent directory:

  <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <warSourceDirectory>WebContent</warSourceDirectory>
      <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>

Upvotes: 1

Mike Summers
Mike Summers

Reputation: 2239

Here's where I'd start with the debugging:

  • Can you connect to the standalone Tomcat at http://localhost:8080 ?
    • If not then you probably have a port problem
  • Is the war expanded under $catalina_home/webapps ?
    • If not then you have a deploy problem
    • If you're not letting Tomcat's Manager auto-deploy then unzip the war in-place

We do exactly what you're up to on a daily basis. We develop in Eclipse, let Tomcat auto-deploy in Dev & QA, in Prod we deploy by hand as the Manager is disabled. Once you can get things to work in Eclipse (usually the problem) then typically it's a Tomcat config problem.

Upvotes: 0

Related Questions