Reputation: 5825
I am trying to get a very simple Jersey web service to run on Weblogic 12.2.1.x but I am failing miserably
In my web.xml
I have the following
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<display-name>jersey1test</display-name>
<servlet>
<servlet-name>ServletAdaptor</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>com.jersey1test</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/srv/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
And the webservice resource itself is very simple
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("jersey1test")
public class Jersey1Resource
{
@Path("hello")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response helloJersey()
{
return Response.status(Response.Status.OK).entity("Hello from Jersey 1").build();
}
}
And I have exclusively jersey 1.13 dependecies in my pom
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
And as suggested on this oracle page I have the following in my weblogic.xml deployed with my war
<wls:container-descriptor>
<wls:prefer-application-packages>
<!— jersey-bundle-*.jar->
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
<wls:package-name>com.sun.ws.rs.ext.*</package-name>
<!— Jackson-*.jar ->
<wls:package-name>org.codehaus.jackson.*</wls:package-name>
<!— jettison-*.jar ->
<wls:package-name>org.codehaus.jettison.*</wls:package-name>
<!— jsr311*.jar ->
<wls:package-name>javax.ws.rs.*</wls:package-name>
<!— asm.jar ->
<wls:package-name>org.objectweb.asm.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
The war deploys fine but when trying to access the webservice I just receive a not found response (the same URI btw works when this is deployed to weblogic 12.1.3 or Glassfish 3/4)
One thing I have noticed is I see the following in the server logs (I can't see any exceptions)
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192509> <Changing servlet class from com.sun.jersey.spi.container.servlet.ServletContainer (web.xml) to org.glassfish.jersey.servlet.ServletContainer.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.ResourceConfig because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.ApplicationAdapter because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.server.impl.application.DeferredResourceConfig because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.ClassNamesResourceConfig because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.DefaultResourceConfig because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.PackagesResourceConfig because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.servlet.WebAppResourceConfig because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.ClasspathResourceConfig because ApplicationPath annotation is not set on it.>
<15-Jul-2016 08:39:55 o'clock BST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class com.sun.jersey.api.core.ScanningResourceConfig because ApplicationPath annotation is not set on it.>
Which to me seems to suggest it's ignoring what I've set in my weblogic.xml
. What am I doing wrong? Is it possible to have a jersey 1 web service working in weblogic 12.2.1.x?
Upvotes: 2
Views: 4622
Reputation: 5443
It looks like there is a compatibility issue with 12.2.1.x.
You have the option of downgrading your version of WebLogic, or upgrading to Jersey 2 (why aren't you using Jersey 2 by the way?)
https://community.oracle.com/thread/3923266?start=0&tstart=0
Upvotes: 3