5

Currently we have developed a jersey 2.0 restful application with the following frameworks:

  • jaxrs-ri (2.25.1)
  • spring4 (4.3.10)
  • jersey-spring3 (2.25.1)

The application works perfectly in tomcat 8.5 & Weblogic 12.1.x servers

However, we got the following error when we tried to deploy it to Weblogic 12.2.1.3

<Oct 6, 2017 10:32:23,020 AM HKT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "214569275552728" for task "1" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: org.glassfish.jersey.internal.ServiceConfigurationError: org.glassfish.jersey.server.spi.ComponentProvider: The class org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider implementing the provider interface org.glassfish.jersey.server.spi.ComponentProvider is not found. The provider implementation is ignored."
weblogic.application.ModuleException: org.glassfish.jersey.internal.ServiceConfigurationError: org.glassfish.jersey.server.spi.ComponentProvider: The class org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider implementing the provider interface org.glassfish.jersey.server.spi.ComponentProvider is not found. The provider implementation is ignored.
        at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
        Truncated. see log file for complete stacktrace
Caused By: org.glassfish.jersey.internal.ServiceConfigurationError: org.glassfish.jersey.server.spi.ComponentProvider: The class org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider implementing the provider interface org.glassfish.jersey.server.spi.ComponentProvider is not found. The provider implementation is ignored.
        at org.glassfish.jersey.internal.ServiceFinder.fail(ServiceFinder.java:433)
        at org.glassfish.jersey.internal.ServiceFinder.access$300(ServiceFinder.java:155)
        at org.glassfish.jersey.internal.ServiceFinder$LazyObjectIterator.handleClassNotFoundException(ServiceFinder.java:806)
        at org.glassfish.jersey.internal.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:757)
        at org.glassfish.jersey.server.ApplicationHandler.getRankedComponentProviders(ApplicationHandler.java:743)
        Truncated. see log file for complete stacktrace
>

As we don't use any CDI implementation (HK2 & Spring's DI are used), we then tried to add the beans.xml under the WEB-INFO folder and let the server don't scan our application.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="none" >
</beans>

and we also tried to Disabling Implicit Bean Discovery in our Weblogic.

All attempts still cannot solve the error. Please kindly help.

Updates 1

We tried to create a empty services folder (Don't why it is needed, can anyone please explain.) under the META-INF and add the following in the weblogic.xml

<prefer-application-resources>
    <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
    <resource-name>META-INF/services/javax.ws.rs.ext.RuntimeDelegate</resource-name>

    <!-- jersey  -->
    <resource-name>META-INF/services/org.glassfish.jersey.*</resource-name>
    <resource-name>org.glassfish.jersey.*</resource-name>
    <resource-name>jersey.repackaged.*</resource-name>

    <!-- hk2 -->
    <resource-name>META-INF/services/org.glassfish.hk2.*</resource-name>
</prefer-application-resources>

Now the application can run properly with its own jersey 2.25.1 library instead of Weblogic 12.2 pre-built libs (2.21.x). However, there is another WARN message appear, not sure if it is an issue..

<BEA-2192510> <Cannot add Jersey servlet for application class org.glassfish.jersey.server.ResourceConfig because ApplicationPath annotation is not set on it.>

The @ApplicationPath is already set

@ApplicationPath("/api")
public class MyResourceConfig extends ResourceConfig {
    public MyResourceConfig() {

        register(JacksonFeature.class);
        ...

    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Cube
  • 95
  • 2
  • 11
  • Try removing all jersey jars from your deployment. It does not need them on Glassfish and they will create conflicts. – Steve C Oct 06 '17 at 08:17
  • It works if we remove all jersey related jars. However, we may need to use latest jersey version instead of the Weblogic's shared libs. – Cube Oct 06 '17 at 08:31
  • 1
    Well, that's what you have to put up with on the WebLogic boat. Complain to your vendor... – Steve C Oct 06 '17 at 08:50

0 Answers0