-->
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.  [ 2 posts ] 
Author Message
 Post subject: Transactions on Weblogic 10.3 - Hibernate 3
PostPosted: Fri Jun 05, 2009 3:51 am 
Newbie

Joined: Fri Jun 05, 2009 3:07 am
Posts: 2
I have a J2EE application written in EJB2 and Hibernate 3 and running on Weblogic 9.2 MP1.
I'm trying to migrate it to Weblogic 10.3.

I have the following method on my EJB:

Code:

   @LocalMethod(transactionAttribute = Constants.TransactionAttribute.REQUIRED)
   public User getUserByUserName(String userName) {
      try {
         LOGGER.debug("Getting Current session");
         org.hibernate.Session ses = HibernateUtil.getSessionFactory().getCurrentSession();
         LOGGER.debug("Got Current session");
         User user = (User)ses.createQuery( "select a from User a"+
                                    " left join fetch a.party p"+
                                    " left join fetch p.contactInformation c"+
                                    " left join fetch c.address"+
                                    " left join fetch p.contactPersons pr"+
                                    " left join fetch pr.contactTypes t"+
                                    " left join fetch a.roles r"+
                                    " left join fetch a.repository s"+
                                    " where a.userId = :userName and a.deleted = 0")
            .setString("userName", userName)
            .uniqueResult();         
         LOGGER.debug("Executed query");
         return user;         
      } catch (RuntimeException e) {
         throw new SystemRuntimeException(e);
      }
   }


and the following configuration on my hibernate.cfg.xml file:

Code:
<property name="connection.datasource">jdbc/reachDatasource</property>
<property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="current_session_context_class">jta</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>


When I'm trying to call the EJB method i get the following stacktrace:

Code:
javax.ejb.EJBException: EJB Exception: : eu.echa.reach.main.services.commons.SystemRuntimeException: org.hibernate.HibernateException: Current transaction is not in progress
        at eu.echa.reach.main.services.users.UserServicesBean.getUserByUserName(UserServicesBean.java:465)
        at eu.echa.reach.main.services.users.UserServicesBean_fget82_ELOImpl.getUserByUserName(UserServicesBean_fget82_ELOImpl.java:1295)
        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:597)
        at eu.echa.reach.main.delegates.util.ServiceProxy.invoke(ServiceProxy.java:127)
        at $Proxy61.getUserByUserName(Unknown Source)
        at eu.echa.reach.web.beans.security.LoginBean.doLogin(LoginBean.java:301)
        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:597)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
        at javax.faces.component.UICommand.broadcast(UICommand.java:109)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
        at org.apache.myfaces.webapp.MyFacesServlet.service(MyFacesServlet.java:77)
        at eu.echa.reach.web.servlets.ReachFacesServlet.service(ReachFacesServlet.java:72)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:210)
        at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:167)
        at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:140)
        at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:93)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: org.hibernate.HibernateException: Current transaction is not in progress
        at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:67)
        at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)
        at eu.echa.reach.main.services.users.UserServicesBean.getUserByUserName(UserServicesBean.java:449)
        ... 43 more


Has anyone seen this before?


Top
 Profile  
 
 Post subject: Re: Transactions on Weblogic 10.3 - Hibernate 3
PostPosted: Tue Jun 09, 2009 10:08 am 
Newbie

Joined: Fri Jun 05, 2009 3:07 am
Posts: 2
Finally I found a solution for my problem.

I requested the Hibernate's session factory during the application loading using an application life cycle listener,
so it was build before calling my first ejb method. I cannot explain why I needed to do that but it worked.


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