6 Replies Latest reply on Sep 5, 2008 9:14 PM by Andy Pemberton

    Issue with the JBoss HelloWorldIPC portlet

    Bapathi Srivalli Newbie

      Hi,
      I am trying to use the JBoss HelloWorldIPC portlet on JBoss 2.6.
      When I add the two portlets HelloWorldIPC Portlet A and HelloWorldIPC Portlet B, nothing is displayed in the 'HelloWorldIPC Portlet A' portlet.

      I get the below error message in the log file -

      ERROR [org.jboss.portal.security.PortalPermissionCollection] Permission check against the repository failed
      org.hibernate.HibernateException: Unable to locate current JTA transaction
      at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)

      I saw many queries on the same issues, but with no solution.
      Please help me out if anyone is aware about this issue.

      Thanks

        • 1. Re: Issue with the JBoss HelloWorldIPC portlet
          Brian DeHaven Newbie

          I'm having the same issue. I made my own portlet to isolate it. All the portlet does is traverse portalNode.getParent() until it reaches the top, and then it tries to print out the entire tree structure. It only has access to the context/portal/page/window that the starting portlet belongs in. Trying to access any other PortalNode instance results in the exception reported in the first post.

          How would you grant a portlet permissions to view the entire PortalNode directory structure to enable page linking, site mapping, etc?

          • 2. Re: Issue with the JBoss HelloWorldIPC portlet
            Brian DeHaven Newbie

            This is the portlet I threw together. There are many other pages and windows deployed. Only the PageLinkWindow and its parent are printed. Exceptions are thrown for every other node the code attempts to access, but they don't propogate into the portlet doView method. They are just printed to console.

            Output:

            : context
            -DemoPortal: portal
            --ipc: page
            ---PageLinkWindow: window


            Portlet code:
            import java.io.IOException;
            import java.util.Collection;
            
            import javax.portlet.PortletException;
            
            import org.jboss.portal.api.node.PortalNode;
            import org.jboss.portlet.JBossPortlet;
            import org.jboss.portlet.JBossRenderRequest;
            import org.jboss.portlet.JBossRenderResponse;
            
            public class PageLinkPortlet extends JBossPortlet
            {
             protected void doView(JBossRenderRequest request, JBossRenderResponse response) throws IOException, PortletException
             {
             try
             {
             response.setContentType("text/html");
             StringBuffer html = new StringBuffer();
            
             PortalNode baseNode = request.getPortalNode();
             while (baseNode.getParent() != null)
             baseNode = baseNode.getParent();
            
             list(html, baseNode);
             listchildren(html, baseNode, 1);
            
             response.getWriter().write(html.toString());
             }
             catch(Exception e)
             {
             //e.printStackTrace();
             }
             }
            
             private void list(StringBuffer html, PortalNode pn)
             {
             String type = "";
             if (pn.getType() == PortalNode.TYPE_CONTEXT)
             type = "context";
             else if (pn.getType() == PortalNode.TYPE_PORTAL)
             type = "portal";
             if (pn.getType() == PortalNode.TYPE_PAGE)
             type = "page";
             if (pn.getType() == PortalNode.TYPE_WINDOW)
             type = "window";
            
             html.append(pn.getName() + ": " + type + "<br>");
             }
            
             private void listchildren(StringBuffer html, PortalNode pn, int depth)
             {
             Collection<PortalNode> c = (Collection<PortalNode>) pn.getChildren();
            
             for (PortalNode node : c)
             {
             for (int i = 0; i < depth; i++)
             html.append("-");
            
             list(html, node);
             listchildren(html, node, depth + 1);
             }
             }
            }
            


            • 3. Re: Issue with the JBoss HelloWorldIPC portlet
              Brian DeHaven Newbie

              Found the problem. Simple fix in the end. You need to add the Required transaction attribute. The above portlet now spits out the entire deployed PortalNode structure. It should be easy to modify into a breadcrumb and/or sitemap portlet.

              jboss-portlet.xml

               <portlet>
               <portlet-name>PageLinkPortlet</portlet-name>
               <transaction>
               <trans-attribute>Required</trans-attribute>
               </transaction>
               </portlet>
              



              • 4. Re: Issue with the JBoss HelloWorldIPC portlet
                Linpei Zhang Newbie

                 

                "briandehaven" wrote:
                Found the problem. Simple fix in the end. You need to add the Required transaction attribute. The above portlet now spits out the entire deployed PortalNode structure. It should be easy to modify into a breadcrumb and/or sitemap portlet.

                jboss-portlet.xml
                 <portlet>
                 <portlet-name>PageLinkPortlet</portlet-name>
                 <transaction>
                 <trans-attribute>Required</trans-attribute>
                 </transaction>
                 </portlet>
                



                Thanks for your post, briandehaven! I didn't complete get your point. Do I have to add your new portlet to make the HelloWorldIPC example work? Or I can simply add the transaction attribute to the existing PortletA and PortletB instance?

                I think a lot of people like myself are still suffering this issue. I appreciate if you can share more details!

                Thanks,
                Linpei

                • 5. Re: Issue with the JBoss HelloWorldIPC portlet
                  Brian DeHaven Newbie

                   

                  "linpeizhang" wrote:
                  Thanks for your post, briandehaven! I didn't complete get your point. Do I have to add your new portlet to make the HelloWorldIPC example work? Or I can simply add the transaction attribute to the existing PortletA and PortletB instance?

                  I think a lot of people like myself are still suffering this issue. I appreciate if you can share more details!

                  Thanks,
                  Linpei


                  Just add the element mentioned above to the configuration of any portlet that tries to traverse the PortalNode tree.

                  My portlet was just showing that the problem only arose when you tried to reach PortalNode's outside the current portlets ancestor list. It was duplicating the HellowWorldIPC problem, just so I knew where the problem was happening.

                  • 6. Re: Issue with the JBoss HelloWorldIPC portlet
                    Andy Pemberton Newbie

                    Brian:

                    Thanks for the dilligence; I'm having a similar issue on JBoss Portal 2.6.5.

                    Basically, if I have two portlets on PageA: PortletA and PortletB, PortletA can only access its own portlet window on the given page.

                    So, the following code can access any page below PageA and PortletA itself:

                    public class PortletA extends GenericPortlet {
                     PortalNode node = ((JBossRenderRequest)request).getPortalNode();
                     PortalNode parent = node.getParent();
                     Collection<PortalNode> kids = parent.getChildren();
                     for (PortalNode kid : kids) {
                     out.println(" child node: " + kid.getName());
                     }...


                    FYI: my jboss-portlet.xml looks like:

                    <portlet>
                     <portlet-name>PortletA</portlet-name>
                     <transaction>
                     <trans-attribute>Required</trans-attribute>
                     </transaction>
                    </portlet>


                    Any ideas?
                    Thanks,
                    Andy