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).
Related
When I try to build my Enterprise Project in Netbeans with ant, i got this exception:
warning: Supported source version 'RELEASE_6' from annotation
processor
'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor'
less than -source '1.8'
Note: Creating static metadata factory ...
An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file
javax/persistence/PersistenceException
I only have some entityclasses in my ejb module.
This error is reported as a bug in NetBeans (with a resolved status as it turns out to be considered as a "user error"). Below is the main comment that explains the problem and gives the solution:
"ClassFormatError: Absent Code attribute in method..." is always indication that javaee-api-6.0.jar is used for runtime execution. The jar contains only method signatures (method bodies are stripped) and is suitable only for compilation. In future versions of javac there might be better error message.
The problem here is that javaee-api-6.0.jar is on classpath before EclipseLink jars and when EclipseLink annotation processor is started classes from javaee-api-6.0.jar are used instead of classes from EclipseLink. First thing is that javaee-api-6.0.jar should be removed from classpath of EJB project - it should not be needed as EJB project has an Application server selected and the project takes EE 6 APIs from that server.
As I understand the comment, you should try removing any reference to javaee-api-6.0.jar (which contains only "dummy" classes) from the classpath of the project, because the EclipseLink library should provide the correct classes used by the annotation processor.
Also, this question seems to tackle the same issue.
when you use the insert code and automatic bean creation it adds the Java EE 6
API library . I deleted the library and add the Java EE 7 API.
Websphere 8.0.0.11
Hibernate 4.2.21.Final
I have found many questions about this same problem but none of them worked for me.
If I deploy the application in Websphere it works OK.
However we have defined a shared library that contains all the third party libraries (spring, hibernate, javassist, etc) so that our WARs are thinner.
This way during deployment we associate our thin WAR against that Websphere shared library.
The point is that when we deploy the application this way the ClassCastException Hibernate exception _$$_javassist_856 cannot be cast to javassist.util.proxy.Proxy is thrown.
I have checked the loaded jars in the websphere console and can only see one javassist jar (3.18.1-GA) in the classpath.
Why could this be happening?
UPDATE
I have also tried using PARENT_FIRST and PARENT_LAST class loading.
UPDATE 2
I just found out that Websphere is loading its own javassist jar:
URL location = ProxyFactory.class.getProtectionDomain().getCodeSource().getLocation();
logger.info("{}", location);
It prints: file:/opt/IBM/WebSphere/AppServer/plugins/javassist.jar
After trying pretty much everything I found on S.O. without any success I decided to downgrade Hibernate to version 4.1.12.Final. This is the maximum 4.x version compatible with Websphere 8.x.
The problem is that Javassist leaves traces in its generated code. With Javassist on the class path twice, its classes are loaded twice. Two types are however only equal if they have the same name and are loaded by the same class loader. In your case, the generated class resolves its Javassist dependeny to a type that is loaded by your application class loader while your code is casting the instance to the Javassist type that is loaded by the Websphere class loader (or the other way around).
Are you sharing any Hibernate dependencies between applications? Try to not use any shared libraries related to Hibernate in your application to avoid this.
I have installed Weblogic 12.1.3 as part of upgrade from Weblogic 10.3.6 to Weblogic 12.1.3
My application uses Jersey version 1.17 jars
However, after we install Weblogic 12.1.3, we get Jersey 1.18 Jars inside folder ORACLE_HOME/oracle_common/modules
The Jersey 1.18 Jars override the Jersey 1.17 jars which are bundled in our application and causes error in deploying our application.
We get error/warning messages as give below
WARNING: Return type javax.xml.bind.JAXBElement of method public javax.xml.bind.JAXBElement com.ipc.dms.dsfs.service.rs.DSFSResource.getEnterpriseContacts(java.lang.String,java.lang.Integer,java.lang.Integer,java.lang.String) is not resolvable to a concrete type
WARNING: Return type javax.xml.bind.JAXBElement of method public javax.xml.bind.JAXBElement com.ipc.dms.dsfs.service.rs.DSFSResource.getMediaServiceConfigList(java.lang.String) is not resolvable to a concrete type
The application is using ServletContainerInitializer class com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer that is loaded from:file:/opt/oracle/oracle_common/modules/jersey-servlet-1.18.jar. This initializer overrides the one available in the system.
**********>
java.lang.NoClassDefFoundError: Could not initialize class org.jgroups.conf.XmlConfigurator
at org.jgroups.conf.ConfiguratorFactory.getXmlConfigurator(ConfiguratorFactory.java:216)
at org.jgroups.conf.ConfiguratorFactory.getStackConfigurator(ConfiguratorFactory.java:93)
at org.jgroups.JChannel.(JChannel.java:142)
If we remove the Jersey 1.18 Jars from ORACLE_HOME/oracle_common/modules we DO NOT get these error messages.
However, removing jars from installation folder causes other issues.To be specific I get the issue mentioned below if I remove the Jersey 1.18 jars from from ORACLE_HOME/oracle_common/modules
weblogic.kernel.Default (self-tuning)'> <> <> <> <1467281457661> < BEA-149231 > < Unable to set the activation state to true for the application "dunkin".
weblogic.application.ModuleException: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
So, I need to know if we can configure our EAR to use older version of Jersey i.e Jersey 1.17 while deploying the application on Weblogic 12.1.3.
If yes, please provide configuration details.
You have got 2 options:
To include the <prefer-application-packages> tag in the weblogic-application.xml of your ear as below:
<weblogic-application>
<prefer-application-packages>
<package-name>com.sun.jersey.*</package-name>
</prefer-application-packages>
</weblogic-application>
To inlcude the <wls:prefer-web-inf-classes> tag in the weblogic.xml of your war file as below:
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
If you decide to use option 2 then all the common libs of weblogic will be overidden by the libs of your application. So I would suggest to go with option 1.
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)
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