JaxWS ClassCastException on JBoss - java

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.

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.

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

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)

Related

Wildfly 20 Upgrade and OpenJRE 8 - Implementation of JAXB-API has not been found on module path or classpath

We are using openjre-8.0.252.09-hotspot, upgraded from Wildfly 10 to Wildfly 20, and started facing following issue, although:
jaxb-impl-2.1.13.jar is already present in WEB-INF\lib
rt.jar (in openjre) has: com.sun.xml.internal.bind.v2.ContextFactory
I have tried adding the following which did not work:
jaxb-api-2.1.jar to the lib.
used openjdk instead of openjre
Why is the application not able to find the com.sun.xml.internal.bind.v2.ContextFactory class which is already present in rt.jar ?
Is there something else that I am missing ?
I tried searching, but all the answers are related to java 9 and above, but no answers fro openjre-8.
Error:
Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory from [Module "deployment.myproject.war" from Service Module Loader]]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:155)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:141)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:314)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:478)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:435)
at org.apache.camel.spring.handler.CamelNamespaceHandler.createJaxbContext(CamelNamespaceHandler.java:187)
RootCause:
One of the jar in application's WebInf/lib had jaxb.properties which had following entry:
javax.xml.bind.context.factory=com.sun.xml.internal.bind.v2.ContextFactory
Removing this resolved the issue.

org.apache.cxf.bus.extension.ExtensionException in WAS9 server

Can you please help me with following error I'm facing in WAS9 environment:
In order to resolve the import
org.apache.cxf.binding.soap.SoapHeader
I added the following dependencies in my pom.xml:
cxf-api-2.7.7
cxf-rt-bindings-soap-2.7.7
But when I'm trying to run my application, I'm getting the following error.
Default Executor-thread-7] ([ ]) Controllerclass - org.apache.cxf.bus.extension.ExtensionException
at org.apache.cxf.bus.extension.Extension.load(Extension.java:222)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(ExtensionManagerImpl.java:199)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.initialize(ExtensionManagerImpl.java:118)
at org.apache.cxf.bus.extension.ExtensionManagerBus.doInitializeInternal(ExtensionManagerBus.java:147)
at org.apache.cxf.bus.CXFBusImpl.initialize(CXFBusImpl.java:191)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createBus(LibertyApplicationBusFactory.java:119)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createClientScopedBus(LibertyApplicationBusFactory.java:86)
at com.ibm.ws.jaxws.metadata.JaxWsClientMetaData.<init>(JaxWsClientMetaData.java:28)
at com.ibm.ws.jaxws.metadata.JaxWsModuleMetaData.getClientMetaData(JaxWsModuleMetaData.java:123)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:84)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:123)
at com.ibm.ws.jaxws.client.LibertyProviderImpl.createServiceDelegate(LibertyProviderImpl.java:56)
at javax.xml.ws.Service.<init>(Service.java:57)
Caused by: java.lang.InstantiationException:org.apache.cxf.bus.osgi.OSGIBusListener
at java.lang.Class.newInstance(Class.java:427)
at org.apache.cxf.bus.extension.Extension.load(Extension.java:218)
Caused by: java.lang.NoSuchMethodException:org.apache.cxf.bus.osgi.OSGIBusListener.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
The server where your WAS9 has been deployed has different version of the above jar file. You need to have same version of jar files both in your eclipse where you have developed your codes and the server where you are deploying the war or ear.
mavan dependency file pom.xml is used during your project compilation. It might add the jar in your binary under lib folder as well. But WAS9 might considering the one which is in server's CLASSPATH. Hence check your class path and replace that jar with the one which you have mentioned in your pom.xml file. Hope that will fix your issue.
We can eliminate this exception by adding webProfile-7.0 in our server.xml, but how ever this is not working with javaee-7.0 not sure, if one knows about how to handle this in javaee-7.0 please share your approach.

classloading in Wildfly 9

