AnsweredAssumed Answered

Liferay JSR-168 (Portlets) and Web Scripts

Question asked by jett on Dec 28, 2008
Latest reply on Aug 5, 2010 by berenicestr69
I tried creating a portlet in Netbeans that references a Web Script in Alfresco. The webscript has not problems as I can "call" it directly from http://host/alfresco/services . When I deploy the portlet WAR file however, I am getting the following error message from the Tomcat log:

15:45:17,921 INFO  [AutoDeployDir:76] Processing alfsample.war
15:45:17,921 INFO  [PortletAutoDeployListener:78] Copying portlets for C:\Docume
nts and Settings\Jett\liferay\deploy\alfsample.war
15:45:17,921 INFO  [BaseDeployer:529] Deploying alfsample.war
  Expanding: C:\Documents and Settings\Jett\liferay\deploy\alfsample.war into E:
\POCs\azeus\liferay-portal-tomcat-5.5-5.1.2\temp\20081228154517921
  Copying 1 file to E:\POCs\azeus\liferay-portal-tomcat-5.5-5.1.2\temp\200812281
54517921\WEB-INF\classes
  Copying 1 file to E:\POCs\azeus\liferay-portal-tomcat-5.5-5.1.2\temp\200812281
54517921\WEB-INF\classes
  Copying 1 file to E:\POCs\azeus\liferay-portal-tomcat-5.5-5.1.2\temp\200812281
54517921\META-INF
15:45:22,953 INFO  [BaseDeployer:1244] Modifying Servlet 2.5 E:\POCs\azeus\lifer
ay-portal-tomcat-5.5-5.1.2\temp\20081228154517921\WEB-INF\web.xml
  Warning: META-INF\MANIFEST.MF modified in the future.
  Warning: WEB-INF\lib\alfresco-webscript-framework.jar modified in the future.
  Warning: WEB-INF\lib\spring-2.0.6.jar modified in the future.
  Warning: WEB-INF\lib\spring.jar modified in the future.
  Warning: WEB-INF\liferay-plugin-package.properties modified in the future.
  Warning: index.jsp modified in the future.
  Copying 20 files to E:\POCs\azeus\liferay-portal-tomcat-5.5-5.1.2\webapps\alfs
ample
  Copying 1 file to E:\POCs\azeus\liferay-portal-tomcat-5.5-5.1.2\webapps\alfsam
ple
  Deleting directory E:\POCs\azeus\liferay-portal-tomcat-5.5-5.1.2\temp\20081228
154517921
15:45:23,156 INFO  [PortletAutoDeployListener:88] Portlets for C:\Documents and
Settings\Jett\liferay\deploy\alfsample.war copied successfully
Dec 28, 2008 3:45:23 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/alfsample]
15:45:23,781 INFO  [PortletHotDeployListener:314] Unregistering portlets for alf
sample
15:45:23,781 INFO  [PortletHotDeployListener:342] 1 portlets for alfsample unreg
istered successfully
15:45:25,359 INFO  [PortletHotDeployListener:202] Registering portlets for alfsa
mple
15:45:25,375 INFO  [PortletHotDeployListener:209] 1 portlets for alfsample are r
eady for registration
15:45:25,375 ERROR [PortletHotDeployListener:534] java.lang.NullPointerException

java.lang.NullPointerException
        at org.alfresco.web.scripts.portlet.WebScriptPortlet.init(WebScriptPortl
et.java:86)
        at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:2
50)
        at com.liferay.portlet.PortletInstanceFactory._init(PortletInstanceFacto
ry.java:253)
        at com.liferay.portlet.PortletInstanceFactory._create(PortletInstanceFac
tory.java:123)
        at com.liferay.portlet.PortletInstanceFactory.create(PortletInstanceFact
ory.java:56)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(Po
rtletHotDeployListener.java:531)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy
(PortletHotDeployListener.java:230)
        at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(P
ortletHotDeployListener.java:114)
        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(H
otDeployUtil.java:84)
        at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(Ho
tDeployUtil.java:41)
        at com.liferay.portal.kernel.servlet.PortletContextListener.portalInit(P
ortletContextListener.java:92)
        at com.liferay.portal.kernel.util.PortalInitableUtil.init(PortalInitable
Util.java:48)
        at com.liferay.portal.kernel.servlet.PortletContextListener.contextIniti
alized(PortletContextListener.java:88)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:3764)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
216)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:760)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:74
0)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:926)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:889)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492
)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1217)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:293)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
        at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBas
e.java:1306)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1570)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1579)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.r
un(ContainerBase.java:1559)
        at java.lang.Thread.run(Thread.java:619)
15:45:25,390 INFO  [PortletHotDeployListener:285] 1 portlets for alfsample regis
tered successfully

My development environment is as follows :

1 Alfresco 3 running on Tomcat 5.5 port 8080
1 Liferay 5.x running on Tomcat 5.5 port 8090

My Liferay WAR configuration files follows

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"
             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"
             version="1.0">

    <portlet>
        <description>A Portlet</description>
        <portlet-name>Alfresco Portlet</portlet-name>
        <portlet-class>org.alfresco.web.scripts.portlet.WebScriptPortlet</portlet-class>

        <init-param>
            <param-name>authenticator</param-name>
            <param-value>webscripts.authenticator.jsr168.webclient</param-value>
        </init-param>
        <init-param>
            <name>http://localhost:8080</name>
            <value>/alfresco/service/sample/avm/stores</value>
        </init-param>

        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
        </supports>

        <portlet-info>
            <title>Portlet Title</title>
            <short-title>Portlet Short Title</short-title>
        </portlet-info>
    </portlet>


</portlet-app>

liferay-portlet.xml
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 4.4.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_4_4_0.dtd">

<liferay-portlet-app>
    <portlet>
        <portlet-name>Alfresco Portlet</portlet-name>
        <instanceable>true</instanceable>
    </portlet>
    <role-mapper>
        <role-name>administrator</role-name>
        <role-link>Administrator</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>guest</role-name>
        <role-link>Guest</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>power-user</role-name>
        <role-link>Power User</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>user</role-name>
        <role-link>User</role-link>
    </role-mapper>
</liferay-portlet-app>

liferay-plugin-package.properties
name=Alfresco Portlet
module-group-id=ipc
module-incremental-version=1
tags=validation
short-description=This portlet shows how to create JSP Validation portlet in Liferya.
change-log=Adapted to the latest version of Liferay.
page-url=http://www.liferay.com/web/guest/downloads
author=Liferay, Inc.
licenses=MIT

Anybody out there who has successfully "called" Alfresco web scripts from within a Liferay portlet? (I am not using the Alfresco Portlet because I need custom functionality)

Outcomes