title: JaxWS ClassCastException on JBoss
body: <p>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:</p>
  
  <blockquote>
    <p>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)<br>
      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)  </p>
    
    <p>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)<br>
    [...]<br>
    ... 3 more Caused by: java.lang.ClassCastException   at
    java.lang.Class.cast(Class.java:2990)   at
    java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)<br>
    ... 14 more</p>
  </blockquote>
  
  <p>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:</p>
  
  <pre><code>activation.jar
  jaxb-api.jar
  jaxws-api.jar
  jbossws-native-factories.jar
  resolver.jar
  serializer.jar stax-api.jar
  xalan.jar
  xercesImpl.jar
  </code></pre>
  
  <p>I've also added the switch -verbose:class to the JVM: </p>
  
  <pre><code>[Loaded org.jboss.ws.core.jaxws.spi.ProviderImpl from jar:file:/Users/carlo/jboss-5.1.0.GA/common/lib/jbossws-native-core.jar!/]
  </code></pre>
  
  <p>and that class extends <code>javax.xml.ws.spi.Provider</code> (http://bit.ly/LK9bNE)</p>
  
  <p>Can someone help me what's going on here?</p>
  
  <p><strong>EDIT 1</strong><br>
  Ok, so I see that the ClassCastException is raised from: ServiceLoader.java line 345</p>
  
  <pre><code>S p = service.cast(Class.forName(cn, true, loader).newInstance());
  </code></pre>
  
  <p>when service.cast is called, <code>this</code> is <code>javax.xml.ws.spi.Provider</code> and the arg to cast  is <code>org.jboss.ws.core.jaxws.spi.ProviderImpl</code>.
  I still fail to understand the problem though.</p>