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.
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
javax.xml.ws.spi.Provider: Provider weblogic.wsee.jaxws.spi.WLSProvider not a subtype
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.<init>(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]
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 -
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
</dependency>
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 prefer-web-inf-classes = true
as shown below in application's weblogic.xml-
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app>
<context-root>/app1</context-root>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
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.
BUT 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.
So now there are two ways for me to get it working.
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.
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.
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 META-INF/weblogic-application.xml (tested with full dependencies and prefer-web-inf-classes = true)-
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
<package-name>javax.xml.ws.*</package-name>
<package-name>javax.xml.bind.*</package-name>
<package-name>javax.xml.soap.*</package-name>
<package-name>com.sun.xml.*</package-name>
</prefer-application-packages>
</weblogic-application>
This is also not working.
I also tried putting javax.xml.ws.spi.Provider file in META-INF/services with value com.sun.xml.ws.spi.ProviderImpl but this is also not working (tested with full dependencies and prefer-web-inf-classes = true)
After these many approaches I dont have any other approach in my mind and I am now clueless.
Following is my pom.xml -
<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">
<modelVersion>4.0.0</modelVersion>
<artifactId>sample.webservice</artifactId>
<packaging>war</packaging>
<name>CounterWebApp_1.0</name>
<version>CounterWebApp_1.0</version>
<groupId>com.sample</groupId>
<build>
<plugins>
<plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId>
<version>2.3.11</version> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase>
<configuration> <sourceRoot>${project.build.directory}/gen/cxf</sourceRoot> <wsdlOptions>
<wsdlOption> <wsdl>${basedir}/src/main/resources/wbfxrProvider.wsdl</wsdl> </wsdlOption>
</wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution>
</executions> </plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>CounterWeb</warName>
<warSourceExcludes>
WEB-INF/lib/*.jar
</warSourceExcludes>
<archive>
<manifestEntries>
<DisableIBMJAXWSEngine>true</DisableIBMJAXWSEngine>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<!-- Dependency definitions -->
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1-b01</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<!-- Spring Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<!-- Apache CXF dependencies -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3.23</version>
</dependency>
<dependency>
<groupId>org.jvnet.staxex</groupId>
<artifactId>stax-ex</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
</project>
I am using the cxf library's api to generate java stubs from the wsdl of the webservice which I want to invoke.
My system's installed jdk is 1.7 and weblogic is 12.1.3
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.
In anticipation of a response