title: Unable to deploy CXF3.x JAX-RS service in Weblogic 12c (12.2.1)
body: <p>After upgrading a JAX-RS service built with CXF3.x from weblogic 12.1.3 to 12.2.1 I am facing the following weird issue</p>
  <pre><code>&lt;03-ago-2017, 3:22:38,789 PM CEST&gt; &lt;Error&gt; &lt;HTTP&gt; &lt;BEA-101216&gt; &lt;Servlet: &quot;JAX-RS/Jersey#1&quot; failed to preload on startup in Web application: &quot;sife&quot;.
  A MultiException has 1 exceptions.  They are:
  1. java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
  
          at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1007)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:962)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1054)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1046)
          at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:696)
          Truncated. see log file for complete stacktrace
  </code></pre>
  <p>Note that I am using CXF, not Jersey, but seems Weblogic is trying to use it (it does not happen with 12.1.3). I disabled it in configuration files following this recommendations: <a href="https://jerometambo.github.io/blog/2016/12/13/How-to-use-CXF-3x-implementation-of-JAX-RS-20-REST-with-Weblogic-12c.html" rel="noreferrer">https://jerometambo.github.io/blog/2016/12/13/How-to-use-CXF-3x-implementation-of-JAX-RS-20-REST-with-Weblogic-12c.html</a></p>
  <blockquote>
  <p>With default configuration, Weblogic wants to use its internal implementation (JAX-RS 2.0 and serialization) to deploy the REST web services (Error 500):</p>
  </blockquote>
  <p><em><strong>META-INF/weblogic-application.xml</strong></em></p>
  <pre><code>&lt;weblogic-application  xmlns:wls=&quot;http://xmlns.oracle.com/weblogic/weblogic-application&quot;
                         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
                         xsi:schemaLocation=&quot;http://xmlns.oracle.com/weblogic/weblogic-application
                                             http://xmlns.oracle.com/weblogic/weblogic-application/1.8/weblogic-application.xsd&quot;&gt;
  
      &lt;prefer-application-packages&gt;
          &lt;package-name&gt;javax.ws.rs.*&lt;/package-name&gt;
          &lt;package-name&gt;com.fasterxml.jackson.*&lt;/package-name&gt;
          &lt;package-name&gt;weblogic.jaxrs.api.client.*&lt;/package-name&gt;
          &lt;package-name&gt;weblogic.jaxrs.internal.api.*&lt;/package-name&gt;
          &lt;package-name&gt;weblogic.jaxrs.dispatch.*&lt;/package-name&gt;
          &lt;package-name&gt;weblogic.jaxrs.monitoring.util.*&lt;/package-name&gt;
      &lt;/prefer-application-packages&gt;
  &lt;/weblogic-application&gt;
  </code></pre>
  <p><em><strong>WEB-INF/weblogic.xml</strong></em></p>
  <pre><code>&lt;weblogic-web-app 
      xmlns=&quot;http://xmlns.oracle.com/weblogic/weblogic-web-app&quot; 
      xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
      xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd&quot;&gt;
          
      &lt;container-descriptor&gt;
          &lt;prefer-application-packages&gt;
              &lt;package-name&gt;javax.ws.rs.*&lt;/package-name&gt;
              &lt;package-name&gt;com.fasterxml.jackson.*&lt;/package-name&gt; 
          &lt;/prefer-application-packages&gt;
      &lt;/container-descriptor&gt; 
  &lt;/weblogic-web-app&gt;
  </code></pre>
  <p>I do not know if this is a specific problem of my project or it is a weblogic issue. I have found similar issues like <a href="https://jerometambo.github.io/blog/2016/12/13/How-to-use-CXF-3x-implementation-of-JAX-RS-20-REST-with-Weblogic-12c.html" rel="noreferrer">this</a> and <a href="https://community.oracle.com/thread/3604562" rel="noreferrer">this</a>, and I tried to use them.</p>
  <p>These are my dependencies (IVY syntax)</p>
  <pre><code>&lt;dependency org=&quot;org.apache.cxf&quot; name=&quot;cxf-rt-frontend-jaxrs&quot; rev=&quot;3.1.10&quot; conf=&quot;default&quot; /&gt;
      &lt;dependency org=&quot;org.apache.cxf&quot; name=&quot;cxf-rt-rs-extension-providers&quot; rev=&quot;3.1.10&quot; conf=&quot;default&quot; /&gt;
      &lt;dependency org=&quot;org.apache.cxf&quot; name=&quot;cxf-rt-transports-http&quot; rev=&quot;3.1.10&quot; conf=&quot;default&quot; /&gt;
      &lt;dependency org=&quot;com.fasterxml.jackson.jaxrs&quot; name=&quot;jackson-jaxrs-json-provider&quot; rev=&quot;2.6.6&quot; conf=&quot;default&quot; /&gt;
  </code></pre>
  <p>And the full stack trace</p>
  <pre><code>&lt;03-ago-2017, 3:32:03,645 PM CEST&gt; &lt;Warning&gt; &lt;JAXRSIntegration&gt; &lt;BEA-2192510&gt; &lt;Cannot add Jersey servlet for application class org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet$ApplicationImpl because ApplicationPath annotation is not set on it.&gt;
  &lt;03-ago-2017, 3:32:03,737 PM CEST&gt; &lt;Warning&gt; &lt;JAXRSIntegration&gt; &lt;BEA-2192511&gt; &lt;The list of resource packages: com.fasterxml.jackson.jaxrs.base;org.apache.cxf.jaxrs.provider;com.fasterxml.jackson.jaxrs.json;org.apache.cxf.jaxrs.provider.aegis;es.aragon.sife.server.filter;org.apache.cxf.jaxrs.provider.jsrjsonp;es.aragon.sife.keystore.api;es.aragon.sife.server.account.api;org.apache.cxf.jaxrs.provider.xmlbeans;org.apache.cxf.jaxrs.validation;es.aragon.sife.server.task.api;org.apache.cxf.jaxrs.provider.json;org.apache.cxf.jaxrs.provider.atom;es.aragon.sife.server.config.api&gt;
  ago 03, 2017 3:32:16 PM es.gob.afirma.signers.xml.Utils installXmlDSigProvider
  &lt;03-ago-2017, 3:32:20,581 PM CEST&gt; &lt;Error&gt; &lt;HTTP&gt; &lt;BEA-101216&gt; &lt;Servlet: &quot;JAX-RS/Jersey#1&quot; failed to preload on startup in Web application: &quot;sife&quot;.
  A MultiException has 1 exceptions.  They are:
  1. java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
  
          at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1007)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:962)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1054)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1046)
          at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:696)
          Truncated. see log file for complete stacktrace
  Caused By: java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
          at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:146)
          at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
          at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179)
          at org.glassfish.jersey.media.sse.SseFeature.&lt;clinit&gt;(SseFeature.java:62)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          Truncated. see log file for complete stacktrace
  &gt;
  &lt;03-ago-2017, 3:32:20,696 PM CEST&gt; &lt;Error&gt; &lt;Deployer&gt; &lt;BEA-149231&gt; &lt;Unable to set the activation state to true for the application &quot;sife&quot;.
  weblogic.application.ModuleException: java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
          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: java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
          at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:146)
          at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
          at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179)
          at org.glassfish.jersey.media.sse.SseFeature.&lt;clinit&gt;(SseFeature.java:62)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          Truncated. see log file for complete stacktrace
  &gt;
  &lt;03-ago-2017, 3:32:20,762 PM CEST&gt; &lt;Notice&gt; &lt;Log Management&gt; &lt;BEA-170027&gt; &lt;The server has successfully established a connection with the Domain level Diagnostic Service.&gt;
  &lt;03-ago-2017, 3:32:20,931 PM CEST&gt; &lt;Notice&gt; &lt;WebLogicServer&gt; &lt;BEA-000365&gt; &lt;Server state changed to ADMIN.&gt;
  &lt;03-ago-2017, 3:32:21,46 PM CEST&gt; &lt;Notice&gt; &lt;WebLogicServer&gt; &lt;BEA-000365&gt; &lt;Server state changed to RESUMING.&gt;
  &lt;03-ago-2017, 3:32:21,174 PM CEST&gt; &lt;Notice&gt; &lt;WebLogicServer&gt; &lt;BEA-000360&gt; &lt;The server started in RUNNING mode.&gt;
  &lt;03-ago-2017, 3:32:21,186 PM CEST&gt; &lt;Notice&gt; &lt;WebLogicServer&gt; &lt;BEA-000365&gt; &lt;Server state changed to RUNNING.&gt;
  &lt;03-ago-2017, 3:32:22,710 PM CEST&gt; &lt;Error&gt; &lt;HTTP&gt; &lt;BEA-101216&gt; &lt;Servlet: &quot;weblogic.management.rest.Application&quot; failed to preload on startup in Web application: &quot;wls-management-services.war&quot;.
  A MultiException has 1 exceptions.  They are:
  1. java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
  
          at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1007)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:962)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1054)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1046)
          at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:696)
          Truncated. see log file for complete stacktrace
  Caused By: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1350)
          Truncated. see log file for complete stacktrace
  &gt;
  &lt;03-ago-2017, 3:32:22,747 PM CEST&gt; &lt;Error&gt; &lt;J2EE&gt; &lt;BEA-160001&gt; &lt;Error deploying Internal Application: weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
  weblogic.application.utils.StateChangeException: weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
          at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:58)
          at weblogic.application.services.BackgroundDeploymentManagerService$BackgroundDeployAction.run(BackgroundDeploymentManagerService.java:396)
          at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
          at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
          at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
          Truncated. see log file for complete stacktrace
  Caused By: weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
          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: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1350)
          Truncated. see log file for complete stacktrace
  </code></pre>
  <hr />
  <h1>WORKAROUND</h1>
  <p>It works if I deploy previously other CXF module using the default JAX-RS implementation and removing <code>WEB-INF/lib/javax.ws.rs-api-2.0.1.jar</code>. Maybe weblogic does some kind of internal initialization.</p>
  <pre><code> myapp.ear
     init.war (JAX-RS with CXF and removing javax.ws.rs-api-2.0.1.jar)
     myapp.war (JAX-RS with CXF and weblogic configuration)
  </code></pre>