在weblogic 12.1.2.0.0上部署ApacheCXF

时间:2017-08-08 08:59:27

标签: java deployment weblogic cxf weblogic12c

我尝试在weblogic服务器上部署使用spring + apache cxf的应用程序。 我不断收到此错误消息:

  

javax.servlet.ServletException:Servlet类:   org.apache.cxf.transport.servlet.CXFServlet'没有实现   javax.servlet.Servlet at   weblogic.servlet.internal.StubSecurityHelper $ ServletInitAction.run(StubSecurityHelper.java:330)     在   weblogic.servlet.internal.StubSecurityHelper $ ServletInitAction.run(StubSecurityHelper.java:288)     在   weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)     在   weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)     在   weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)     在   weblogic.servlet.internal.StubSecurityHelper.initServletInstance(StubSecurityHelper.java:98)     在   weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:86)     在   weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:74)     在   weblogic.servlet.internal.StubLifecycleHelper。(StubLifecycleHelper.java:60)     在   weblogic.servlet.internal.StubLifecycleHelper。(StubLifecycleHelper.java:34)     在   weblogic.servlet.internal.ServletStubImpl.initStubLifecycleHelper(ServletStubImpl.java:652)     在   weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:593)     在   weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1924)     在   weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1901)     在   weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1791)     在   weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2807)     在   weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)     在   weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:822)     在   weblogic.application.internal.ExtensibleModuleWrapper $ StartStateChange.next(ExtensibleModuleWrapper.java:360)     在   weblogic.application.internal.ExtensibleModuleWrapper $ StartStateChange.next(ExtensibleModuleWrapper.java:356)     在   weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)     在   weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)

