Reputation: 1523
I'm developing a simple application which uses Jersey as framework to build the API and Jackson to handle JSON.
When I deploy the application, by copying & pasting at webapps/, I can see my index.jsp. Although my created resource isn't reachable, it always show a 404 page. No errors are shown, not event at the catalina.* logs file.
I'm pretty sure about the problem isn't at the java code because it used to work with *.jar include approach. But I'm tired of that and wanted to migrate it to maven architecture.
I won't post my entire code, but you can see it here.
To make things easier, here follows the list of dependencies that I'm using:
What can cause this error? I have nothing to follow, no stack trace, no error message, nothing. Could it be the lack of some dependency?
Upvotes: 1
Views: 2746
Reputation: 208944
jersey-json
. That is 1.x and it's going to mess you upYou need more than just jersey-server
. You will also need
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25.1</version>
</dependency>
You should get rid of your web.xml. You don't need it with your @ApplicationPath
configuration annotation. Also your using a very old schema version in your web.xml. I don't know if that will mess you up either. Better just get rid of the web.xml completely, unless you can find a more up to date header for the file.
Upvotes: 2
Reputation: 13
not very sure about this but try adding the servlet to your web.xml, since last time I use jersey i find out it was necesary to communicate with the server
for example this is what I add to a web.xml
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>"PACKAGE WHERE DO YOU HAVE YOUR CLASS"</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Please notice that I was ussing Glassfish server and not Tomcat (in "servlet-class" ), but this migth give you and idea I really hope this could help you :)
Upvotes: 0