Problem with IntelliJ 12.1.1 and Jersy 1.12

Hi all I am trying a very simple Jersey 1.12/Tomcat 7/Java 7u15 project in IntelliJ.

I set it up with Web, Rest, Spring and Tomcat. I have one service class


package org.fwp.service;


import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;


@Path("/fwp")
public class FWPService
{


    @GET
    @Path("/test")
    @Produces("test/plain")
    public String getTest()
    {
        return "TEST WORKED";
    }


}




And a simple web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app
    id="FWP"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">


    <display-name>FWP</display-name>


    <servlet>
        <servlet-name>fwp-service</servlet-name>
        <servlet-class>
            com.sun.jersey.spi.container.servlet.ServletContainer
        </servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>org.fwp.service</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>


    <servlet-mapping>
        <servlet-name>fwp-service</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>


</web-app>


However, when I try to run the project one of thwo things happen

1) If I have the Jersey Jar in the 'Available Elements' of the project artiacts configuration section, then Jersey does not seem to start at all and I get the following error when I go to localhost:8080/fwp/test

HTTP Status 404 -


type Status report
message
description The requested resource is not available.


Apache Tomcat/7.0.39





2) However if I move the Jersey jar into the lib directory of the web service then the webapp starts up with the following error

INFO: validateJarFile(/Users/conrad/FWPServerJava/out/artifacts/FWPServerJava_war_exploded/WEB-INF/lib/grizzly-servlet-webserver-1.9.45.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Apr 15, 2013 7:41:23 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  org.fwp.service

But I am able to see the string "TEST WORKED" at the right url localhost:8080/fwp/test



In the dependenies for the module I have the Jersey jar set to 'compile' scope.

Can anybody help? This is the standard setup that IntelliJ created when I made the project.

Conrad
2 comments

Anybody? I really could do with help fixing this issue.

0

Hello,

It looks like grizzly-servlet-webserver-1.9.45.jar is not a part of Jersey -- I can't see a grizzly jar in jersey-archive-1.17.zip and also it's not among ones to be included into <artifact>/WEB-INF/lib according to tutortials (for instance - http://mworking.blogspot.com/2012/01/configuring-tomcat-7-as-jax-rs-server.html).

So, I suspect you shouldn't include a grizzly-*.jar into the artifact. Do you have specific reasons to included the jar? Can you please try without it?

Regards,
Michael
0

Please sign in to leave a comment.