-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 
Author Message
 Post subject: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Thu Apr 08, 2010 5:44 pm 
Newbie

Joined: Tue Apr 06, 2010 2:11 pm
Posts: 2
I've been trying to setup my application to use Hibernate 3.5 Final realease as a JPA 2.0 implementation deploying to Weblogic 10.3.1, but I keep having classloading problems. First I got:


java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;


It obviously was a classloading problem, so I checked for other jars in weblogic lib and found that it has it's own javax.persistence jar (version 1.0). To avoid using weblogic's version of javax.persistence classes I defined a class-loading filter in weblogic-application.xml to enforce using the jar packaged in my EAR (hibernate-jpa-2.0-api-1.0.0.Final.jar).

Code:
<weblogic-application>
    <prefer-application-packages>
        <package-name>antlr.*</package-name>
        <package-name>javax.persistence.*</package-name>
    </prefer-application-packages>
</weblogic-application>


Now I'm getting a ClassCastException:


weblogic.management.DeploymentException:
at weblogic.application.internal.flow.JpaFlow.prepare(JpaFlow.java:59)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:141)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:187)
at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)
at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
weblogic.deployment.EnvironmentException: Error processing persitence unit ApplicationEntityManager of module midas-ear-1: Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit ApplicationEntityManager: java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider
at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:322)
at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:123)
at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:331)
at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptors(AbstractPersistenceUnitRegistry.java:111)
at weblogic.deployment.EarPersistenceUnitRegistry.<init>(EarPersistenceUnitRegistry.java:52)
at weblogic.application.internal.flow.JpaFlow.prepare(JpaFlow.java:54)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:141)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:187)
at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)
at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)


I thought that org.hibernate.ejb classes were having a similar problem, so I tried adding a similar filter in weblogic-application.xml with no success. I'm pretty sure that the jars loaded by weblogic are the ones in my EAR (hibernate-entitymanager-3.5.0-Final.jar and hibernate-jpa-2.0-api-1.0.0.Final.jar), I even tried removing each of them from my EAR and I got a ClassNotFoundException for org.hibernate.ejb.HibernatePersistence and javax.persistence.PersistenceProvider.

Any ideas would be greatly appreciated.


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Tue Jun 08, 2010 1:32 am 
Newbie

Joined: Tue Jun 08, 2010 1:29 am
Posts: 2
We are facing exactly same issue, and have been stuck with it since past 2 days. Were you able to resolve this? Any pointers are highly appreciated. Thanks


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Tue Jun 08, 2010 2:21 am 
Newbie

Joined: Tue Jun 08, 2010 2:17 am
Posts: 1
I have the same issue.

_________________
mafia wars secrets
make rap beats


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Wed Jul 07, 2010 5:14 am 
Newbie

Joined: Wed Jul 07, 2010 5:09 am
Posts: 1
Hi everyone,

same problem here. I've spent some days in order to solve this issue, but I've not succeeded. EclipseLink provided a helpful tutorial, but it didn't help either. So I've opened a thread within the EclipseLink forum as well as it seems like these guys did some research on this issue.

Kind regards
Oliver


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Tue Aug 03, 2010 8:26 pm 
Newbie

Joined: Tue Mar 24, 2009 1:57 pm
Posts: 2
Same issue here. Any news on this problem?

Regards,

Figura


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Fri Sep 10, 2010 2:02 pm 
Newbie

Joined: Fri Sep 10, 2010 1:58 pm
Posts: 2
Has anyone been able to solve the ClassCastException ? I am having the same problem.

Thanks.


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Sat Sep 11, 2010 4:25 am 
Newbie

Joined: Tue Aug 24, 2010 7:04 am
Posts: 14
I have not the same probleme but my experience told me that you only have to reverse the classloader. Normally every Application Server tries to resolve the classes first from the application server jars instead from the application so I believe you only have switch your classloader: http://www.rgagnon.com/javadetails/java-0551.html

Try it!

Kind regards
Michael


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Mon Sep 13, 2010 8:16 am 
Newbie

Joined: Fri Sep 10, 2010 1:58 pm
Posts: 2
michaeler wrote:
I have not the same probleme but my experience told me that you only have to reverse the classloader. Normally every Application Server tries to resolve the classes first from the application server jars instead from the application so I believe you only have switch your classloader: http://www.rgagnon.com/javadetails/java-0551.html

Try it!

Kind regards
Michael


Thanks Michael for the input. However, I have already implemented those recommendations and they resolved problems I was having and lead to the class cast exception that jacarrera posted in the first message in this thread.

Take care,

Cully.


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Mon Sep 13, 2010 2:43 pm 
Newbie

Joined: Tue Aug 24, 2010 7:04 am
Posts: 14
Hi,
I searched for a while and I found the following: http://forums.oracle.com/forums/thread. ... ID=1093616. <-- see the last answer!
I hope it helps a little bit.

Kind regards
Michael


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Mon May 16, 2011 3:17 am 
Newbie

Joined: Mon May 16, 2011 3:05 am
Posts: 1
Hi,

