This content has been marked as final.
Show 3 replies
-
1. Re: Error accesing Hibernate current session and UserModule
the-gtm Feb 15, 2006 8:37 AM (in response to xmaniac)I'm not accessing UserModule but I got the same exception in a portlet when I tried to use my own SessionFactory, so my solution might apply to your case. Try to edit jboss-portlet.xml to add a "transaction" element :
<portlet-app> <portlet> <portlet-name>MyPortlet</portlet-name> <transaction> <trans-attribute>Required</trans-attribute> </transaction> </portlet> </portlet-app>
-
2. Re: Error accesing Hibernate current session and UserModule
xmaniac Feb 15, 2006 1:03 PM (in response to xmaniac)That works great with portlets. As a matter of fact, I was using it already.
However my problem arises when accesing the portal context from a Spring bean (not referenced by a portlet) or a servlet. -
3. Re: Error accesing Hibernate current session and UserModule
al_kiev Mar 4, 2006 3:27 AM (in response to xmaniac)Had the same problem in the code that executed outside of standard TransactionInterceptor....
the solution is to wrap your calls to transactions using the following technique:TransactionManager tm; try { tm = TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager(); } catch (Exception e) { throw new RuntimeException(e); } Transaction oldTx = null; try { oldTx = Transactions.applyBefore(Transactions.TYPE_REQUIRED, tm); .... do something .... } catch (TransactionException e) { throw new RuntimeException(e); } finally { try { Transactions.applyAfter(Transactions.TYPE_REQUIRED, tm, oldTx); } catch (TransactionException e) { log.error("", e); } }