欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jboss4.2中web service的wsconsume工具测试客户端调用问题

程序员文章站 2022-03-08 08:17:25
...

这两天自己练习jboss4.2GA里的web service例子,注解的形式发布web service挺简单,但每个类,都要写一个servlet在web.xml文件里维护起来不烦吗?

坑爹的是最后写测试类调用web service时老是报如下错误:

Exception in thread "main" javax.xml.ws.WebServiceException: Unable to load Provider: Failed to load javax.xml.ws.spi.Provider: com.sun.xml.ws.spi.ProviderImpl
	at javax.xml.ws.spi.Provider.provider(Provider.java:90)
	at javax.xml.ws.Service.<init>(Service.java:81)
	at ws.ConveterService.<init>(ConveterService.java:40)
	at org.study.ws.ConveterTest.main(ConveterTest.java:22)
Caused by: java.lang.IllegalStateException: Failed to load javax.xml.ws.spi.Provider: com.sun.xml.ws.spi.ProviderImpl
	at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:96)
	at javax.xml.ws.spi.Provider.provider(Provider.java:82)
	... 3 more
Caused by: java.lang.ExceptionInInitializerError
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
	at java.lang.Class.newInstance0(Class.java:350)
	at java.lang.Class.newInstance(Class.java:303)
	at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:91)
	... 4 more
Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext for W3CEndpointReference. 
	at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:188)
	at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:65)
	... 11 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "address". Use @XmlType.name and @XmlType.namespace to assign different names to them.
	this problem is related to the following location:
		at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address
		at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address com.sun.xml.ws.developer.MemberSubmissionEndpointReference.addr
		at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
	this problem is related to the following location:
		at javax.xml.ws.wsaddressing.W3CEndpointReference$Address
		at private javax.xml.ws.wsaddressing.W3CEndpointReference$Address javax.xml.ws.wsaddressing.W3CEndpointReference.address
		at javax.xml.ws.wsaddressing.W3CEndpointReference
Two classes have the same XML type name "elements". Use @XmlType.name and @XmlType.namespace to assign different names to them.
	this problem is related to the following location:
		at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
		at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties
		at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
	this problem is related to the following location:
		at javax.xml.ws.wsaddressing.W3CEndpointReference$Elements
		at private javax.xml.ws.wsaddressing.W3CEndpointReference$Elements javax.xml.ws.wsaddressing.W3CEndpointReference.referenceParameters
		at javax.xml.ws.wsaddressing.W3CEndpointReference

	at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:438)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:286)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:211)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:372)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
	at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:186)
	... 12 more

 昨晚到今天早上一直被这问题困扰,后来还是jboss的论坛上找到了答案:

写道
Try to remove following jar files from your clients class path - jaxws-rt.jar
jaxws-tools.jar. This happended to me. Please try this. It might work.


---------------------------------------------------------------------------------------

Yes, it's a classpath problem. The JAX-WS provider is accessed by a Jar service loader. Depending on which jar is in the classpath it either loads the Jbossws one or the Sun RI one: com.sun.xml.ws.spi.ProviderImpl.

It's the two jars pramod_bs described. They only needed for the wsconsume and wsprovide tools, but shouldn't be on the client classpath.

 原来是jar包冲突啊,client目录下的jaxws-rt.jar jaxws-tools.jar只是给wsconsume wsprovide工具用的,不需要在测试时放到类路径里面。jboss4.2中web service的wsconsume工具测试客户端调用问题
            
    
    博客分类: Java  jboss4.2中web service的wsconsume工具测试客户端调用问题
            
    
    博客分类: Java  jboss4.2中web service的wsconsume工具测试客户端调用问题
            
    
    博客分类: Java  

 

这么篇抱怨的文章竟然还有人看那,那就接着再吐槽会。

我自己用的eclipse是最新的java ee Juno Service Release 1版,练习web service是因为在用jboss跑EJB3.0的例子。友情提醒各位,用jboss时一定要选好jboss的版本,否则这些坑爹的乱七八糟、奇奇怪怪的问题会不断骚扰你,jboss产品的版本控制太神奇了,不向前兼容,举个例子,4.0版本有的问题,4.2版本没了,但在5.0中竟然又出现了,就没个统一规划吗?

根据之前网上了解到的经验,个人推荐4.2GA版本做练习,貌似这个反馈的问题较其它版本而言好那么一点点。