I am getting the same classcast exception in WebLogic 10.3.4. I have tried the same things - adding the hibernate libraries in the EAR lib directory and doing the filter to load from application. But still no use. If I remove the hibernate api jar, it is giving class not found error. Has anyone got a solution for this.

This is my persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd">

<persistence-unit name="MYUTIL" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/my_util_datasource</jta-data-source>
<properties>
<property name="hibernate.bytecode.provider" value="cglib" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>

</persistence>

weblogic-application.xml

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblog ... cation.xsd">
<!--weblogic-version:10.3.4-->
<wls:application-param>
<wls:param-name>webapp.encoding.default</wls:param-name>
<wls:param-value>UTF-8</wls:param-value>
</wls:application-param>
<wls:prefer-application-packages>
<wls:package-name>antlr.*</wls:package-name>
<wls:package-name>javax.persistence.*</wls:package-name>
<wls:package-name>javax.jws.*</wls:package-name>
<wls:package-name>org.apache.*</wls:package-name>
<wls:package-name>org.apache.commons.logging.*</wls:package-name>
</wls:prefer-application-packages>
</wls:weblogic-application>

I am unable to find any useful OTN forums as well for this. I am stuck with this for last 3 days.

Please help.

Thanks
Jay


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Tue May 17, 2011 6:56 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello all,
not nice. So this is the situation: Hibernate since 3.5 implements JPA2, so it expects the JPA2 API.
JPA2 is backwards compatible to JPA1, so it's expected that you should all be able to run your existing JPA1 application on a container which is providing a JPA2 service.

Now the case is that Weblogic 10.3.1 does not provide a JPA2 service, so it will try managing the persistence context with the classes it has, while it's possible to override the actual implementation of the service, it's not possible to override the API, so Weblogic is loading the JPA1 interface first; while I'm in no way a Weblogic expert, it seems to me you can hardly prevent that by tuning your deployment descriptors.

so as michaeler pointed out, you could "patch" weblogic as in
Code:
I searched for a while and I found the following: http://forums.oracle.com/forums/thread. ... ID=1093616. <-- see the last answer!
I hope it helps a little bit.

(thanks for that!)

An alternative, is that you manage to start the persistence context your self, managing it in the application. not nice but it could work; even more aggressive, use the Hibernate API and avoid the EntityManager; I'm not suggesting it but it's an option to consider.

other possibilities:
- some setting will need to change if you use pure application manager classloaders to ignore WL's jpa 1 classes
- somehow, one will have to tell WL to ignore all META-INF/persistence.xml (some specific setting as well if available)

Personally, I wouldn't to hack or workaround serious container limitations. JPA2 is not supported on that container, so you'd better upgrade to 10.3.4 which supports it, or just move to a JPA2 container such as Glassfish3 or JBoss6 which are already ready since some time.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Wed Aug 10, 2011 2:20 am 
Newbie

Joined: Wed Aug 10, 2011 2:13 am
Posts: 1
s.grinovero wrote:
Hello all,
not nice. So this is the situation: Hibernate since 3.5 implements JPA2, so it expects the JPA2 API.
JPA2 is backwards compatible to JPA1, so it's expected that you should all be able to run your existing JPA1 application on a container which is providing a JPA2 service.

Now the case is that Weblogic 10.3.1 does not provide a JPA2 service, so it will try managing the persistence context with the classes it has, while it's possible to override the actual implementation of the service, it's not possible to override the API, so Weblogic is loading the JPA1 interface first; while I'm in no way a Weblogic expert, it seems to me you can hardly prevent that by tuning your deployment descriptors.

so as michaeler pointed out, you could "patch" weblogic as in
Code:
I searched for a while and I found the following: http://forums.oracle.com/forums/thread. ... ID=1093616. <-- see the last answer!
I hope it helps a little bit.

(thanks for that!)

An alternative, is that you manage to start the persistence context your self, managing it in the application. not nice but it could work; even more aggressive, use the Hibernate API and avoid the EntityManager; I'm not suggesting it but it's an option to consider.

other possibilities:
- some setting will need to change if you use pure application manager classloaders to ignore WL's jpa 1 classes
- somehow, one will have to tell WL to ignore all META-INF/persistence.xml (some specific setting as well if available)

Personally, I wouldn't to hack or workaround serious container limitations. JPA2 is not supported on that container, so you'd better upgrade to 10.3.4 which supports it, or just move to a JPA2 container such as Glassfish3 or JBoss6 which are already ready since some time.


hi~ do u have some idea for this questions? hibernate 3.6.5 in weblogic 10.3 really doesn't work ?
u said " Now the case is that Weblogic 10.3.1 does not provide a JPA2 service "
but in which place i can find the official speaking~
please give me some advice~

thanks·~ thanks~~ 


Top
 Profile  
 
 Post subject: Re: ClassCastException with Hibernate 3.5 in Weblogic 10.3.1
PostPosted: Wed Aug 10, 2011 7:44 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
but in which place i can find the official speaking~

in the official documentation of course. There's no mention of JPA2 in that version: doesn't support it.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.