JaxWS ClassCastException on JBoss

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

I'm using JBoss 5.1.0.GA (for JDK6), and jaxws 2.2.6. When I invoke the webservice, I get the following exception:

java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.jboss.ws.core.jaxws.spi.ProviderImpl could not be instantiated: java.lang.ClassCastException at org.jboss.resource.work.WorkWrapper.completed(WorkWrapper.java:283)
at org.jboss.util.threadpool.BasicTaskWrapper.taskCompleted(BasicTaskWrapper.java:367) at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:268) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680)

Caused by: java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.jboss.ws.core.jaxws.spi.ProviderImpl could not be instantiated: java.lang.ClassCastException at java.util.ServiceLoader.fail(ServiceLoader.java:207) at java.util.ServiceLoader.access$100(ServiceLoader.java:164) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353) at java.util.ServiceLoader$1.next(ServiceLoader.java:421) at javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Provider.java:180) at javax.xml.ws.spi.Provider.provider(Provider.java:140) at javax.xml.ws.Service.(Service.java:92)
[...]
... 3 more Caused by: java.lang.ClassCastException at java.lang.Class.cast(Class.java:2990) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)
... 14 more

I also tried to update jbossws to version 3.4.0 from 3.1.2.GA, nothing changed. I've read a lot of suggestions related to checking jars in lib/endorsed of JBoss, so this is the content:

activation.jar jaxb-api.jar jaxws-api.jar jbossws-native-factories.jar resolver.jar serializer.jar stax-api.jar xalan.jar xercesImpl.jar

I've also added the switch -verbose:class to the JVM:

[Loaded org.jboss.ws.core.jaxws.spi.ProviderImpl from jar:file:/Users/carlo/jboss-5.1.0.GA/common/lib/jbossws-native-core.jar!/]

and that class extends javax.xml.ws.spi.Provider (http://bit.ly/LK9bNE)

Can someone help me what's going on here?

EDIT 1
Ok, so I see that the ClassCastException is raised from: ServiceLoader.java line 345

S p = service.cast(Class.forName(cn, true, loader).newInstance());

when service.cast is called, this is javax.xml.ws.spi.Provider and the arg to cast is org.jboss.ws.core.jaxws.spi.ProviderImpl. I still fail to understand the problem though.

回答1:

Finally, I've managed to solve my problem: I put jaxws-rt.jar in $JBOSS_HOME/lib/endorsed.

EDIT
I had the same problem on JBoss 5.1 EAP, and to solve it, the steps are a little different: in $JBOSS_HOME/lib/endorsed I removed the old jaxb-api.jar, then copied

  • jaxb-api.jar
  • jaxb-impl.jar
  • jaxws-api.jar
  • jaxws-rt.jar

from the latest jaxws-ri package, and eventually it worked.



回答2:

I faced the same issue. I am running JBoss 5.1 EAP along with JDK 1.6_22.

I did things slightly different. I combined the solution by Carlo plus this solution.

I created an endorsed folder under $JBOSS_HOME/server//lib/endorsed. I then copied over streambuffer.jar, stax-ex.jar, policy.jar, jaxws-rt.jar, jaxws-api.jar, jaxb-impl.jar, jaxb-api.jar and gmbal-api-only.jar.

I left the $JBOSS_HOME/lib/endorsed alone.

Doing this, I was able to get it to work it all to work



回答3:

I had the same problem on JBoss 5.1 EAP Instead of putting jar files into JBOSS application server it is more robust when you alter class loading logic by isolating WAR with Overriding Server Classes (http://www.jboss.org/community/wiki/classloadingconfiguration) In my case I have 3 environments. With this solution I can move war file from one JBOSS instance to another and it will still work.

I resolved this problem by: Adding this to jboss-web.xml:

<class-loading java2ClassLoadingCompliance="false">     <loader-repository>         com.example:archive=unique-archive-name         <loader-repository-config>java2ParentDelegation=false</loader-repository-config>     </loader-repository> </class-loading>

...

and by adding requierd jars into war (jaxb-api.jar, jaxb-impl.jar, jaxws-api.jar, jaxws-rt.jar)



转载请标明出处:JaxWS ClassCastException on JBoss
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!