Jahia Dev Forum > portlet render error

0 (0 Good)
0 (0 Bad)

portlet render error

by  lazkopaterdal »  2011/06/07 20:43

Hi All,
i am trying to write a new portlet just output is "Hello". but when deployed my .war file over Jahia-Manage portlet part, it is OK. There is no error on server log but when i add this portlet on my page, i get an error on logs like "Error while rendering portlet java.lang.NullPointerException". 

Is there anyone who knows my mistake?

thanks

  (lazkopaterdal)

Number of messages  5
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  jpaagt »  2011/06/07 20:43

More details are needed to understand the problem. Can you post the full stacktrace of the exception and if possible the code that might be generating the null pointer exception?

  (jpaagt)

Number of messages  8
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  lazkopaterdal »  2011/06/07 20:43

Thanks for your attension.
note: i use IntelijIDEA.
i create a web project and after my code changes, i create a war file. should i use another tool to write a portlet ?

exception logs
************
2010-05-14 10:44:15,293: ERROR [PlutoDispatchingProvider] - Error while rendering portlet
java.lang.NullPointerException
at org.apache.pluto.internal.impl.MimeResponseImpl.<init>(MimeResponseImpl.java:117)
at org.apache.pluto.internal.impl.RenderResponseImpl.<init>(RenderResponseImpl.java:57)
at org.apache.pluto.core.DefaultPortletEnvironmentService.createRenderResponse(DefaultPortletEnvironmentService.java:70)
at org.apache.pluto.core.PortletContainerImpl.doRender(PortletContainerImpl.java:192)
at org.jahia.services.applications.pluto.PlutoDispatchingProvider.render(PlutoDispatchingProvider.java:142)
at org.jahia.services.applications.DispatchingServiceImpl.getAppOutput(DispatchingServiceImpl.java:122)
at org.jahia.services.applications.DispatchingServiceImpl$$FastClassByCGLIB$$7271be17.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:113)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at org.jahia.services.applications.DispatchingServiceImpl$$EnhancerByCGLIB$$be17ba0f.getAppOutput(<generated>)
at org.jahia.ajax.gwt.commons.server.rpc.JahiaServiceImpl.drawPortletInstanceOutput(JahiaServiceImpl.java:286)
at sun.reflect.GeneratedMethodAccessor830.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.jahia.ajax.gwt.commons.server.AbstractJahiaGWTServiceImpl.service(AbstractJahiaGWTServiceImpl.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.jahia.ajax.gwt.commons.server.AbstractJahiaGWTServiceImpl.service(AbstractJahiaGWTServiceImpl.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jahia.bin.filters.jcr.JcrSessionFilter.doFilter(JcrSessionFilter.java:40)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
************

here is my codes : 

java class: 
*********************
package org.jahia.portlet; /**
* Created by IntelliJ IDEA.
* User: testusr
* Date: May 13, 2010
* Time: 2:46:25 PM
* To change this template use File | Settings | File Templates.
*/

import javax.portlet.*;
import java.io.PrintWriter;


public class ErdalPortlet8 extends GenericPortlet {
/**
* Init portlet method
*
* @param config Description of Parameter
* @throws PortletException Description of Exception
*/
public void init(PortletConfig config) throws PortletException {
//System.out.println("====== Begin process method test ======");
super.init(config);
}

public void processAction(ActionRequest request, ActionResponse response) {
//System.out.println("====== Begin process method ======");
}

/**
* render method
*/
public void doView(RenderRequest request, RenderResponse response) {
try {
// System.out.println("erdal");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("Hello world!");
}
catch (Exception ex) {
//ex.printStackTrace();
System.out.println("erdal : " + ex.getMessage());
}
}

/**
* destroy method
*/
public void destroy() {
super.destroy();
}
}

***********
portlet.xml

***********
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:portlet="http://java.sun.com/xml/ns/portlet"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
version="1.0">
<portlet>
<description>org.jahia.portlet.ErdalPortlet8</description>
<portlet-name>ErdalPortlet8</portlet-name>
<portlet-class>org.jahia.portlet.ErdalPortlet8</portlet-class>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>SimplePortlet</title>
</portlet-info>
</portlet>
</portlet-app>
****************

web.xml (after deploy portlet, its updated itself)
*********
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
</web-app>
*********

  (lazkopaterdal)

Number of messages  5
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  mabouchacra »  2011/06/07 20:43

 

Hi,

 

The code seems good to me. However, what about the code in the template? I've noticed that you can't render a portlet by letting it in the <template:field> tag, the code below won't work (at least in my case) :

<template:field name="myPortlet"/>

You should use the var attribute to display it, like this :

<template:field name="myPortlet" var="portlet" display="false"/>

<p>${portlet}</p>

 

Another thing to do, if this works, you'll probably get a classCastException telling you that your portlet can't be cast to javax.portlet.Portlet. This is because you have the portlet lib imported in your portlet (portlet-apiXXX.jar). You have to have it in your portlet so you can develop your portlet, however you have to remove it when you deploy the portlet in Jahia as Jahia already have the jar. So just remove the jar from the deployed portlet and everything should be fine.

Hope this'll helps!

Marc.

  (mabouchacra)

Number of messages  44
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  lazkopaterdal »  2011/06/07 20:43

Another thing to do, if this works, you'll probably get a classCastException telling you that your portlet can't be cast to javax.portlet.Portlet. This is because you have the portlet lib imported in your portlet (portlet-apiXXX.jar). You have to have it in your portlet so you can develop your portlet, however you have to remove it when you deploy the portlet in Jahia as Jahia already have the jar. So just remove the jar from the deployed portlet and everything should be fine.

Hope this'll helps!
Marc.[/quote]

in my portlet there is no jsp file. so i did not understand where i should put the "<template:field name="myPortlet" var="portlet" display="false"/>" . should i put it into jsp file or java class ?

i do not attach my jars when i prepare a war file. i put the related jars into server.
thanks

  (lazkopaterdal)

Number of messages  5
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  mabouchacra »  2011/06/07 20:43

I was talking about the code in the template. As I said the portlet looks good (I've developped the exact same on my own).
I assume that you have created a template in which you want to display your portlet? Or maybe your are just trying to render it in the demo site? If that's the case, just remove the portlet api jar from the deployed portlet and it should work.

Marc.

  (mabouchacra)

Number of messages  44
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  lazkopaterdal »  2011/06/07 20:43

Hi,
i am working on demo server. i removed the portlet-api.jar and protlet.jar from the server.
but i gave the below error :

Nested Exception is java.lang.ClassCastException: org.jahia.portlet.ErdalPortlet8 cannot be cast to javax.portlet.Portlet
at org.apache.pluto.core.PortletServlet.init(PortletServlet.java:128)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:808)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:599)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
at org.apache.pluto.core.DefaultPortletInvokerService.invoke(DefaultPortletInvokerService.java:217)
at org.apache.pluto.core.DefaultPortletInvokerService.render(DefaultPortletInvokerService.java:108)
at org.apache.pluto.core.PortletContainerImpl.doRender(PortletContainerImpl.java:201)
at org.jahia.services.applications.pluto.PlutoDispatchingProvider.render(PlutoDispatchingProvider.java:142)
at org.jahia.services.applications.DispatchingServiceImpl.getAppOutput(DispatchingServiceImpl.java:122)
at org.jahia.services.applications.DispatchingServiceImpl$$FastClassByCGLIB$$7271be17.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:113)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at org.jahia.services.applications.DispatchingServiceImpl$$EnhancerByCGLIB$$432ae0ca.getAppOutput(<generated>)
at org.jahia.ajax.gwt.commons.server.rpc.JahiaServiceImpl.drawPortletInstanceOutput(JahiaServiceImpl.java:286)
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:597)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.jahia.ajax.gwt.commons.server.AbstractJahiaGWTServiceImpl.service(AbstractJahiaGWTServiceImpl.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.jahia.ajax.gwt.commons.server.AbstractJahiaGWTServiceImpl.service(AbstractJahiaGWTServiceImpl.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jahia.bin.filters.jcr.JcrSessionFilter.doFilter(JcrSessionFilter.java:40)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

  (lazkopaterdal)

Number of messages  5
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  mabouchacra »  2011/06/07 20:43

Weird...
That's the stack I have when I let the jar.
Probably a stupid question, but have you restarted tomcat?

Marc.

  (mabouchacra)

Number of messages  44
Registration date
0 (0 Good)
0 (0 Bad)

Re: portlet render error

by  lazkopaterdal »  2011/06/07 20:43

thanks, it is working now. i have to reboot after install new portlet.
i think it oes not need to be rebooted because of installing over GUI.
thanks a lot.

  (lazkopaterdal)

Number of messages  5
Registration date
Contact
Share
Feedback

Get in touch

Whether you are a current user or if you are just evaluating Jahia, we are here to help.

Contact us

Share this page