title: How to resolve conflict between jars of weblogic and application
body: <p>I am facing a problem in jar conflicts between my application's jars and weblogic container's jars for which I am seeking your help. Here is the situation. </p>
  
  <p>I am trying to call a webservice from inside another webservice and both the webservices are hosted on my local weblogic server. Maven has been used as build tool which generates war files and they are deployed on weblogic. 
  When invoking another webservice from a webservice, I am getting this error</p>
  
  <p><strong>javax.xml.ws.spi.Provider: Provider weblogic.wsee.jaxws.spi.WLSProvider not a subtype</strong> </p>
  
  <pre><code>org.apache.cxf.interceptor.Fault: javax.xml.ws.spi.Provider: Provider weblogic.wsee.jaxws.spi.WLSProvider not a subtype
          at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155) ~[cxf-rt-core-2.5.4.jar:2.5.4]
          at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:86) ~[cxf-rt-frontend-jaxws-2.5.4.jar:2.5.4]
          at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121) ~[cxf-rt-core-2.5.4.jar:2.5.4]
          at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:64) ~[cxf-rt-frontend-jaxws-2.5.4.jar:2.5.4]
          at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75) ~[cxf-rt-core-2.5.4.jar:2.5.4]
          at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) ~[cxf-rt-core-2.5.4.jar:2.5.4]
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[na:1.7.0_75]
          at java.util.concurrent.FutureTask.run(FutureTask.java:262) ~[na:1.7.0_75]
          at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) ~[cxf-rt-core-2.5.4.jar:2.5.4]
          at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107) ~[cxf-rt-core-2.5.4.jar:2.5.4]
          at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) ~[cxf-api-2.5.4.jar:2.5.4]
          at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123) [cxf-rt-core-2.5.4.jar:2.5.4]
          at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207) [cxf-rt-transports-http-2.5.4.jar:2.5.4]
          at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) [cxf-rt-transports-http-2.5.4.jar:2.5.4]
          at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:193) [cxf-rt-transports-http-2.5.4.jar:2.5.4]
          at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:128) [cxf-rt-transports-http-2.5.4.jar:2.5.4]
          at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185) [cxf-rt-transports-http-2.5.4.jar:2.5.4]
          at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108) [cxf-rt-transports-http-2.5.4.jar:2.5.4]
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:751) [weblogic.server.merged.jar:12.1.3.0.0]
          at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164) [cxf-rt-transports-http-2.5.4.jar:2.5.4]
          at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) [com.oracle.css.weblogic.security.wls_7.1.0.0.jar:CSS 7.1 0.0]
          at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311) [weblogic.server.merged.jar:12.1.3.0.0]
          at weblogic.work.ExecuteThread.run(ExecuteThread.java:263) [weblogic.server.merged.jar:12.1.3.0.0]
      **Caused by: java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider weblogic.wsee.jaxws.spi.WLSProvider not a subtype**
          at java.util.ServiceLoader.fail(ServiceLoader.java:231) ~[na:1.7.0_75]
          at java.util.ServiceLoader.access$300(ServiceLoader.java:181) ~[na:1.7.0_75]
          at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369) ~[na:1.7.0_75]
          at java.util.ServiceLoader$1.next(ServiceLoader.java:445) ~[na:1.7.0_75]
          at javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Provider.java:180) ~[jaxws-api-2.2.11.jar:na]
          at javax.xml.ws.spi.Provider.provider(Provider.java:140) ~[jaxws-api-2.2.11.jar:na]
          at javax.xml.ws.Service.&lt;init&gt;(Service.java:92) ~[jaxws-api-2.2.11.jar:na]
          at javax.xml.ws.Service.create(Service.java:722) ~[jaxws-api-2.2.11.jar:na]
          at com.zafinlabs.mirev.jewel.cibc.gen.fx.webservice.impl.ERDSFXManagementServiceImpl.callExternalWebService(ERDSFXManagementServiceImpl.java:249) ~[_wl_cls_gen.jar:na]
          at com.zafinlabs.mirev.jewel.cibc.gen.fx.webservice.impl.ERDSFXManagementServiceImpl.fillUpdateFXBulletinRatesResponse(ERDSFXManagementServiceImpl.java:214) ~[_wl_cls_gen.jar:na]
          at com.zafinlabs.mirev.jewel.cibc.gen.fx.webservice.impl.ERDSFXManagementServiceImpl.updateFXBulletinRates(ERDSFXManagementServiceImpl.java:122) ~[_wl_cls_gen.jar:na]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_75]
  </code></pre>
  
  <p>I don't get this error if I invoke this webservice through a simple java program (with main method). This comes only when I try to invoke through a code deployed on weblogic. I did some research on this and found that its because of jar conflicts. In my pom.xml following dependencies are causing this error - </p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;javax.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-api&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-rt&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-tools&lt;/artifactId&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>On further research I got to know that we can specify preferred jar files to be picked up the container in case of jar conflicts. This is done by setting the <code>prefer-web-inf-classes = true</code> as shown below in application's weblogic.xml- </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;weblogic-web-app&gt;
      &lt;context-root&gt;/app1&lt;/context-root&gt;
      &lt;container-descriptor&gt;
          &lt;prefer-web-inf-classes&gt;true&lt;/prefer-web-inf-classes&gt;
      &lt;/container-descriptor&gt;
  &lt;/weblogic-web-app&gt;
  </code></pre>
  
  <p>Now if I set the above property false, then I it works and I don't see any error even after keeping all the dependencies mentioned above.</p>
  
  <p><strong>BUT</strong> if I this property is set to true and I don't remove the above dependencies then I get error. However, with this property set to true, if I remove the above dependencies then it works without any error.</p>
  
  <p>So now there are two ways for me to get it working. </p>
  
  <p>One, set the prefer-web-inf-classes property to false without making any other change. This is causing other issues like logging is not working and may be couple of other issues.
  Second, set the prefer-web-inf-classes property to true and remove the above mentioned dependencies.</p>
  
  <p>Unfortunately both the solutions are not accepted by the management. I want a solution where the prefer-web-inf-classes property is true and also there is no removal of any dependencies. May be there is a way where we can force the weblogic to pick the jars in my application's classpath and not pick from the container's environment.</p>
  
  <p>Upon further research I learned that we can specify preferred packages to be picked from the application by the container by making changes as shown below in <strong>META-INF/weblogic-application.xml</strong> (tested with full dependencies and prefer-web-inf-classes = true)- </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;weblogic-application&gt;
    &lt;application-param&gt;
      &lt;param-name&gt;webapp.encoding.default&lt;/param-name&gt;
      &lt;param-value&gt;UTF-8&lt;/param-value&gt;
    &lt;/application-param&gt;
    &lt;prefer-application-packages&gt;
      &lt;package-name&gt;javax.jws.*&lt;/package-name&gt;
      &lt;package-name&gt;javax.xml.ws.*&lt;/package-name&gt;
      &lt;package-name&gt;javax.xml.bind.*&lt;/package-name&gt;
      &lt;package-name&gt;javax.xml.soap.*&lt;/package-name&gt;
      &lt;package-name&gt;com.sun.xml.*&lt;/package-name&gt;
    &lt;/prefer-application-packages&gt;
  &lt;/weblogic-application&gt;
  </code></pre>
  
  <p>This is also not working.</p>
  
  <p>I also tried putting  <strong>javax.xml.ws.spi.Provider file in META-INF/services with value com.sun.xml.ws.spi.ProviderImpl</strong> but this is also not working (tested with full dependencies and prefer-web-inf-classes = true)</p>
  
  <p>After these many approaches I dont have any other approach in my mind and I am now clueless. </p>
  
  <p>Following is my pom.xml -</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;   
      &lt;artifactId&gt;sample.webservice&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;CounterWebApp_1.0&lt;/name&gt;
      &lt;version&gt;CounterWebApp_1.0&lt;/version&gt;
      &lt;groupId&gt;com.sample&lt;/groupId&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
  
                  &lt;plugin&gt; &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt; &lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt; 
                  &lt;version&gt;2.3.11&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;generate-sources&lt;/id&gt; &lt;phase&gt;generate-sources&lt;/phase&gt; 
                  &lt;configuration&gt; &lt;sourceRoot&gt;${project.build.directory}/gen/cxf&lt;/sourceRoot&gt; &lt;wsdlOptions&gt; 
                  &lt;wsdlOption&gt; &lt;wsdl&gt;${basedir}/src/main/resources/wbfxrProvider.wsdl&lt;/wsdl&gt; &lt;/wsdlOption&gt; 
                  &lt;/wsdlOptions&gt; &lt;/configuration&gt; &lt;goals&gt; &lt;goal&gt;wsdl2java&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; 
                  &lt;/executions&gt; &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;warName&gt;CounterWeb&lt;/warName&gt;
                      &lt;warSourceExcludes&gt;
                          WEB-INF/lib/*.jar
                      &lt;/warSourceExcludes&gt;
                      &lt;archive&gt;
                          &lt;manifestEntries&gt;
                              &lt;DisableIBMJAXWSEngine&gt;true&lt;/DisableIBMJAXWSEngine&gt;
                          &lt;/manifestEntries&gt;
                          &lt;manifest&gt;
                              &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                              &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt;
                          &lt;/manifest&gt;
                      &lt;/archive&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.5.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
                  &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;8.1.5.v20120716&lt;/version&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;skip&gt;true&lt;/skip&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;!-- Dependency definitions --&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;version&gt;3.1-b01&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-collections&lt;/groupId&gt;
              &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
              &lt;version&gt;3.2.1&lt;/version&gt;
          &lt;/dependency&gt;
  
         &lt;!--   Spring Dependencies --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;4.1.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;4.1.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;4.1.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
         &lt;!--   Apache CXF dependencies --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-rt-frontend-jaxws&lt;/artifactId&gt;
              &lt;version&gt;2.5.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-rt-transports-http&lt;/artifactId&gt;
              &lt;version&gt;2.5.4&lt;/version&gt;
          &lt;/dependency&gt;        
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-api&lt;/artifactId&gt;
              &lt;version&gt;2.2.11&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-rt&lt;/artifactId&gt;
              &lt;version&gt;2.2.8&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-tools&lt;/artifactId&gt;
              &lt;version&gt;2.2.8&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.woodstox&lt;/groupId&gt;
              &lt;artifactId&gt;woodstox-core-asl&lt;/artifactId&gt;
              &lt;version&gt;4.4.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.messaging.saaj&lt;/groupId&gt;
              &lt;artifactId&gt;saaj-impl&lt;/artifactId&gt;
              &lt;version&gt;1.3.23&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jvnet.staxex&lt;/groupId&gt;
              &lt;artifactId&gt;stax-ex&lt;/artifactId&gt;
              &lt;version&gt;1.7.6&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
              &lt;version&gt;1.7.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;1.7.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-core&lt;/artifactId&gt;
              &lt;version&gt;1.1.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
               &lt;version&gt;1.1.2&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I am using the <strong>cxf library's api to generate java stubs from the wsdl of the webservice which I want to invoke.</strong> </p>
  
  <p>My system's installed <strong>jdk is 1.7 and weblogic is 12.1.3</strong></p>
  
  <p>Please suggest what else can I do or if I missed something in my earlier approaches. Please let me know if you need any further info.</p>
  
  <p>In anticipation of a response</p>