本文介绍了如何解决weblogic和应用程序之间的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序的jar和weblogic容器的jar之间的jar冲突中遇到问题,我正在寻求你的帮助。这是情况。

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.

我试图从另一个webservice中调用web服务,并且两个webservices都托管在我的本地weblogic服务器上。 Maven已被用作生成war文件的构建工具,它们部署在weblogic上。
当从webservice调用另一个web服务时,我收到此错误

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不是子类型

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]

我不知道这个如果我通过一个简单的java程序(使用main方法)调用此Web服务,则会出错。只有当我尝试通过weblogic上部署的代码调用时才会出现这种情况。我对此做了一些研究,发现它因为jar冲突。在我的pom.xml中,以下依赖项导致此错误 -

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>

在进一步的研究中我知道我们可以指定首选的jar文件来接收容器jar冲突的情况。这可以通过设置 prefer-web-inf-classes = true 来完成,如下面的应用程序的weblogic.xml-

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>

现在,如果我将上述属性设置为false,那么我的工作正常,我没有看到任何错误即使保留了上面提到的所有依赖项。

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.

但是如果我将此属性设置为true并且我不删除上述依赖项我收到错误。但是,如果将此属性设置为true,如果我删除了上面的依赖项,那么它可以正常工作。

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.

一,将prefer-web-inf-classes属性设置为false,而不进行任何其他更改。这导致其他问题,如日志记录无法正常工作,可能还有其他一些问题。
其次,将prefer-web-inf-classes属性设置为true并删除上面提到的依赖项。

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.

不幸的是,管理层都不接受这两种解决方案。我想要一个解决方案,其中prefer-web-inf-classes属性为true,并且不会删除任何依赖项。可能有一种方法可以强制weblogic在我的应用程序的类路径中选择jar而不是从容器的环境中选择。

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.

经过进一步的研究,我了解到了可以通过进行更改来指定容器从应用程序中挑选的首选包,如下所示 META-INF / weblogic-application.xml (使用完全依赖项进行测试,并使用prefer-web-inf-classes = true) -

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>

这也无效。

我还尝试将 javax.xml.ws.spi.Provider文件放在META-INF / services中,其值为com.sun.xml.ws.spi.ProviderImpl ,但这也无效(已完整测试)依赖关系和prefer-web-inf-classes = true)

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.

以下是我的pom.xml -

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>

我使用 cxf库的api从webservice的wsdl生成java存根我想调用。

我的系统安装 jdk是1.7,weblogic是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.

预期回复

推荐答案

@ user3264917我没有回答这个问题,但我想分享一下我的经验。早些时候,我在将weblogic从12.1.2升级到12.1.3时遇到了很大的困难。

@user3264917 I don't have answer to this question but I would like to share my experience. Earlier, I've badly struggled with the upgrade of weblogic from 12.1.2 to 12.1.3.

我曾经为hibernate-validator.jar得到类似的冲突jar错误。这个错误实际上误导了我的调查。实际原因是别的。新的weblogic 12.1.3开始为slf4j-logback提供内置支持。我的旧代码已经有了slf4j-logback jar。当我开始使用新weblogic支持的那些时,我的问题就解决了。

I used to get similar conflicting jar error for hibernate-validator.jar. This error was actually misguiding my investigation. Actual reason was something else. New weblogic 12.1.3 started giving inbuilt support for slf4j-logback. My old code already had slf4j-logback jars. When I started using the ones supported by new weblogic, my problem got solved.

在这里,我建议你做几件事。

Here, I would recommend you few things.


  1. 找出新weblogic支持的新罐子。

  2. 看看你是否可以管理新weblogic支持的罐子,而不是使用你自己的。

  3. 但是你可能有很好的pom.xml编写,不要在旧的webglic上构建并部署在新的webglic上。尝试新的weblogic上的所有内容。

这篇关于如何解决weblogic和应用程序之间的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 04:37