8 Replies Latest reply on Oct 5, 2012 2:14 AM by antoine_h

    Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.

    sk0032729

      Hi,

      Here is problem description:

       

      1. I created a new java portlet and try to deploy in gate in 3.2.0 and it was successful.

      2. Then I tried doView() method to include a jsp file which used </defineObject> tag.

      3. This portlet deployed successfully but during rendering of this portlet I got exception:

      I am strugging from last 3 days about this exception but no success.

      Please some one help me:

       

       

      Exception:

      ================================================================================

       

      12:36:43,381 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/DBC].[jsp]] Servlet.service() for servlet js

      threw exception: java.lang.ClassCastException: org.gatein.pc.api.invocation.RenderInvocation cannot be cast to org.jboss.portal.

      ortlet.invocation.PortletInvocation

              at org.jboss.portal.portlet.impl.jsr168.taglib.PortletTag.getInvocation(PortletTag.java:219) [:2.0.0]

              at org.jboss.portal.portlet.impl.jsr168.taglib.PortletTag.getDispatchedRequest(PortletTag.java:66) [:2.0.0]

              at org.jboss.portal.portlet.impl.jsr168.taglib.PortletTag.getPortletRequest(PortletTag.java:72) [:2.0.0]

              at org.jboss.portal.portlet.impl.jsr168.taglib.PortletTag.getRenderRequest(PortletTag.java:90) [:2.0.0]

              at org.jboss.portal.portlet.impl.jsr286.taglib.DefineObjects286Tag.doEndTag(DefineObjects286Tag.java:57) [:2.0.0]

              at org.apache.jsp.WEB_002dINF.jsp.MySqlToOracle_jsp._jspService(MySqlToOracle_jsp.java:66)

              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [:6.0.0.Final]

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]

              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) [:6.0.0.Final]

              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) [:6.0.0.Final]

              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) [:6.0.0.Final]

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:734) [:6.0.0.Final]

              at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:639) [:6.0.0.Final]

              at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:576) [:6.0.0.Final]

              at org.gatein.pc.portlet.impl.jsr168.api.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:155) [:2

      3.1-Beta02]

              at org.gatein.pc.portlet.impl.jsr168.api.PortletRequestDispatcherImpl.forward(PortletRequestDispatcherImpl.java:89) [:2.3

      1-Beta02]

              at com.dbconvertor.converter.MySqlToOracle.doView(MySqlToOracle.java:26) [:]

              at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328) [:]

              at javax.portlet.GenericPortlet.render(GenericPortlet.java:233) [:]

              at org.gatein.pc.portlet.impl.jsr168.PortletContainerImpl$Invoker.doFilter(PortletContainerImpl.java:569) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.impl.jsr168.api.FilterChainImpl.doFilter(FilterChainImpl.java:159) [:2.3.1-Beta02]

              at org.exoplatform.portal.application.ApplicationMonitoringFilter.doFilter(ApplicationMonitoringFilter.java:77) [:3.2.0-G

      ]

              at org.gatein.pc.portlet.impl.jsr168.api.FilterChainImpl.doFilter(FilterChainImpl.java:159) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.impl.jsr168.api.FilterChainImpl.doFilter(FilterChainImpl.java:80) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.impl.jsr168.PortletContainerImpl.dispatch(PortletContainerImpl.java:506) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.container.ContainerPortletDispatcher.invoke(ContainerPortletDispatcher.java:42) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:93) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.aspects.EventPayloadInterceptor.invoke(EventPayloadInterceptor.java:197) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:93) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.aspects.RequestAttributeConversationInterceptor.invoke(RequestAttributeConversationInterceptor.j

      va:119) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:93) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.aspects.CCPPInterceptor.invoke(CCPPInterceptor.java:65) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:93) [:2.3.1-Beta02]

              at org.gatein.pc.bridge.BridgeInterceptor.invoke(BridgeInterceptor.java:49) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:93) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.PortletInvokerInterceptor.invoke(PortletInvokerInterceptor.java:93) [:2.3.1-Beta02]

              at org.gatein.pc.portlet.aspects.SessionInvalidatorInterceptor.invoke(SessionInvalidatorInterceptor.java:55) [:2.3.1-Beta

       

       

      ===========================================================================================

       

      JSP FILE:

      <%@ page language="java" contentType="text/html; charset=ISO-8859-1"

                pageEncoding="ISO-8859-1"%>

      <%@ page import="javax.portlet.*"%>

      <%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

      <portlet:defineObjects/>

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

      <html>

            <body>

                               Mysql to syabase

                     <br>

           </body>

      </html>

      ==============================================================================================

       

      Java Class:

       


      public void doView(RenderRequest request,RenderResponse response) throws PortletException,IOException {


              response.setContentType("text/html"); 

              PrintWriter writer = response.getWriter();

       

              writer.write("MySqlToOracle:: Hello This is View Mode");

              PortletContext ctx = getPortletContext();

              request.setAttribute("one", "one");

       

       



      PortletRequestDispatcher rd = ctx.getRequestDispatcher("/WEB-INF/jsp/MySqlToOracle.jsp");


      rd.forward(request, response);

       

       




       

          }

      ================================================================

       

       

      Potlet.xml file:

      =============================================================

      <portlet>

                          <portlet-name>MySqlToOracle</portlet-name>

                          <display-name>MySql To Oracle</display-name>

                          <portlet-class>com.dbconvertor.converter.MySqlToOracle</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>MySql To Oracle</title>

                          </portlet-info>

                </portlet>

      ==================================================

        • 1. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
          julien_viet

          Hi,

           

          check the libs if your classpath or war file, it looks like there are a jar from jboss-portal (the former portal project) because I can see "org.gatein.pc.api.invocation.RenderInvocation cannot be cast to org.jboss.portal.portlet.invocation.PortletInvocation".

           

          Julien

          • 2. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
            sk0032729

            Hi Julien Viet,

             

            Thanks for your answer.

             

            I have added  portlet-portlet-2.0.0.jar in my classpath.

            Is there any other jar that I need to add in classpath.

            Please respond.

             

             

            Thanks

            Sonu Kumar

             

             

             

            .......

             

            One more thing here I want to tell that:

            This exception says ClassCastException. It means that jar files are avaialble but internally code in not able to operate.

            If I am missing any jar file then there should have exception like : NoClassDefinitionfound.

            Please give your suggesstion.

            • 3. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
              sk0032729

              I am getting error at following code:

               

                protected PortletInvocation getInvocation()

                 {

                    // Get the invocation

                    ServletRequest req = pageContext.getRequest();

                    return (PortletInvocation)req.getAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);

                 }

              }

               

               

              I think during interceptor instead of putting PortletInvocation in request attribute, GATEIN is putting RenderInvocation object which is creating problem, This might be issue in my portal configuration, but I am not sure where I am making a mistake.

              Is anyone there to help me.

              • 4. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
                antoine_h

                Hi Sonu Kumar,

                 

                When you say that, this is where the trouble comes from :

                I have added  portlet-portlet-2.0.0.jar in my classpath.

                you should remove this jar from your lib folder in your war.

                 

                this should resolve the problem, and you won't see the exception.

                 

                *******************

                usually, you don't need to add the jars of the GateIn portal, or for the Portlet api, in the War.

                you can add them in your project, when coding, so the java editor can rely on them, but when packaging your code in a war file, you don't put them in the lib folder.

                 

                with Maven, when you want to do so, you declare the lib dependency with scope "provided".

                it is provided by the server (the container).

                With Eclipse (without Maven), you declare that the lib dependency is not to put in the packaged war.

                 

                This lib, portlet-portlet-2.0.0.jar, is yet provided by Gatein on the server.

                 

                and that is enough (usually, unless for running on JBoss AS7, where there might be some module dependency to set, then... on this new type of server and classloader...).

                 

                *******************

                with the explaination of Julien, he pointed out that your war seem to come from JBoss Portal.

                 

                In GateIn, you can see that "org.gatein.pc.api.invocation.RenderInvocation" is inhériting from "org.gatein.pc.api.invocation.PortletInvocation".

                Your exception is talking of : "org.jboss.portal.portlet.invocation.PortletInvocation"

                 

                the package names are not the same.

                "org.jboss.portal.portlet.invocation" where the package in JBoss Portal (former product to GateIn).

                 

                "org.gatein.pc.api.invocation" is the package name for the new PortletInvocation class, that comes with GateIn portal.

                 

                That is why it cannot cast it to the "org.jboss.portal.portlet.invocation.PortletInvocation".

                 

                It seems that your jar, or may be another one, is comming from the former JBoss Portal version, and then, it tryies this casting, which is not possible.

                 

                whatever is happening with this odd trial of casting, the best is to remove the jar(s) from the libs (and classpath) of your war when packaging it and deploying it in the server.

                thoses libs are yet in the GateIn libs, and are yet available to the classloader, when your JSP is processed.

                 

                *******************

                I hope this will help you make your portlet run fine.

                and those explaination make it more clear about what is happening with the class cast exception.

                best regards,

                Antoine

                Presta-Expert, comment rechercher un expert.

                • 5. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
                  sk0032729

                  Hi ,

                   

                  sorry to disturb you again but I cought into another problem:

                  After removing portlet.jar from the war file and deployed again, I got following error:

                   

                  Caused by: org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved in either web.x

                  ml or the jar files deployed with this application

                          at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51) [:6.0.0.Final]

                          at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409) [:6.0.0.Final]

                          at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116) [:6.0.0.Final]

                          at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:239) [:6.0.0.Final]

                          at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:152) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:386) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:448) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1398) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Parser.parse(Parser.java:130) [:6.0.0.Final]

                          at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255) [:6.0.0.Final]

                          at org.apache.jasper.compiler.ParserController.parse(ParserController.java:103) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:196) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Compiler.compile(Compiler.java:358) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Compiler.compile(Compiler.java:338) [:6.0.0.Final]

                          at org.apache.jasper.compiler.Compiler.compile(Compiler.java:325) [:6.0.0.Final]

                          at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:607) [:6.0.0.Final]

                          at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:312) [:6.0.0.Final]

                          at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) [:6.0.0.Final]

                          at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) [:6.0.0.Final]

                          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]

                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]

                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

                          at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:734) [:6.0.0.Final]

                          at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:639) [:6.0.0.Final]

                          at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:576) [:6.0.0.Final]

                          at org.gatein.pc.portlet.impl.jsr168.api.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:142) [:2.

                  3.1-Beta02]

                          ... 274 more

                   

                   

                   

                   

                  I searched on the internet and found that it reqire some another jar files as given in this image:

                  Untitled.png

                   

                  But Still I am getting above exception.

                  Anybody can help me???

                  • 6. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
                    antoine_h

                    what server do you use : Tomcat ? JBoss ?

                    what gatein bundle ?

                     

                    With Tomcat and JBoss AS 5, you should not need to do anything.

                    only remove the portlet-portlet-2.0.0.jar from the war.

                     

                    With JBoss AS 7, you need to set the dependency to the module of GateIn that has the portlet-portlet-2.0.0.jar.

                    with this, you don't add another lib (in your war), you reuse the one that is yet provided by GateIn, in the JBoss AS 7.

                    with this version of AS, you have to declare the dependency.

                     

                    Antoine

                    J2EE, JBoss AS7, JBoss Portal, EPP, and GateIn, JSF, Richfaces, UXP.

                    • 7. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
                      sk0032729

                      Hi Antoine,

                       

                      Thanks For yours answer.

                       

                      I am using GateIn-3.2.0.Final-jbossas6 version.

                      What should I do to resolved this error. I have attached the deployed war here also

                      Please check and help me to resolve this error.

                       

                       

                      Thanks

                      Sonu KUmar

                      • 8. Re: Getting Class cast exception while deploying portlet in Gatein 3.2.0 final release.
                        antoine_h

                        Hi,

                         

                        Sorry, with jboss AS6, I don't know how the classloader is managed.

                        I don't know anything about this version.

                         

                        with version AS7, you should not have the same problem, as this version use a class loader isolation.

                         

                        can you use this version ?

                        (by the way, why taking the AS6, now ?)

                         

                        I have looked at the war.

                        usually, I don't put anything in my lib folder.

                        all the classes are taken from the container (jboss as5, or as7).

                        may be try without any lib ?

                         

                        Antoine

                        Presta-Expert, comment rechercher un expert.

                        1 of 1 people found this helpful