CXF+weblogic发布webservice

发布于 2021-12-08 00:25:18 字数 9443 浏览 982 评论 4

如题,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

回眸一笑 2021-12-09 17:34:18

楼主在吗,我也是部署 CXF + weblogic时报错,我的错误是

凌乱心跳 2021-12-09 16:05:18

竟然有回帖,自己搞定了,主要是要配置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>

伪装你 2021-12-09 15:46:38

看下包,是不是少包。

别低头,皇冠会掉 2021-12-08 04:51:43

我也遇到这个问题了,麻烦问一下解决了吗?谢谢~

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文