Reputation: 947
I've a application that is working fine when I deploy it on a tomcat server but got not working if deployed on weblogic.
Tomcat verison is: 7.0.47
Weblogic version is: 12.2.1.2.0
There is a simple rest endpoint that returns a JSON:
http://localhost:8080/MyApplication/rest/configuration/test
Works fine on tomcat, on weblogic I get only the string "Not Found".
In the log files the only warings I found are the following:
<Warning> <JAXRSIntegration> <MyApplication> <[ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <24ad6e0e-7bbc-4781-b294-f546069677ec-00000007> <1511013418859> <[severity-value: 16] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-2192510> <Cannot add Jersey servlet for application class org.glassfish.jersey.server.ResourceConfig because ApplicationPath annotation is not set on it.>
<Warning> <JAXRSIntegration> <MyApplication> <[ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <24ad6e0e-7bbc-4781-b294-f546069677ec-00000007> <1511013418860> <[severity-value: 16] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-2192510> <Cannot add Jersey servlet for application class org.glassfish.jersey.server.ResourceConfig$WrappingResourceConfig because ApplicationPath annotation is not set on it.>
<Warning> <JAXRSIntegration> <MyApplication> <[ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <24ad6e0e-7bbc-4781-b294-f546069677ec-00000007> <1511013418861> <[severity-value: 16] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-2192510> <Cannot add Jersey servlet for application class org.glassfish.jersey.server.ResourceConfig$RuntimeConfig because ApplicationPath annotation is not set on it.>
The EndPoint:
@Path("/configuration")
@NoCache
public class ConfigurationResource {
@GET
@Path("/test")
@Produces(MediaType.APPLICATION_JSON)
public Response getClientConfig() {
Map<String, Object> map = new HashMap<>();
map.put("test", "Test is running.");
return Response.ok(map).build();
}
...
}
public class MyApplication extends ResourceConfig {
public MyApplication() {
register(ConfigurationResource.class);
}
}
from the web.xml
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.sample.rest.MyApplication</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
weblogic.xml:
<weblogic-web-app>
<container-descriptor>
<prefer-application-packages>
<package-name>javax.ws.rs</package-name>
<package-name>javax.persistence</package-name>
<package-name>org.apache.commons</package-name>
<package-name>org.slf4j</package-name>
<package-name>org.apache.commons.logging</package-name>
</prefer-application-packages>
</container-descriptor>
</weblogic-web-app>
I already tried adding the annotation but without an effect.
Does have anybody any idea what I can do to get it working?
Upvotes: 1
Views: 6360
Reputation: 947
I found a solution for that problem after removing some lines form the weblogic.xml it worked:
weblogic.xml:
<weblogic-web-app>enter code here
<container-descriptor>
<prefer-application-packages>
<package-name>org.apache.commons</package-name>
<package-name>org.slf4j</package-name>
<package-name>org.apache.commons.logging</package-name>
</prefer-application-packages>
</container-descriptor>
</weblogic-web-app>
so I was removing:
<package-name>javax.ws.rs</package-name>
<package-name>javax.persistence</package-name>
this was the only thing. Unfortunately, there was no real hint what was the actual problem as I was finding no error/warning entries in any log files.
It seems that these packages are not compatible with the ones that are provided by the weblogic ones. I think it should also be checked if the according dependencies in the pom files are in scope 'provided'.
Upvotes: 2