You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-user@portals.apache.org by Megha Bokam <mb...@gmail.com> on 2004/11/02 00:13:57 UTC

NullPointerException: org.apache.pluto.invoker.impl.PortletInvokerImpl.invoke(PortletInvokerImpl.java:109)

Hi,

I downloaded source distribution  of pluto and installed it. I could able to 
run the testsuite and is working fine. (FYI: I am running tomcat 4.1.31, 
j2sdk1.4.2_05 on winXP).

I have created a "HelloWorldPortlet.java" in webapps/myPortlets

When I try to access my "Hello" portlet from 
http://localhost:8080/pluto/portal/hello page, its showing "Error occurred in 
portlet! " and I could see the following null pointer exception in the error 
logs.

-------------------------------------------------------------------------
SEVERE: Error in Portlet
java.lang.NullPointerException
	at org.apache.pluto.invoker.impl.PortletInvokerImpl.invoke
(PortletInvokerImpl.java:109)
	at org.apache.pluto.invoker.impl.PortletInvokerImpl.load
(PortletInvokerImpl.java:80)
	at org.apache.pluto.PortletContainerImpl.portletLoad
(PortletContainerImpl.java:201)
	at 
org.apache.pluto.portalImpl.core.PortletContainerWrapperImpl.portletLoad
(PortletContainerWrapperImpl.java:94)
	at org.apache.pluto.portalImpl.aggregation.PortletFragment.service
(PortletFragment.java:120)
	at org.apache.jsp.ColumnFragment_jsp._jspService
(ColumnFragment_jsp.java:63)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
.......

-------------------------------------------------------------------------

Any help on this is greatly appreciated.

I am using the following files to run my "HelloWorldPortlet" :

---------------------------------------------------------------------------
web.xml  ----->

<?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>
    <display-name>Pluto HelloWorld</display-name>
    <description>Hello World Portlet Description</description>
    <taglib>
        <taglib-uri>http://java.sun.com/portlet</taglib-uri>
        <taglib-location>/WEB-INF/tld/portlet.tld</taglib-location>
    </taglib>
    <security-role>
        <role-name>tomcat</role-name>
    </security-role>
</web-app>
----------------------------------------------------------------------------

portlet.xml  -------->

<?xml version="1.0" encoding="UTF-8"?>

<portlet-app
    xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
    version="1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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">

    <portlet>
        <description>HelloWorldDescription</description>
        <portlet-name>HelloWorldPortlet1</portlet-name>
        <display-name>HelloWorld Portlet #1</display-name>
		
        <portlet-class>com.myportlets.HelloWorldPortlet</portlet-class>

        <init-param>
            <name>display-name</name>
            <value>HelloWorld Portlet #1</value>
        </init-param>
	        
        <expiration-cache>-1</expiration-cache>
		        
        <supports>
	    <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
            <portlet-mode>EDIT</portlet-mode>
            <portlet-mode>HELP</portlet-mode>
	</supports>

        <supported-locale>en</supported-locale>        

	<portlet-info>
		<title>HelloWorld Portlet #1</title>
		<short-title>HelloWorld1</short-title>
		<keywords>HelloWorld, HelloWorlden</keywords>
        </portlet-info>

       <portlet-preferences>            
            <preference>
		<name>dummyName</name>
		<value>dummyValue</value>
		<read-only>false</read-only>
            </preference>			
            <preference>
		<name>dummyName2</name>
		<value>dummyValue2</value>
	    </preference>
            <preference>
                <name>readonly</name>
                <value>readonly</value>
                <read-only>true</read-only>
            </preference>
        </portlet-preferences>
        
        <security-role-ref>
            <role-name>plutoTestRole</role-name>
            <role-link>tomcat</role-link>
        </security-role-ref>
     </portlet>

 </portlet-app>
------------------------------------------------------------------------------
portletentityregistry.xml --------->

