-->
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.  [ 7 posts ] 
Author Message
 Post subject: Problem using Hibernate JBOSS service
PostPosted: Mon May 03, 2004 7:30 am 
Newbie

Joined: Mon May 03, 2004 7:10 am
Posts: 4
Location: Bangalore, India
Hi,

I've configured Hibernate service for one of my J2EE application on JBOSS. My jboss-service.xml in the sar file looks like following:

<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
<depends>jboss.jca:service=RARDeployer</depends>
<attribute name="MapResources">com/edhand/example1/Order.hbm.xml,com/edhand/example1/Item.hbm.xml</attribute>
<attribute name="JndiName">java:/hibertest</attribute>
<attribute name="Datasource">java:/example1DS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.HSQLDialect</attribute>
<attribute name="UseOuterJoin">true</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
</mbean>

</server>

Hibernate is configured to use default UserTransaction of jboss. I'm getting the following exception at JTATransaction.begin() method:
java.lang.ClassCastException: org.jboss.tm.usertx.client.ServerVMClientUserTransaction
at net.sf.hibernate.transaction.JTATransaction.begin(JTATransaction.java:132)
at net.sf.hibernate.transaction.JTATransactionFactory.beginTransaction(JTATransactionFactory.java:58)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2195)
at com.edhand.example1.ItemService.addItem(Unknown Source)
at com.edhand.example1.ItemServicesEJB.addItem(ItemServicesEJB.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:297)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)

The return type of the begin() method is javax.transaction.UserTransaction

I've checked that the returned class org.jboss.tm.usertx.client.ServerVMClientUserTransaction implements javax.transaction.UserTransaction, hence is fully compatible with it. I'm at a loss to understand the reason for the ClassCastException. The class javax.transaction.UserTransaction is present in jboss-j2ee.jar and is loaded by the server.

Please help!!

Thanks,
Joydeep


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 03, 2004 7:35 am 
Newbie

Joined: Mon May 03, 2004 7:10 am
Posts: 4
Location: Bangalore, India
Sorry, there was one mistake. javax.transaction.Transaction is the return type cast of initialcontext.lookup("UserTransaction") in the JTATransaction.begin() method. Ant the class returned is org.jboss.tm.usertx.client.ServerVMClientUserTransaction


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 03, 2004 9:08 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Do you still have a problem then? It is not clear from your last post.


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 1:58 am 
Newbie

Joined: Mon May 03, 2004 7:10 am
Posts: 4
Location: Bangalore, India
Ya, I still have the problem. The exact problem is that the method JTATransaction.begin() internally invokes the following method:

initialcontext.lookup("UserTransaction");

This method expects a return type of javax.transaction.UserTransaction

and the lookup returns the following class:

org.jboss.tm.usertx.client.ServerVMClientUserTransaction

I'm getting the ClassCastException at this point.

But I've checked that both the above mentioned classes are compatible.

I really don't understand the reason for this exception. Can it be because the class javax.transaction.UserTransaction is not loaded by the server?
But this class is present in jboss-j2ee.jar which in turn is present at the lib directory of my server.

Please Help!!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 6:32 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
What versions of JBoss, operating systems and JVM are you using?


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 05, 2004 5:09 am 
Newbie

Joined: Mon May 03, 2004 7:10 am
Posts: 4
Location: Bangalore, India
It got fixed now. It was actually a classloading issue. I had the jta.jar in my war file. So the required class was getting loaded in a different context, causing the ClassCasfException/NoClassDefFoundException.

Thanks,
Joydeep


Top
 Profile  
 
 Post subject: Re: Problem using Hibernate JBOSS service
PostPosted: Tue Apr 20, 2010 9:02 pm 
Newbie

Joined: Tue Apr 20, 2010 8:59 pm
Posts: 1
I hope someone still reads topics this old, but the thing is i had the same problem, and I don't know how to change that classLoad, since the jta.jar is already included from the Hibernate Core Library.
Could anyone help about this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.