3 Replies Latest reply on Oct 30, 2006 4:23 PM by Antoine Herzog

    Extending UserPortlet in separate web app transaction proble

    Jon French Newbie

      I had a need to extend the default behavior of org.jboss.portal.core.portlet.user.UserPortlet. I needed to change both the behavior of the doView method and the associated JSP content. To that end, I did this:

      [1] Created a class [MyUserPortlet] that extended UserPortlet and overrode doView like this:

       protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
       throws PortletException,
       PortletSecurityException,
       IOException
       {
       /* my custom code */
      
       super.doView(req,resp);
       }
      
      

      [2] Created a web app named "mywebapp.war"
      [3] Deployed MyUserPortlet in "mywebapp.war" such that MyUserPortlet existed in mywebapp.war/WEB-INF/classes directory, mywebapp.war/WEB-INF/portlet.xml contained a entry for MyUserPortlet, and all the MyUserPortlet jsp were copied to mywebapp.war/WEB-INF/jsp/user.
      [4] Created an instance of MyUserPortlet in mywebapp.war/WEB-INF/my-object.xml.
      [5] Created multiple pages in JBoss portal where an instance of MyUserPortlet was displayed.

      For most UserPortlet functionality, everything works just like I would expect if I was interacting with the default UserPortlet instance as configured in $JBOSS_PORTAL_HOME/conf/data/default-object.xml. However, when, I try to access UserPortal functionality that requires database access (like showing the list of users), I get this exception:

      org.hibernate.HibernateException: Unable to locate current JTA transaction
       at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)
       at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:604)
       at org.jboss.portal.core.impl.user.UserModuleImpl.getCurrentSession(UserModuleImpl.java:372)
       at org.jboss.portal.core.impl.user.UserModuleImpl.findUsers(UserModuleImpl.java:272)
       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:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy220.findUsers(Unknown Source)
       at org.jboss.portal.core.portlet.user.UserPortlet.doView(UserPortlet.java:313)
       at my.package.MyUserPortlet.doView(MyUserPortlet.java:47)
      
       at org.jboss.portlet.JBossPortlet.doDispatch(JBossPortlet.java:230)
       at org.jboss.portlet.JBossPortlet.render(JBossPortlet.java:217)
       at org.jboss.portlet.JBossPortlet.render(JBossPortlet.java:360)
       at org.jboss.portal.portlet.PortletContainer.invokeRender(PortletContainer.java:521)
       at org.jboss.portal.portlet.PortletContainer.dispatch(PortletContainer.java:433)
       at org.jboss.portal.server.app.ComponentInvocation.dispatch(ComponentInvocation.java:79)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:140)
       at org.jboss.portal.core.aspects.component.TransactionInterceptor.invoke(TransactionInterceptor.java:72)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.core.aspects.component.HeaderInterceptor.invoke(HeaderInterceptor.java:50)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.server.aspects.component.NavigationInterceptor.invoke(NavigationInterceptor.java:76)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.server.aspects.component.CacheInterceptor.invoke(CacheInterceptor.java:167)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.server.aspects.component.ModesInterceptor.invoke(ModesInterceptor.java:88)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.server.aspects.component.WindowStatesInterceptor.invoke(WindowStatesInterceptor.java:87)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.bridge.BridgeInterceptor.invoke(BridgeInterceptor.java:49)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.portlet.aspects.component.SessionPostDispatchInterceptor.invoke(SessionPostDispatchInterceptor.java:65)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:38)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.server.aspects.component.ContextDispatcherInterceptor$InvokeNextCommand.execute(ContextDispatcherInterceptor.java:129)
       at sun.reflect.GeneratedMethodAccessor372.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.portal.server.servlet.CommandServlet.doGet(CommandServlet.java:101)
       at org.jboss.portal.server.servlet.CommandServlet.doPost(CommandServlet.java:149)
      
      .... more stack trace left out for clarity.
      


      In looking at the stack trace it seems like the correct TransactionInterceptor is being called that should be starting a Hibernate transaction. Could the fact that MyUserPortlet is deployed in a different web application cause this error? Has anyone else had this problem?

      JBoss AS 4.0.3SP1
      JBoss Portal 2.2.1