Weblogic 10.3.6和Spring Web Services ClassCastException

时间:2014-11-26 14:38:25

标签: spring web-services weblogic jax-ws

我正在尝试在weblogic 10.3.6中运行spring-ws,但我还没有实现运行它。 Pom spring-ws artifacts

    <dependency>
        <groupId>org.jvnet.jax-ws-commons.spring</groupId>
        <artifactId>jaxws-spring</artifactId>
        <version>1.9</version>
    </dependency>
    <!-- JAX-WS -->
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.8</version>
    </dependency>  

web.xml

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<listener>
    <listener-class> com.sun.xml.ws.transport.http.servlet.WSServletContextListener </listener-class>
</listener>  

web.xml中的servlet

<servlet>
    <servlet-name>jaxws-servlet</servlet-name>
    <servlet-class>
        com.sun.xml.ws.transport.http.servlet.WSSpringServlet
    </servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>jaxws-servlet</servlet-name>
    <url-pattern>/process</url-pattern>
</servlet-mapping>

sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
    version="2.0">
    <endpoint name="AuthenticatorWebService"
        implementation="com.company.ws.ProcessWSImpl"
        url-pattern="/process" />
</endpoints>

weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app.xsd">
    <context-root>/jobmonitor</context-root>
    <container-descriptor>
        <servlet-reload-check-secs>-1</servlet-reload-check-secs>
        <resource-reload-check-secs>-1</resource-reload-check-secs>
        <prefer-application-packages>
            <package-name>antlr.*</package-name>
            <package-name>javax.persistence.*</package-name>
            <package-name>org.apache.commons.*</package-name>
            <package-name>org.springframework.*</package-name>
            <package-name>org.hibernate.*</package-name>
            <package-name>org.stringtemplate.*</package-name>
            <package-name>org.antlr.*</package-name>
            <package-name>com.sun.xml.ws.*</package-name>
        </prefer-application-packages>
    </container-descriptor>
    <jsp-descriptor>
        <page-check-seconds>-1</page-check-seconds>
        <verbose>false</verbose>
    </jsp-descriptor>
</weblogic-web-app>  

我得到了以下类强制转换异常:

<Nov 26, 2014 3:45:44 PM EET> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sun.xml.ws.transport.http.servlet.SpringBinding#0' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Cannot create inner bean '(inner bean)' of type [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#45': FactoryBean threw exception on object creation; nested exception is com.sun.xml.ws.util.ServiceConfigurationError: com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension: Provider weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension is specified in jar:file:/weblogic/fmw1036/Middleware/wlserver_10.3/server/lib/weblogic.jar!/META-INF/services/com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtensionbut could not be instantiated: java.lang.ClassCastException: Cannot cast weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension to com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sun.xml.ws.transport.http.servlet.SpringBinding#0' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Cannot create inner bean '(inner bean)' of type [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#45': FactoryBean threw exception on object creation; nested exception is com.sun.xml.ws.util.ServiceConfigurationError: com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension: Provider weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension is specified in jar:file:/weblogic/fmw1036/Middleware/wlserver_10.3/server/lib/weblogic.jar!/META-INF/services/com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtensionbut could not be instantiated: java.lang.ClassCastException: Cannot cast weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension to com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:126)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#45': FactoryBean threw exception on object creation; nested exception is com.sun.xml.ws.util.ServiceConfigurationError: com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension: Provider weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension is specified in jar:file:/weblogic/fmw1036/Middleware/wlserver_10.3/server/lib/weblogic.jar!/META-INF/services/com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtensionbut could not be instantiated: java.lang.ClassCastException: Cannot cast weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension to com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:109)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:275)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:126)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
        Truncated. see log file for complete stacktrace
Caused By: com.sun.xml.ws.util.ServiceConfigurationError: com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension: Provider weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension is specified in jar:file:/weblogic/fmw1036/Middleware/wlserver_10.3/server/lib/weblogic.jar!/META-INF/services/com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtensionbut could not be instantiated: java.lang.ClassCastException: Cannot cast weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension to com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension
        at com.sun.xml.ws.util.ServiceFinder.fail(ServiceFinder.java:278)
        at com.sun.xml.ws.util.ServiceFinder.access$600(ServiceFinder.java:153)
        at com.sun.xml.ws.util.ServiceFinder$LazyIterator.next(ServiceFinder.java:527)
        at com.sun.xml.ws.util.ServiceFinder$CompositeIterator.next(ServiceFinder.java:422)
        at com.sun.xml.ws.util.ServiceFinder.toArray(ServiceFinder.java:270)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassCastException: Cannot cast weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension to com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension
        at java.lang.Class.cast(Class.java:3133)
        at com.sun.xml.ws.util.ServiceFinder$LazyIterator.next(ServiceFinder.java:523)
        at com.sun.xml.ws.util.ServiceFinder$CompositeIterator.next(ServiceFinder.java:422)
        at com.sun.xml.ws.util.ServiceFinder.toArray(ServiceFinder.java:270)
        at com.sun.xml.ws.server.EndpointFactory.generateWSDL(EndpointFactory.java:652)
        Truncated. see log file for complete stacktrace
>
Nov 26, 2014 3:45:45 PM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextDestroyed
INFO: WSSERVLET13: JAX-WS context listener destroyed
<Nov 26, 2014 3:45:45 PM EET> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application 'jobmonitor'.
weblogic.application.ModuleException:
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1522)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassCastException: Cannot cast weblogic.wsee.jaxws.framework.policy.WSDLGeneratorExtension to com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension
        at java.lang.Class.cast(Class.java:3133)
        at com.sun.xml.ws.util.ServiceFinder$LazyIterator.next(ServiceFinder.java:523)
        at com.sun.xml.ws.util.ServiceFinder$CompositeIterator.next(ServiceFinder.java:422)
        at com.sun.xml.ws.util.ServiceFinder.toArray(ServiceFinder.java:270)
        at com.sun.xml.ws.server.EndpointFactory.generateWSDL(EndpointFactory.java:652)
        Truncated. see log file for complete stacktrace

2 个答案:

答案 0 :(得分:2)

最好不要将它包含在你的战争/耳中,因为Weblogic带有JAX-WS RI堆栈(查看Weblogic安装的modules目录),我的是2.1.5,因此只提供编译时参考以避免覆盖它并打开classloader问题潘多拉盒子:

Pedometer

答案 1 :(得分:0)

版本,它工作。

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.1.7</version>
</dependency>

Check out oracle site