1 2 Previous Next 17 Replies Latest reply on Jul 16, 2009 1:21 PM by Prabhat Jha

    Need IPC Sample

    ganeshraja chinnadurai Newbie

      I need Inter Portlet Communication portlet sample for JBoss Portal 2.6 GA version..

        • 1. Re: Need IPC Sample
          Thomas Heute Master

          Use the event mechanism, there is an example in the documentation.

          • 2. Re: Need IPC Sample
            ganeshraja chinnadurai Newbie

            I am getting error for the following code refered from reference document.

            PortletA.java

            package sample;
            
            import java.io.IOException;
            import java.io.PrintWriter;
            
            import javax.portlet.GenericPortlet;
            import javax.portlet.PortletException;
            import javax.portlet.PortletSecurityException;
            import javax.portlet.RenderRequest;
            import javax.portlet.RenderResponse;
            
            
            public class PortletA extends GenericPortlet
            {
             protected void doView(RenderRequest request, RenderResponse response)
             throws PortletException, PortletSecurityException, IOException
             {
             response.setContentType("text/html");
             PrintWriter writer = response.getWriter();
             writer.println("<form action=\"" + response.createActionURL() + "\" method=\"post\">");
             writer.println("<select name=\"color\">");
             writer.println("<option>blue</option>");
             writer.println("<option>red</option>");
             writer.println("<option>black</option>");
             writer.println("</select>");
             writer.println("<input type=\"submit\"/>");
             writer.println("</form>");
             writer.close();
             }
            }


            PortletB.java

            package sample;
            
            import java.io.IOException;
            import java.io.PrintWriter;
            
            import javax.portlet.ActionRequest;
            import javax.portlet.ActionResponse;
            import javax.portlet.GenericPortlet;
            import javax.portlet.PortletException;
            import javax.portlet.PortletSecurityException;
            import javax.portlet.RenderRequest;
            import javax.portlet.RenderResponse;
            
            import org.jboss.portlet.PortalNode;
            import org.jboss.portlet.event.node.PortalNodeEvent;
            import org.jboss.portlet.event.node.PortalNodeEventBubbler;
            import org.jboss.portlet.event.node.PortalNodeEventListener;
            import org.jboss.portlet.event.node.WindowActionEvent;
            
            public class PortletB extends GenericPortlet
            {
            
             public void processAction(ActionRequest request, ActionResponse response)
             throws PortletException, PortletSecurityException, IOException
             {
             String color = request.getParameter("color");
             if (color != null)
             {
             response.setRenderParameter("color", color);
             }
             }
            
             protected void doView(RenderRequest request, RenderResponse response)
             throws PortletException, PortletSecurityException, IOException
             {
             String color = request.getParameter("color");
             response.setContentType("text/html");
             PrintWriter writer = response.getWriter();
             writer.println("<div" +
             (color == null ? "" : " style=\"color:" + color + ";\"") +
             ">some text in color</div>");
             writer.close();
             }
            
             // Inner listener
             public static class Listener implements PortalNodeEventListener
             {
             public PortalNodeEvent onEvent(PortalNodeEventBubbler bubbler, PortalNodeEvent event)
             {
             PortalNode node = event.getNode();
             // Get node name
             String nodeName = node.getName();
             // See if we need to create a new event or not
             WindowActionEvent newEvent = null;
             if (nodeName.equals("PortletAWindow") && event instanceof WindowActionEvent)
             {
             // Find window B
             WindowActionEvent wae = (WindowActionEvent)event;
             PortalNode windowB = node.resolve("../PortletBWindow");
             if (windowB != null)
             {
             // We can redirect
             newEvent = new WindowActionEvent(windowB);
             newEvent.setParameters(wae.getParameters());
             // Redirect to the new event
             return newEvent;
             }
             }
             // Otherwise bubble up
             return bubbler.dispatch(event);
             }
             }
            
            }


            Portlet.xml

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <portlet-app version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
            
             <portlet>
             <portlet-name>IPCPortletA</portlet-name>
             <portlet-class>sample.PortletA</portlet-class>
             <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             </supports>
             <portlet-info>
             <title>IPC Portlet A</title>
             </portlet-info>
             </portlet>
             <portlet>
             <portlet-name>IPCPortletB</portlet-name>
             <portlet-class>sample.PortletB</portlet-class>
             <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             </supports>
             <portlet-info>
             <title>IPC Portlet B</title>
             </portlet-info>
             </portlet>
            
            </portlet-app>


            Exception

            org.jboss.portal.portlet.container.PortletInitializationException: The portlet IPCPortletA threw a runtime exception during init
             at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:264)
             at org.jboss.portal.portlet.impl.container.PortletApplicationContextImpl.startPortletApplication(PortletApplicationContextImpl.java:130)
             at org.jboss.portal.portlet.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:153)
             at org.jboss.portal.core.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:94)
             at org.jboss.portal.server.deployment.jboss.DeploymentContext.start(DeploymentContext.java:99)
             at org.jboss.portal.server.deployment.jboss.PortalDeploymentInfoContext.start(PortalDeploymentInfoContext.java:211)
             at org.jboss.portal.server.deployment.jboss.ServerDeployer.start(ServerDeployer.java:217)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
             at sun.reflect.GeneratedMethodAccessor194.invoke(Unknown Source)
             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:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy194.deploy(Unknown Source)
             at org.jboss.portal.server.deployment.jboss.ServerDeployer.deploy(ServerDeployer.java:259)
             at org.jboss.portal.server.deployment.WebAppAdapter.deploy(WebAppAdapter.java:54)
             at org.jboss.portal.server.deployment.WebAppIntercepter.handleNotification(WebAppIntercepter.java:160)
             at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:153)
             at $Proxy197.handleNotification(Unknown Source)
             at org.jboss.mx.util.JBossNotificationBroadcasterSupport.handleNotification(JBossNotificationBroadcasterSupport.java:127)
             at org.jboss.mx.util.JBossNotificationBroadcasterSupport.sendNotification(JBossNotificationBroadcasterSupport.java:108)
             at org.jboss.deployment.SubDeployerSupport.emitNotification(SubDeployerSupport.java:340)
             at org.jboss.deployment.SubDeployerSupport.start(SubDeployerSupport.java:308)
             at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:482)
             at sun.reflect.GeneratedMethodAccessor256.invoke(Unknown Source)
             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:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
             at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
             at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
             at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
             at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy177.start(Unknown Source)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
             at sun.reflect.GeneratedMethodAccessor117.invoke(Unknown Source)
             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:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy8.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
             Caused by: java.lang.ClassCastException: sample.PortletA
             at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:231)
             ... 73 more
             org.jboss.portal.portlet.container.PortletInitializationException: The portlet IPCPortletB threw a runtime exception during init
             at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:264)
             at org.jboss.portal.portlet.impl.container.PortletApplicationContextImpl.startPortletApplication(PortletApplicationContextImpl.java:130)
             at org.jboss.portal.portlet.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:153)
             at org.jboss.portal.core.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:94)
             at org.jboss.portal.server.deployment.jboss.DeploymentContext.start(DeploymentContext.java:99)
             at org.jboss.portal.server.deployment.jboss.PortalDeploymentInfoContext.start(PortalDeploymentInfoContext.java:211)
             at org.jboss.portal.server.deployment.jboss.ServerDeployer.start(ServerDeployer.java:217)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
             at sun.reflect.GeneratedMethodAccessor194.invoke(Unknown Source)
             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:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy194.deploy(Unknown Source)
             at org.jboss.portal.server.deployment.jboss.ServerDeployer.deploy(ServerDeployer.java:259)
             at org.jboss.portal.server.deployment.WebAppAdapter.deploy(WebAppAdapter.java:54)
             at org.jboss.portal.server.deployment.WebAppIntercepter.handleNotification(WebAppIntercepter.java:160)
             at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:153)
             at $Proxy197.handleNotification(Unknown Source)
             at org.jboss.mx.util.JBossNotificationBroadcasterSupport.handleNotification(JBossNotificationBroadcasterSupport.java:127)
             at org.jboss.mx.util.JBossNotificationBroadcasterSupport.sendNotification(JBossNotificationBroadcasterSupport.java:108)
             at org.jboss.deployment.SubDeployerSupport.emitNotification(SubDeployerSupport.java:340)
             at org.jboss.deployment.SubDeployerSupport.start(SubDeployerSupport.java:308)
             at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:482)
             at sun.reflect.GeneratedMethodAccessor256.invoke(Unknown Source)
             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:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
             at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
             at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
             at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
             at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy177.start(Unknown Source)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
             at sun.reflect.GeneratedMethodAccessor117.invoke(Unknown Source)
             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:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy8.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
             Caused by: java.lang.ClassCastException: sample.PortletB
             at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:231)
             ... 73 more
            


            • 3. Re: Need IPC Sample
              Thomas Heute Master

              Do you have portlet-api-lib.jar in your war ? In case you do please remove it.

              • 4. Re: Need IPC Sample
                ganeshraja chinnadurai Newbie

                which are the required .jar files for this sample?

                • 5. Re: Need IPC Sample
                  habicht hawk Newbie

                  all necessary libs are located in /JBOSS_HOME/default/deploy/jboss-portal.sar/lib

                  another question. are there any steps to do to get the portletA/portletB-example running that aren't mentioned in the reference manual? i tried exactly according to the example but all i got was an exception because of the used actionulr in portleta which doesn't override the processAction methode (i think this was the problem because after i implemented an emty processAction the exception was gone).

                  • 6. Re: Need IPC Sample
                    Thomas Heute Master

                    Yes some info was missing, sorry about this.
                    I updated the chapter it should be built and available soon online, i'll let you know.

                    • 8. Re: Need IPC Sample
                      Prabhat Jha Master

                      Hi Guys,

                      The URL that Thomas posted works inside vpn only. For public, replace the machine name with hudson.jboss.org. Here you go:

                      https://hudson.jboss.org/hudson/view/JBoss%20Portal/job/jboss-portal-nightly-doc/lastSuccessfulBuild/artifact/daily-doc/referenceGuide/html/portalapi.html

                      Cheers,
                      Prabhat

                      • 10. Re: Need IPC Sample
                        Thomas Heute Master

                        i update the wiki, ty prabhat !

                        • 11. Re: Need IPC Sample
                          habicht hawk Newbie

                          does that code example from the link 2 posts above work for Portal 2.6? do i have to create a jboss-service.xml, if yes where, or do i have to copy this mbean-code into an existing file?

                          • 12. Re: Need IPC Sample
                            habicht hawk Newbie

                            i would like to repeat my questions from the post above.

                            does that code example from the link 2 posts above work for Portal 2.6? do i have to create a jboss-service.xml, if yes where, or do i have to copy this mbean-code into an existing file?

                            • 13. Re: Need IPC Sample
                              Thomas Heute Master

                              The doc says you need to reference your listerner as an mbean. So if you don't have one already create a sar file with a jboss-service.xml file

                              • 14. Re: Need IPC Sample
                                ruchika garg Newbie

                                I am still facing the below problem.
                                I was getting no class loader error when i was trying to deploy my war.
                                I created the jar of classes and have put in class path.
                                Now I am facing the below error.
                                I am using jboss-portal-2.6.4.

                                Any help will be greatly appreciated.

                                Regards,
                                Ruchika

                                1 2 Previous Next