4 Replies Latest reply on Oct 9, 2005 12:13 PM by Stuart Barker

    ClassCastException during Portlet Initialisation

    Stuart Barker Newbie

      I'm having problems deploying my portlet under JBoss, I receive the following error during start-up...

      2005-10-06 23:37:27,340 DEBUG [org.jboss.portal.portlet.PortletContainer] Loading portlet class com.xponentsoftware.portlets.im.ControllerPortlet
      2005-10-06 23:37:27,350 DEBUG [org.jboss.portal.portlet.PortletContainer] Creating portlet object com.xponentsoftware.portlets.im.ControllerPortlet
      2005-10-06 23:37:27,360 DEBUG [org.jboss.portal.server.kernel.Kernel.component.xmppIMPortlet.jMessengerPortlet] failed
      2005-10-06 23:37:27,360 ERROR [org.jboss.portal.core.deployment.jboss.PortletAppDeployment] The portlet cannot be started due to an error that occcured during init
      org.jboss.portal.portlet.PortletInitializationException: The portlet threw a runtime exception during init
       at org.jboss.portal.portlet.PortletContainer.start(PortletContainer.java:165)
       at org.jboss.portal.server.kernel.StartMethod.invokeMethod(StartMethod.java:37)
       at org.jboss.portal.server.kernel.UpgradeMethod.invoke(UpgradeMethod.java:46)
       at org.jboss.portal.server.kernel.Kernel.start(Kernel.java:382)
       at org.jboss.portal.server.impl.ServerManagerImpl.deploy(ServerManagerImpl.java:409)
       at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       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:121)
       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:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy29.deploy(Unknown Source)
       at org.jboss.portal.portlet.deployment.jboss.PortletAppDeployment.create(PortletAppDeployment.java:165)
       at org.jboss.portal.server.deployment.jboss.ServerDeployer.create(ServerDeployer.java:171)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:918)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:910)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:774)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       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:121)
       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:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy56.deploy(Unknown Source)
       at org.jboss.portal.server.deployment.jboss.ServerDeployer.deploy(ServerDeployer.java:255)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy31.deploy(Unknown Source)
       at org.jboss.portal.server.deployment.WebAppAdapter.deploy(WebAppAdapter.java:49)
       at org.jboss.portal.server.deployment.WebAppIntercepter.handleNotification(WebAppIntercepter.java:137)
       at org.jboss.mx.modelmbean.XMBean.handleNotification(XMBean.java:485)
       at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:138)
       at $Proxy38.handleNotification(Unknown Source)
       at org.jboss.mx.util.JBossNotificationBroadcasterSupport.handleNotification(JBossNotificationBroadcasterSupport.java:112)
       at org.jboss.mx.util.JBossNotificationBroadcasterSupport.sendNotification(JBossNotificationBroadcasterSupport.java:93)
       at org.jboss.deployment.SubDeployerSupport.emitNotification(SubDeployerSupport.java:238)
       at org.jboss.deployment.SubDeployerSupport.start(SubDeployerSupport.java:206)
       at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:410)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
       at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       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:121)
       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:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy8.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:483)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
      Caused by: java.lang.ClassCastException: com.xponentsoftware.portlets.im.ControllerPortlet
       at org.jboss.portal.portlet.PortletContainer.start(PortletContainer.java:133)
       ... 82 more
      


      Looking through this it really doesn't tell me a great deal about the exception, I've also got very minimal code in this portlet class (I'm only just trying to test my initial attempt at coding a portlet!).

      My deployment descriptors looks as follows...

      portlet.xml
      <portlet-app>
       <portlet>
       <portlet-name>jMessengerPortlet</portlet-name>
       <portlet-class>com.xponentsoftware.portlets.im.ControllerPortlet</portlet-class>
       <init-param>
       <name>imPortlet.imServer</name>
       <value>localhost</value>
       </init-param>
       <expiration-cache>3600</expiration-cache>
       <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>EDIT</portlet-mode>
       <portlet-mode>HELP</portlet-mode>
       </supports>
       <portlet-info>
       <title>jMessenger</title>
       </portlet-info>
       </portlet>
      </portlet-app>
      


      web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
       <session-config>
       <session-timeout>30</session-timeout>
       </session-config>
       <display-name>jMessenger Portlet</display-name>
      </web-app>
      


      jboss-app.xml
      <jboss-app>
       <app-name>xmppIMPortlet</app-name>
      </jboss-app>
      


      jboss-portlet.xml
      <portlet-app>
       <portlet>
       <portlet-name>jMessengerPortlet</portlet-name>
       <security></security>
       </portlet>
      </portlet-app>
      


      portlet-instances.xml
      <instances>
       <instance>
       <instance-name>jMessengerInstance</instance-name>
       <component-ref>jMessengerPortlet</component-ref>
       </instance>
      </instances>
      


      jMessenger-pages.xml
      <pages>
       <portal-name>default</portal-name>
       <page>
       <page-name>jMessenger</page-name>
       <window>
       <window-name>jMessengerPortletWindow</window-name>
       <instance-ref>xmppIMPortlet.jMessengerPortlet.jMessengerInstance</instance-ref>
       <default>true</default>
       <region>center</region>
       <height>0</height>
       </window>
       </page>
      </pages>
      


      Any help would be greatly appreciated, thanks!

        • 1. Re: ClassCastException during Portlet Initialisation
          Jacek Laskowski Newbie

          Hi,

          You didn't describe your environment, but having taken a look at the configuration files, I guess it's JBoss Portal 2.0.1, isn't it? It may not be as important as it seemed to be at first glance, but it's a good habit to include such information when reporting an issue.

          I've seen ClassCastExceptions when I included portlet.jar within a war. So, make sure that your WEB-INF/lib or WEB-INF/classes directories don't contain portlet.jar.

          I've seen the exception, too, when a portlet was based on Apache MyFaces portlet and when JSF libraries were in these WEB-INF directories. Since it wasn't shown how your portlet looked like I can't give you a definitive answer.

          I'm leaning towards to saying that when the ClassCastException is thrown it is most likely a problem manifesting conflicting libraries in WEB-INF/classes or WEB-INF/lib directories. That's what I've been seeing many times in 2.2.0-ALPHA, and may not be of help in previous versions.

          Hope this helps.

          Jacek

          • 2. Re: ClassCastException during Portlet Initialisation
            Stuart Barker Newbie

            Hi Jacek,

            Thanks it was the portlet.jar packaged up into the WAR.

            Now to get back and sort out the NPE - looks like the container can't find the portlet title and ResourceBundle!

            Cheers,
            Stuart

            • 3. Re: ClassCastException during Portlet Initialisation
              Viet Master

              yes having the portlet.jar is an issue because of the classloading scheme of the servlets.

              • 4. Re: ClassCastException during Portlet Initialisation
                Stuart Barker Newbie


                Not sure what's going on now. Given the config files above anybody got any ideas why I'm getting the following exception on the Portlet Page?

                java.lang.NullPointerException
                 at javax.portlet.GenericPortlet.getResourceBundle(GenericPortlet.java:251)
                 at javax.portlet.GenericPortlet.getTitle(GenericPortlet.java:274)
                 at javax.portlet.GenericPortlet.render(GenericPortlet.java:393)
                 at org.jboss.portal.portlet.invocation.DispatcherInterceptor.invokeRequest(DispatcherInterceptor.java:163)
                 at org.jboss.portal.portlet.invocation.DispatcherInterceptor.invoke(DispatcherInterceptor.java:195)
                 at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:213)
                 at org.jboss.portal.portlet.invocation.PreferencesInterceptor.invoke(PreferencesInterceptor.java:93)
                 at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:213)
                 at org.jboss.portal.server.invocation.component.ContextDispatcherInterceptor$InvokeNextCommand.execute(ContextDispatcherInterceptor.java:94)
                 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.portal.server.servlet.CommandServlet.doGet(CommandServlet.java:49)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                [...]
                


                Thanks in advance.
                Stuart