1 Reply Latest reply on Apr 18, 2010 4:04 PM by Prabhat Jha

    Jboss portal 2.7.2 portlet ClassCast Exception

    Debopam Poddar Newbie

      I am new to portlet developmet. I was trying to develop and deploy simple portlet in Jboss portal 2.7.2 and Jboss AS 4.2.3/

       

      Following is the code

       

      Portlet extending GenericPortlet

       

      package com.sampleportlet;

      import java.io.IOException;

      import javax.portlet.ActionRequest;
      import javax.portlet.ActionResponse;
      import javax.portlet.GenericPortlet;
      import javax.portlet.PortletConfig;
      import javax.portlet.PortletException;
      import javax.portlet.PortletRequestDispatcher;
      import javax.portlet.RenderRequest;
      import javax.portlet.RenderResponse;
      import javax.portlet.UnavailableException;



      public class First extends GenericPortlet {

         
         
          public void init(PortletConfig portletConfig) throws UnavailableException,
                  PortletException {
              super.init(portletConfig);
          }

          /**
           * Helper method to serve up the mandatory view mode.
           */
          protected void doHelp(RenderRequest request, RenderResponse response)
                  throws PortletException, IOException {
              response.setContentType("text/html");
              PortletRequestDispatcher dispatcher = getPortletContext()
                      .getRequestDispatcher("/WEB-INF/jsp/First_help.jsp");
              dispatcher.include(request, response);
          }

          /**
           * Helper method to serve up the mandatory view mode.
           */
          protected void doEdit(RenderRequest request, RenderResponse response)
                  throws PortletException, IOException {
              response.setContentType("text/html");
              PortletRequestDispatcher dispatcher = getPortletContext()
                      .getRequestDispatcher("/WEB-INF/jsp/First_edit.jsp");
              dispatcher.include(request, response);
          }

          /**
           * Helper method to serve up the mandatory view mode.
           */
          protected void doView(RenderRequest request, RenderResponse response)
                  throws PortletException, IOException {
              response.setContentType("text/html");

              String name = (String) request.getParameter("name");

              if (name != null) {
                  PortletRequestDispatcher reqDispatcher = getPortletContext()
                          .getRequestDispatcher("/WEB-INF/jsp/First_view.jsp");
                  request.setAttribute("name", name);
                  reqDispatcher.include(request, response);
              } else {
                  PortletRequestDispatcher reqDispatcher = getPortletContext()
                          .getRequestDispatcher("/WEB-INF/jsp/First_edit.jsp");
                  reqDispatcher.include(request, response);
              }
          }

          public void processAction(ActionRequest actionRequest,
                  ActionResponse actionResponse) throws PortletException,
                  IOException, UnavailableException {
              String name = (String) actionRequest.getParameter("name");

              // send name back to view
              actionResponse.setRenderParameter("name", name);
          }

      }

       

      WEB-INF/portlet.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
          version="2.0">
          <portlet>
              <portlet-name>FirstJspPortlet</portlet-name>
              <display-name>First Portlet</display-name>
              <portlet-class>com.sampleportlet.First</portlet-class>
              <supports>
                  <mime-type>text/html</mime-type>
                  <portlet-mode>VIEW</portlet-mode>
                  <portlet-mode>EDIT</portlet-mode>
                  <portlet-mode>HELP</portlet-mode>
              </supports>
              <portlet-info>
                  <title>First Portlet</title>
              </portlet-info>
          </portlet>
         
      </portlet-app>

       

      WEB-INF/portlet-instances.xml

       

       

      <?xml version="1.0" standalone="yes"?>
      <deployments>
         <deployment>
               <instance>
                  <instance-id>FirstPortletInstance</instance-id>
                  <portlet-ref>FirstJspPortlet</portlet-ref>
               </instance>
         </deployment>
      </deployments>

       

      WEB-INF/firstjspportlet-object.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <deployments>
          <deployment>
              <if-exists>overwrite</if-exists>
              <parent-ref>default.default</parent-ref>
              <window>
                  <window-name>FirstPortletWindow</window-name>
                  <content>
                      <content-type>portlet</content-type>
                      <content-uri>FirstPortletInstance</content-uri>
                  </content>
                  <region>center</region>
                  <height>1</height>
              </window>
          </deployment>
      </deployments>

       

      WEB-INF/Jboss-portlet.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE portlet-app PUBLIC "-//JBoss Portal//DTD JBoss Portlet 2.6//EN"
              "http://www.jboss.org/portal/dtd/jboss-portlet_2_6.dtd">

      <portlet-app>
         <remotable>true</remotable>
         <portlet>
            <portlet-name>FirstJspPortlet</portlet-name>
         </portlet>
      </portlet-app>

       

      Error I am getting is

       

       

      2010-04-18 22:09:22,953 DEBUG [org.jboss.portal.portlet.container.com_sampleportlet_First] Loading portlet class com.sampleportlet.First
      2010-04-18 22:09:22,958 DEBUG [org.jboss.portal.portlet.container.com_sampleportlet_First] Creating portlet object com.sampleportlet.First
      2010-04-18 22:09:22,962 ERROR [org.jboss.portal.portlet.impl.container.LifeCycle] Cannot start object
      org.jboss.portal.portlet.container.PortletInitializationException: The portlet FirstJspPortlet threw a runtime exception during init
          at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:288)
          at org.jboss.portal.portlet.impl.container.PortletContainerLifeCycle.invokeStart(PortletContainerLifeCycle.java:76)
          at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:92)
          at org.jboss.portal.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:351)
          at org.jboss.portal.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:128)
          at org.jboss.portal.portlet.deployment.jboss.PortletAppDeployment.start(PortletAppDeployment.java:226)
          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:220)
          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.GeneratedMethodAccessor212.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 $Proxy222.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:53)
          at org.jboss.portal.server.deployment.WebAppIntercepter.handleNotification(WebAppIntercepter.java:159)
          at sun.reflect.GeneratedMethodAccessor4.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 $Proxy224.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.GeneratedMethodAccessor105.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.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
          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 $Proxy202.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.GeneratedMethodAccessor26.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 $Proxy9.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.startService(AbstractDeploymentScanner.java:336)
          at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
          at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
          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.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
          at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
          at $Proxy0.start(Unknown Source)
          at org.jboss.system.ServiceController.start(ServiceController.java:417)
          at sun.reflect.GeneratedMethodAccessor9.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.server.Invocation.invoke(Invocation.java:86)
          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 $Proxy4.start(Unknown Source)
          at org.jboss.deployment.SARDeployer.start(SARDeployer.java:304)
          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 org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
          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: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 $Proxy5.deploy(Unknown Source)
          at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
          at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
          at org.jboss.Main.boot(Main.java:200)
          at org.jboss.Main$1.run(Main.java:508)
          at java.lang.Thread.run(Thread.java:613)
      Caused by: java.lang.ClassCastException: com.sampleportlet.First
          at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:254)

       

      Please let me know what needs to be changed.