在我的web.xml中:

 <servlet>
        <description>Apache CXF Endpoint</description>
        <display-name>cxf</display-name>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
  <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/ksas4/*</url-pattern>
    </servlet-mapping>

weblogic.xml中:

<?xml version="1.0" encoding="UTF-8" ?>
<weblogic-web-app
        xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
        http://http://www.oracle.com/technology/weblogic/weblogic-web-app/1.1/weblogic-web-app.xsd">


    <container-descriptor>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>
</weblogic-web-app>

和我的weblogic-application.xml:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application">

  <application-param>
    <param-name>webapp.encoding.default</param-name>
    <param-value>UTF-8</param-value>
  </application-param>

  <prefer-application-packages>
    <package-name>com.ctc.wstx.*</package-name>
    <package-name>javax.jws.*</package-name>
    <package-name>com.sun.xml.*</package-name>
    <package-name>javax.xml.bind.*</package-name>
    <package-name>org.slf4j.*</package-name>
    <package-name>ch.qos.logback.*</package-name>

    <!--<package-name>org.apache.cxf.*</package-name>-->
    <package-name>org.apache.xml.security.*</package-name>
    <package-name>antlr.*</package-name>
    <package-name>com.google.common.*</package-name>
    <package-name>com.sun.istack.*</package-name>
    <package-name>javax.annotation.*</package-name>
    <package-name>javax.annotation.security.*</package-name>
    <package-name>javax.annotation.sql.*</package-name>
    <package-name>javax.mail.*</package-name>
    <package-name>javax.mail.event.*</package-name>
    <package-name>javax.mail.internet.*</package-name>
    <package-name>javax.mail.search.*</package-name>
    <package-name>javax.mail.util.*</package-name>
    <package-name>javax.servlet.*</package-name>
    <package-name>javax.servlet.annotation.*</package-name>
    <package-name>javax.servlet.descriptor.*</package-name>
    <package-name>javax.servlet.http.*</package-name>
    <package-name>javax.wsdl.*</package-name>
    <package-name>javax.wsdl.extensions.*</package-name>
    <package-name>javax.wsdl.factory.*</package-name>
    <package-name>javax.wsdl.xml.*</package-name>
    <package-name>javax.xml.stream.*</package-name>
    <!--<package-name>javax.xml.ws.*</package-name>-->
    <package-name>org.bouncycastle.*</package-name>
    <package-name>org.bouncycastle.*</package-name>
    <package-name>org.bouncycastle.asn1.*</package-name>
    <package-name>org.bouncycastle.crypto.*</package-name>
    <package-name>org.bouncycastle.i18n.*</package-name>
    <package-name>org.bouncycastle.jce.*</package-name>
    <package-name>org.bouncycastle.math.*</package-name>
    <package-name>org.bouncycastle.util.*</package-name>
    <package-name>org.bouncycastle.x509.*</package-name>
    <package-name>org.codehaus.stax2.*</package-name>
    <package-name>org.joda.time.*</package-name>
    <package-name>org.jvnet.fastinfoset.*</package-name>
    <package-name>org.objectweb.asm.*</package-name>
    <package-name>org.opensaml.soap.*</package-name>
  </prefer-application-packages>

</weblogic-application>

我使用this添加了所需的包,然后在weblogic上运行了分析工具,告诉我要添加休息。

在glassfish上一切正常,所以应用程序本身应该没问题。 CXFServlet确实实现了Servlet(它扩展了GenericServlet)。

编辑: 如果我不使用weblogic-application.xml,它会被部署,但我会继续

 o.a.c.p.PhaseInterceptorChain - Interceptor for {xxx}zzz
has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
        at org.apache.cxf.binding.soap.saaj.SAAJInInterceptor$SAAJPreInInterceptor.handleMessage(SAA
JInInterceptor.java:146) ~[cxf-rt-bindings-soap-3.1.4.jar:3.1.4]
        at org.apache.cxf.binding.soap.saaj.SAAJInInterceptor$SAAJPreInInterceptor.handleMessage(SAA
JInInterceptor.java:108) ~[cxf-rt-bindings-soap-3.1.4.jar:3.1.4]
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) ~[
cxf-core-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:1
21) [cxf-core-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java
:251) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.ja
va:234) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [cx
f-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [cx
f-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)
 [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.ja
va:293) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:212)
 [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:751) [weblogic.server.merged.jar:
12.1.2.0.0]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268
) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.
java:280) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.
java:254) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136) [
weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341) [weblogic.ser
ver.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:238) [weblogic.ser
ver.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServ
letContext.java:3363) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletC
ontext.java:3333) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) [
weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) [com.oracle.css
.weblogic.security.wls_7.0.0.0.jar:CSS 7.0 0.0]
        at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) [weblogic.server
.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java
:2220) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2
146) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124) [w
eblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564) [weblogic.
server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSu
pportProviderImpl.java:254) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295) [weblogic.server.merged.jar:1
2.1.2.0.0]
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:254) [weblogic.server.merged.jar:12.1.
2.0.0]
Caused by: javax.xml.soap.SOAPException: Unable to create message factory for SOAP: oracle.j2ee.ws.s
aaj.soap.MessageFactoryImpl cannot be cast to javax.xml.soap.MessageFactory
        at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:125) ~[saaj-api-1.3.4.jar:1
.7.0_67]
        at org.apache.cxf.binding.soap.saaj.SAAJFactoryResolver.createMessageFactory(SAAJFactoryReso
lver.java:62) ~[cxf-rt-bindings-soap-3.1.4.jar:3.1.4]
        at org.apache.cxf.binding.soap.saaj.SAAJInInterceptor$SAAJPreInInterceptor.getFactory(SAAJIn
Interceptor.java:158) ~[cxf-rt-bindings-soap-3.1.4.jar:3.1.4]
        at org.apache.cxf.binding.soap.saaj.SAAJInInterceptor$SAAJPreInInterceptor.handleMessage(SAA
JInInterceptor.java:134) ~[cxf-rt-bindings-soap-3.1.4.jar:3.1.4]
        ... 29 common frames omitted
08:09:22.195 [[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN
 o.a.c.p.PhaseInterceptorChain - Interceptor for {xxx}zzz
has thrown exception, unwinding now
java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:454) ~[na:1.7.0_67]
        at java.lang.Integer.valueOf(Integer.java:582) ~[na:1.7.0_67]
        at webservice.interceptors.FaultOutInterceptor.handleMessage(FaultOutInterceptor.java:56) ~[
_wl_cls_gen.jar:na]
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [c
xf-core-3.1.4.jar:3.1.4]
        at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultCha
inInitiatorObserver.java:112) [cxf-core-3.1.4.jar:3.1.4]
        at org.apache.cxf.phase.PhaseInterceptorChain.wrapExceptionAsFault(PhaseInterceptorChain.jav
a:366) [cxf-core-3.1.4.jar:3.1.4]
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:324) [c
xf-core-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:1
21) [cxf-core-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java
:251) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.ja
va:234) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [cx
f-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [cx
f-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)
 [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.ja
va:293) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:212)
 [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:751) [weblogic.server.merged.jar:
12.1.2.0.0]
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268
) [cxf-rt-transports-http-3.1.4.jar:3.1.4]
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.
java:280) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.
java:254) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136) [
weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341) [weblogic.ser
ver.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:238) [weblogic.ser
ver.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServ
letContext.java:3363) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletC
ontext.java:3333) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) [
weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) [com.oracle.css
.weblogic.security.wls_7.0.0.0.jar:CSS 7.0 0.0]
        at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) [weblogic.server
.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java
:2220) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2
146) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124) [w
eblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564) [weblogic.
server.merged.jar:12.1.2.0.0]
        at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSu
pportProviderImpl.java:254) [weblogic.server.merged.jar:12.1.2.0.0]
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295) [weblogic.server.merged.jar:1
2.1.2.0.0]
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:254) [weblogic.server.merged.jar:12.1.
2.0.0]

1 个答案:

答案 0 :(得分:0)

让它发挥作用。

是第一个问题
 <package-name>javax.servlet.*</package-name>
    <package-name>javax.servlet.annotation.*</package-name>
    <package-name>javax.servlet.descriptor.*</package-name>
    <package-name>javax.servlet.http.*</package-name>

导致

javax.servlet.ServletException: Servlet class: org.apache.cxf.transport.servlet.CXFServlet
 does not implement javax.servlet.Servlet

这让我想到了第二个问题:

 javax.xml.soap.SOAPException: Unable to create message factory for SOAP: oracle.j2ee.ws.s
aaj.soap.MessageFactoryImpl cannot be cast to javax.xml.soap.MessageFactory

解决这个问题我需要在我的POM中添加两个库

 <dependency>
      <groupId>com.sun.xml.messaging.saaj</groupId>
      <artifactId>saaj-impl</artifactId>
      <version>1.3.5</version>
    </dependency>
    <dependency>
      <groupId>javax.xml.soap</groupId>
      <artifactId>saaj-api</artifactId>
      <version>1.3.5</version>
    </dependency>

然后在weblogic-application.xml中添加

 <package-name>com.sun.xml.messaging.saaj.*</package-name>
 <package-name>javax.xml.soap.*</package-name>

现在它适用于weblogic和glassfish。