I am deploying my application to Wildfly 9 and I am getting a strange error that resembles class loading problems. The same war file deploys successfully to Tomcat so I am guessing Wildfly is bundling com.google classes and somehow it is interfering with the bundled libraries in the war file.
First, the error looks like this:
Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class com.google.inject.internal.Annotations$AnnotationChecker
at com.google.inject.internal.Annotations$AnnotationChecker.<init>(Annotations.java:104)
at com.google.inject.internal.Annotations.<clinit>(Annotations.java:122)
at com.google.inject.Key.ensureRetainedAtRuntime(Key.java:362)
at com.google.inject.Key.strategyFor(Key.java:354)
at com.google.inject.Key.get(Key.java:222)
at org.eclipse.sisu.wire.ParameterKeys.<clinit>(ParameterKeys.java:28)
at org.eclipse.sisu.wire.DependencyAnalyzer.<init>(DependencyAnalyzer.java:92)
at org.eclipse.sisu.wire.ElementAnalyzer.<init>(ElementAnalyzer.java:87)
at org.eclipse.sisu.wire.WireModule.configure(WireModule.java:74)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
at com.google.inject.spi.Elements.getElements(Elements.java:103)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:94)
at com.google.inject.Guice.createInjector(Guice.java:71)
at com.google.inject.Guice.createInjector(Guice.java:61)
and I have both guava-16.0.1.jar and sisu-guice-3.1.0-no_aop.jar inside my war file's lib folder.
so I basically need to solve this issue, whether it is a class loading issue or not.

ClassCastException with OpenJPA in Jboss 6.0

Jboss 6 comes with JPA 2.0 (hibernate-jpa-2.0-api.jar) and Hibernate 3.6.6 as the implementation.
I have a web application that has OpenJPA 2.0 library (openjpa-all-2.1.0.jar). I have set the classloader isolation in the jboss-web.xml as shown below
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
some.example:loader=some-webapp.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
When I deploy the application I get this error
ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=some.war#some state=Create: java.lang.ClassCastException: org.apache.openjpa.persistence.PersistenceProviderImpl cannot be cast to javax.persistence.spi.PersistenceProvider
This is strange since, org.apache.openjpa.persistence.PersistenceProviderImpl already implements javax.persistence.spi.PersistenceProvider
I did a -version:class to check where the javax.persistence.spi.PersistenceProvider is being loaded from and it appears that it's being loaded from the web application first and then from jboss6\common\lib
[Loaded javax.persistence.spi.PersistenceProviderResolverHolder$1 from vfs:/home/sathwik/apps/jboss-6.1.0.Final/server/default/deploy/some-webapp.war/WEB-INF/lib/openjpa-all-2.1.0.jar/]
[Loaded javax.persistence.spi.PersistenceProvider from vfs:/home/sathwik/apps/jboss-6.1.0.Final/common/lib/hibernate-jpa-2.0-api.jar/]
From the Manifest.mf file i was able to gather the JDK version used to compile
hibernate-jpa-2.0-api.jar is compiled with Build-Jdk: 1.5.0_19,
openjpa-all-2.1.0 is compiled with Build-Jdk: 1.6.0_22
Can anyone help me out in understanding why this exception?
According to the OpenJPA Dependencies page, the openjpa-all JAR file
[...] includes the OpenJPA core code plus all of the runtime dependencies for Java SE environments
You're not running in a JavaSE envrionment, you're in a full-blown JavaEE environment, which already has many of the ancillary API classes contained within the openjpa-all JAR. As a result, you're getting conflicts caused by loading classes of the same name, but from different classloaders.
You should replace openjpa-all with more specific JAR files (i.e. openjpa-2.1.0.jar and whatever others are necessary to make it work - see the above page).

Integrated ant - taskdef classloader issue

On Weblogic 10.3 my enterprise application includes a webservice that runs ant scripts inside. My problem is that I cannot get my custom tasks running due to java.lang.ClassNotFoundExceptions.
(All this works well on Tomcat 5.5)
My task implementation can be found in 4 different locations:
something.ear/APP-INF/lib/antaddon.jar!/foo/bar/MyTask.class
something.ear/Webservice.war/WEB-INF/lib/antaddon.jar!/foo/bar/MyTask.class
something.ear/Webservice.war/WEB-INF/classes/foo/bar/MyTask.class
server/lib/antaddon.jar!/foo/bar/MyTask.class
I see that the Weblogic 10.3 integrated Ant 1.6.5 module might cause problems
as I have an Ant 1.8.0 bundled, so I added
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.apache.ant.*</package-name>
<package-name>org.apache.zip.*</package-name>
</prefer-application-packages>
to my weblogic-application.xml to overcome this. (This solved some NoSuchMethodErrors..)
However my Task is still not found:
java.lang.ClassNotFoundException: foo.bar.MyTask.class
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
can you help me how to solve this?
The problem was that my prefer-application-packages directive was wrong, ant classes are not in org.apache.ant.* but in org.apache.tools.ant.*. After repairing this my custom class gets loaded and works well from APP-INF/lib/antaddon.jar

Categories

Resources