CXF+weblogic发布webservice
如题,myeclipse2014集成环境下面使用CXF3.1.5+Weblogic12.1.3+spring4发布ws服务,服务可以正常启动,但是使用soap测试时发现调用错误,但是在tomcat任何版本下面都可以调用成功,恳请大神赐教。个人觉得是配置问题,上代码和异常信息。
实现类
package com.test; import javax.jws.WebService; import org.springframework.stereotype.Component; @WebService() @Component public class HelloServiceImpl implements HelloService { public String say(String name) { return "hello " + name; } }
接口
package com.test; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; @WebService() public interface HelloService { @WebMethod String say(@WebParam(name="name" )String name); }web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>testCxf3_1_5</display-name> <!-- spring监听 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:config/spring/spring-servlet.xml</param-value> </context-param> <servlet> <servlet-name>cxf</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>cxf</servlet-name> <url-pattern>/ws/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>weblogic.xml
<?xml version="1.0" encoding="UTF-8"?> <wls:weblogic-web-app xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd"> <wls:weblogic-version>12.1.3</wls:weblogic-version> <container-descriptor> <prefer-web-inf-classes>false</prefer-web-inf-classes> <wls:prefer-application-packages> <wls:package-name>javax.jws.*</wls:package-name> <wls:package-name>com.ctc.wstx.*</wls:package-name> <wls:package-name>javax.wsdl.*</wls:package-name> <wls:package-name>org.apache.cxf.*</wls:package-name> </wls:prefer-application-packages> </container-descriptor> </wls:weblogic-web-app>spring-cxf.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <jaxws:endpoint id="helloService" implementor="#helloServiceImpl" address="/helloworld" /> </beans>异常信息:
三月 06, 2016 2:50:42 上午 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging 警告: Interceptor for {http://test.com/}HelloServiceImplService#{http://test.com/}say has thrown exception, unwinding now org.apache.cxf.interceptor.Fault at org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor.handleMessage(WrapperClassInInterceptor.java:167) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:253) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:298) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217) at javax.servlet.http.HttpServlet.service(HttpServlet.java:751) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:273) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572) at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311) at weblogic.work.ExecuteThread.run(ExecuteThread.java:263) Caused by: org.apache.cxf.interceptor.Fault at org.apache.cxf.databinding.AbstractWrapperHelper.getWrapperParts(AbstractWrapperHelper.java:146) at org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor.handleMessage(WrapperClassInInterceptor.java:134) ... 28 more Caused by: java.lang.NullPointerException at com.test.jaxws_asm.Say.getName(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.cxf.jaxb.JAXBWrapperHelper.getValue(JAXBWrapperHelper.java:61) at org.apache.cxf.databinding.AbstractWrapperHelper.getWrapperParts(AbstractWrapperHelper.java:132) ... 29 more <2016-3-6 上午02时50分42秒 CST> <Warning> <org.apache.cxf.phase.PhaseInterceptorChain> <BEA-000000> <Interceptor for {http://test.com/}HelloServiceImplService#{http://test.com/}say has thrown exception, unwinding now org.apache.cxf.interceptor.Fault at org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor.handleMessage(WrapperClassInInterceptor.java:167) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:253) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) Truncated. see log file for complete stacktrace Caused By: org.apache.cxf.interceptor.Fault at org.apache.cxf.databinding.AbstractWrapperHelper.getWrapperParts(AbstractWrapperHelper.java:146) at org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor.handleMessage(WrapperClassInInterceptor.java:134) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:253) Truncated. see log file for complete stacktrace Caused By: java.lang.NullPointerException at com.test.jaxws_asm.Say.getName(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) Truncated. see log file for complete stacktrace >求大神指点,急!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
楼主在吗,我也是部署 CXF + weblogic时报错,我的错误是
竟然有回帖,自己搞定了,主要是要配置weblogic的加载jar包顺序
<wls:weblogic-version>12.1.3</wls:weblogic-version>
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<wls:prefer-application-packages>
<wls:package-name>org.codehaus.stax2.*</wls:package-name>
<wls:package-name>org.objectweb.asm.*</wls:package-name>
<wls:package-name>javax.jws.*</wls:package-name>
<wls:package-name>com.ctc.wstx.*</wls:package-name>
<wls:package-name>javax.wsdl.*</wls:package-name>
<wls:package-name>org.apache.cxf.*</wls:package-name>
</wls:prefer-application-packages>
</container-descriptor>
看下包,是不是少包。
我也遇到这个问题了,麻烦问一下解决了吗?谢谢~