<?xml version="1.0" encoding="UTF-8"?>
<portlet-entity-registry>
    <application id="3">
        <definition-id>testsuite</definition-id>
        <portlet id="1">
            <definition-id>testsuite.TestPortlet1</definition-id>
            <preferences>
                <pref-name>TestName4</pref-name>
                <pref-value>TestValue4</pref-value>
                <read-only>true</read-only>
            </preferences>
        </portlet>
    </application>
    <application id="4">
        <definition-id>testsuite</definition-id>
        <portlet id="1">
            <definition-id>testsuite.TestPortlet2</definition-id>
            <preferences>
                <pref-name>org.apache.pluto.testsuite.BOGUS_KEY</pref-name>
                <pref-value>notTheOriginal</pref-value>
                <read-only>false</read-only>
            </preferences>
            <preferences>
                <pref-name>TEST</pref-name>
                <pref-value>TEST_VALUE</pref-value>
                <pref-value>ANOTHER</pref-value>
                <read-only>false</read-only>
            </preferences>
            <preferences>
                <pref-name>TestName4</pref-name>
                <pref-value>TestValue4</pref-value>
                <read-only>true</read-only>
            </preferences>
        </portlet>
    </application>

    <application id="5">
        <definition-id>myPortlets</definition-id>
        <portlet id="1">
            <definition-id>myPortlets.HelloWorldPortlet1</definition-id>
            <preferences>
                <pref-name>TestName5</pref-name>
                <pref-value>TestValue5</pref-value>
                <read-only>true</read-only>
            </preferences>
        </portlet>
    </application>
</portlet-entity-registry>

-----------------------------------------------------------------------------
pageregistry.xml -------------->

<?xml version="1.0"?>
<!-- 
Copyright 2004 The Apache Software Foundation
Licensed  under the  Apache License,  Version 2.0  (the "License");
you may not use  this file  except in  compliance with the License.
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed  under the  License is distributed on an "AS IS" BASIS,
WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
implied.

See the License for the specific language governing permissions and
limitations under the License.
-->
<portal>

    <fragment name="navigation" 
class="org.apache.pluto.portalImpl.aggregation.navigation.TabNavigation">
    </fragment>
    
    <fragment name="test" type="page">
        <navigation>
            <title>Test</title>
            <description>...</description>
        </navigation>

        <fragment name="row" type="row">

            <fragment name="col1" type="column">

                <fragment name="p1" type="portlet">
                    <property name="portlet" value="3.1"/>
                </fragment>

                <fragment name="p2" type="portlet">
                    <property name="portlet" value="4.1"/>
                </fragment>

            </fragment>

        </fragment>

    </fragment>

    <fragment name="hello" type="page">
        <navigation>
            <title>Hello</title>
            <description>...</description>
        </navigation>

        <fragment name="row2" type="row">

            <fragment name="col2" type="column">

                <fragment name="p3" type="portlet">
                    <property name="portlet" value="5.1"/>
                </fragment>

            </fragment>

        </fragment>

    </fragment>

</portal>

---------------------------------------------------------------------------
HelloWorldPortlet.java -------->

package com.myportlets;

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

public class HelloWorldPortlet extends GenericPortlet {

    private String portletName;

    public void init() throws PortletException {
 		System.out.println("HelloWorldPortlet::init()");
        portletName = getInitParameter("display-name");
        if(portletName==null) {
            portletName = "Test Portlet";
        }
	}//init()

	public void processAction(ActionRequest request, ActionResponse 
response)
		throws PortletException, java.io.IOException {

	}//processAction()

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

        response.setTitle(portletName);

        PortletMode mode = request.getPortletMode();
        WindowState state = request.getWindowState();
        if (!state.equals(WindowState.MINIMIZED) && (PortletMode.VIEW.equals
(mode) ||
        	PortletMode.EDIT.equals(mode) || PortletMode.HELP.equals
(mode)) ) {

        	response.setContentType("text/html");
            PortletContext context = getPortletContext();
            PortletRequestDispatcher rd = context.getRequestDispatcher
("/jsp/hello.jsp");
            rd.include(request,response);
        }//if
    }//doDispatch()

}//class HelloWorldPortlet

----------------------------------------------------------------------------
hello.jsp ----->

<h1>Hello World!!</h1>

------------------------------------------------------------------------------


Re: NullPointerException: org.apache.pluto.invoker.impl.PortletInvokerImpl.invoke(PortletInvokerImpl.java:109)

Posted by "David H. DeWolf" <dd...@apache.org>.
It looks to me like the portlet application context is not being found. 
  Have you made sure that your portal and portlet apps are configured to 
allow cross context dispatching?

This is done in tomcat by adding the crossContext="true" to your context 
configuration definition.

David

Megha Bokam wrote:
> Hi,
> 
> I downloaded source distribution  of pluto and installed it. I could able to 
> run the testsuite and is working fine. (FYI: I am running tomcat 4.1.31, 
> j2sdk1.4.2_05 on winXP).
> 
> I have created a "HelloWorldPortlet.java" in webapps/myPortlets
> 
> When I try to access my "Hello" portlet from 
> http://localhost:8080/pluto/portal/hello page, its showing "Error occurred in 
> portlet! " and I could see the following null pointer exception in the error 
> logs.
> 
> -------------------------------------------------------------------------
> SEVERE: Error in Portlet
> java.lang.NullPointerException
> 	at org.apache.pluto.invoker.impl.PortletInvokerImpl.invoke
> (PortletInvokerImpl.java:109)
> 	at org.apache.pluto.invoker.impl.PortletInvokerImpl.load
> (PortletInvokerImpl.java:80)
> 	at org.apache.pluto.PortletContainerImpl.portletLoad
> (PortletContainerImpl.java:201)
> 	at 
> org.apache.pluto.portalImpl.core.PortletContainerWrapperImpl.portletLoad
> (PortletContainerWrapperImpl.java:94)
> 	at org.apache.pluto.portalImpl.aggregation.PortletFragment.service
> (PortletFragment.java:120)
> 	at org.apache.jsp.ColumnFragment_jsp._jspService
> (ColumnFragment_jsp.java:63)
> 	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
> .......
> 
> -------------------------------------------------------------------------
> 
> Any help on this is greatly appreciated.
> 
> I am using the following files to run my "HelloWorldPortlet" :
> 
> ---------------------------------------------------------------------------
> web.xml  ----->
> 
> <?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>
>     <display-name>Pluto HelloWorld</display-name>
>     <description>Hello World Portlet Description</description>
>     <taglib>
>         <taglib-uri>http://java.sun.com/portlet</taglib-uri>
>         <taglib-location>/WEB-INF/tld/portlet.tld</taglib-location>
>     </taglib>
>     <security-role>
>         <role-name>tomcat</role-name>
>     </security-role>
> </web-app>
> ----------------------------------------------------------------------------
> 
> portlet.xml  -------->
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <portlet-app
>     xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
>     version="1.0"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     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">
> 
>     <portlet>
>         <description>HelloWorldDescription</description>
>         <portlet-name>HelloWorldPortlet1</portlet-name>
>         <display-name>HelloWorld Portlet #1</display-name>
> 		
>         <portlet-class>com.myportlets.HelloWorldPortlet</portlet-class>
> 
>         <init-param>
>             <name>display-name</name>
>             <value>HelloWorld Portlet #1</value>
>         </init-param>
> 	        
>         <expiration-cache>-1</expiration-cache>
> 		        
>         <supports>
> 	    <mime-type>text/html</mime-type>
>             <portlet-mode>VIEW</portlet-mode>
>             <portlet-mode>EDIT</portlet-mode>
>             <portlet-mode>HELP</portlet-mode>
> 	</supports>
> 
>         <supported-locale>en</supported-locale>        
> 
> 	<portlet-info>
> 		<title>HelloWorld Portlet #1</title>
> 		<short-title>HelloWorld1</short-title>
> 		<keywords>HelloWorld, HelloWorlden</keywords>
>         </portlet-info>
> 
>        <portlet-preferences>            
>             <preference>
> 		<name>dummyName</name>
> 		<value>dummyValue</value>
> 		<read-only>false</read-only>
>             </preference>			
>             <preference>
> 		<name>dummyName2</name>
> 		<value>dummyValue2</value>
> 	    </preference>
>             <preference>
>                 <name>readonly</name>
>                 <value>readonly</value>
>                 <read-only>true</read-only>
>             </preference>
>         </portlet-preferences>
>         
>         <security-role-ref>
>             <role-name>plutoTestRole</role-name>
>             <role-link>tomcat</role-link>
>         </security-role-ref>
>      </portlet>
> 
>  </portlet-app>
> ------------------------------------------------------------------------------
> portletentityregistry.xml --------->
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <portlet-entity-registry>
>     <application id="3">
>         <definition-id>testsuite</definition-id>
>         <portlet id="1">
>             <definition-id>testsuite.TestPortlet1</definition-id>
>             <preferences>
>                 <pref-name>TestName4</pref-name>
>                 <pref-value>TestValue4</pref-value>
>                 <read-only>true</read-only>
>             </preferences>
>         </portlet>
>     </application>
>     <application id="4">
>         <definition-id>testsuite</definition-id>
>         <portlet id="1">
>             <definition-id>testsuite.TestPortlet2</definition-id>
>             <preferences>
>                 <pref-name>org.apache.pluto.testsuite.BOGUS_KEY</pref-name>
>                 <pref-value>notTheOriginal</pref-value>
>                 <read-only>false</read-only>
>             </preferences>
>             <preferences>
>                 <pref-name>TEST</pref-name>
>                 <pref-value>TEST_VALUE</pref-value>
>                 <pref-value>ANOTHER</pref-value>
>                 <read-only>false</read-only>
>             </preferences>
>             <preferences>
>                 <pref-name>TestName4</pref-name>
>                 <pref-value>TestValue4</pref-value>
>                 <read-only>true</read-only>
>             </preferences>
>         </portlet>
>     </application>
> 
>     <application id="5">
>         <definition-id>myPortlets</definition-id>
>         <portlet id="1">
>             <definition-id>myPortlets.HelloWorldPortlet1</definition-id>
>             <preferences>
>                 <pref-name>TestName5</pref-name>
>                 <pref-value>TestValue5</pref-value>
>                 <read-only>true</read-only>
>             </preferences>
>         </portlet>
>     </application>
> </portlet-entity-registry>
> 
> -----------------------------------------------------------------------------
> pageregistry.xml -------------->
> 
> <?xml version="1.0"?>
> <!-- 
> Copyright 2004 The Apache Software Foundation
> Licensed  under the  Apache License,  Version 2.0  (the "License");
> you may not use  this file  except in  compliance with the License.
> You may obtain a copy of the License at 
> 
> http://www.apache.org/licenses/LICENSE-2.0
> 
> Unless required by applicable law or agreed to in writing, software
> distributed  under the  License is distributed on an "AS IS" BASIS,
> WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
> implied.
> 
> See the License for the specific language governing permissions and
> limitations under the License.
> -->
> <portal>
> 
>     <fragment name="navigation" 
> class="org.apache.pluto.portalImpl.aggregation.navigation.TabNavigation">
>     </fragment>
>     
>     <fragment name="test" type="page">
>         <navigation>
>             <title>Test</title>
>             <description>...</description>
>         </navigation>
> 
>         <fragment name="row" type="row">
> 
>             <fragment name="col1" type="column">
> 
>                 <fragment name="p1" type="portlet">
>                     <property name="portlet" value="3.1"/>
>                 </fragment>
> 
>                 <fragment name="p2" type="portlet">
>                     <property name="portlet" value="4.1"/>
>                 </fragment>
> 
>             </fragment>
> 
>         </fragment>
> 
>     </fragment>
> 
>     <fragment name="hello" type="page">
>         <navigation>
>             <title>Hello</title>
>             <description>...</description>
>         </navigation>
> 
>         <fragment name="row2" type="row">
> 
>             <fragment name="col2" type="column">
> 
>                 <fragment name="p3" type="portlet">
>                     <property name="portlet" value="5.1"/>
>                 </fragment>
> 
>             </fragment>
> 
>         </fragment>
> 
>     </fragment>
> 
> </portal>
> 
> ---------------------------------------------------------------------------
> HelloWorldPortlet.java -------->
> 
> package com.myportlets;
> 
> import javax.portlet.*;
> import java.io.*;
> 
> public class HelloWorldPortlet extends GenericPortlet {
> 
>     private String portletName;
> 
>     public void init() throws PortletException {
>  		System.out.println("HelloWorldPortlet::init()");
>         portletName = getInitParameter("display-name");
>         if(portletName==null) {
>             portletName = "Test Portlet";
>         }
> 	}//init()
> 
> 	public void processAction(ActionRequest request, ActionResponse 
> response)
> 		throws PortletException, java.io.IOException {
> 
> 	}//processAction()
> 
>     public void doDispatch(RenderRequest request, RenderResponse response)
>     	throws PortletException, IOException {
> 
>         response.setTitle(portletName);
> 
>         PortletMode mode = request.getPortletMode();
>         WindowState state = request.getWindowState();
>         if (!state.equals(WindowState.MINIMIZED) && (PortletMode.VIEW.equals
> (mode) ||
>         	PortletMode.EDIT.equals(mode) || PortletMode.HELP.equals
> (mode)) ) {
> 
>         	response.setContentType("text/html");
>             PortletContext context = getPortletContext();
>             PortletRequestDispatcher rd = context.getRequestDispatcher
> ("/jsp/hello.jsp");
>             rd.include(request,response);
>         }//if
>     }//doDispatch()
> 
> }//class HelloWorldPortlet
> 
> ----------------------------------------------------------------------------
> hello.jsp ----->
> 
> <h1>Hello World!!</h1>
> 
> ------------------------------------------------------------------------------
> 
>