The answer to the first question is of course yes. Since Struts 2 Portlet is a JSR168 framework, it can be deployed to any portlet container supporting the JSR168 standard, including JBoss Portal.
To answer the second question, I had to browse through the JBoss Portal reference guide, and found that you have to write two custom deployment descriptors.
For the Struts 2 sample portlet application, I added the following:
portlet-instances.xml
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE deployments PUBLIC
"-//JBoss Portal//DTD Portlet Instances 2.6//EN"
"http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd">
<deployments>
<deployment>
<instance>
<instance-id>StrutsPortletInstance</instance-id>
<portlet-ref>StrutsPortlet</portlet-ref>
</instance>
</deployment>
</deployments>
struts2-portlet-object.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE deployments PUBLIC
"-//JBoss Portal//DTD Portal Object 2.6//EN"
"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
<deployments>
<deployment>
<parent-ref>default.default</parent-ref>
<if-exists>overwrite</if-exists>
<window>
<window-name>StrutsPortletWindow</window-name>
<instance-ref>StrutsPortletInstance</instance-ref>
<region>center</region>
<height>1</height>
</window>
</deployment>
</deployments>
I added both files to the WEB-INF folder of the application.
With both files added, put the war file in the deploy folder of your server, and your portlet should appear on the default page of the portal.
Consult the documentation for a description of these files, and the relations between the names and ids in them.
I would rather not have to specify the instances, page and placement of the portlet in a descriptor in the portlet application itself, but that is how it was described in the documentation.
Update:
It appears that these descriptors are indeed optional. You can deploy a plain Struts 2 Portlet (or any JSR168 portlet for that matter) and do all the required steps in the portal administration.
6 comments:
It can't be initialized due to xml parse. does anybody know how to deal?
Cheers,
Lanette
Seems like there's a couple of closing tags missing in the example. Add closing tags for <parent-ref> and <if-exists> and see if that helps. If that doesn't help, it's impossible to say what the problem is without more information.
I've updated the example now.
Hi,
I am getting this error when i deploy the struts2 portlet application in jboss-portal-2.6.6.GA
Please help me
14:39:06,700 INFO [TomcatDeployer] deploy, ctxPath=/bookmarkportlet, warUrl=...
/deploy/bookmarkportlet.war/
14:39:07,246 ERROR [STDERR] org.jboss.portal.portlet.container.PortletInitializa
tionException: The portlet BookmarkPortlet threw a runtime exception during init
14:39:07,246 ERROR [STDERR] at org.jboss.portal.portlet.impl.jsr168.PortletC
ontainerImpl.start(PortletContainerImpl.java:264)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.portlet.impl.container.Portl
etApplicationContextImpl.startPortletApplication(PortletApplicationContextImpl.j
ava:135)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.portlet.deployment.jboss.Por
tletAppDeployment.start(PortletAppDeployment.java:151)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.core.deployment.jboss.Portle
tAppDeployment.start(PortletAppDeployment.java:96)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.server.deployment.jboss.Depl
oymentContext.start(DeploymentContext.java:99)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.server.deployment.jboss.Port
alDeploymentInfoContext.start(PortalDeploymentInfoContext.java:220)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.server.deployment.jboss.Serv
erDeployer.start(ServerDeployer.java:217)
14:39:07,246 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainD
eployer.java:1025)
14:39:07,246 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(Main
Deployer.java:819)
14:39:07,246 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor239.invoke
(Unknown Source)
14:39:07,246 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
14:39:07,246 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
97)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.
invoke(ReflectedDispatcher.java:155)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invoc
ation.java:94)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.
invoke(AbstractInterceptor.java:133)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationI
nterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invo
ke(AbstractMBeanInvoker.java:264)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
eanServerImpl.java:659)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
roxyExt.java:210)
14:39:07,246 ERROR [STDERR] at $Proxy222.deploy(Unknown Source)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.server.deployment.jboss.Serv
erDeployer.deploy(ServerDeployer.java:259)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.server.deployment.WebAppAdap
ter.deploy(WebAppAdapter.java:53)
14:39:07,246 ERROR [STDERR] at org.jboss.portal.server.deployment.WebAppInte
rcepter.handleNotification(WebAppIntercepter.java:159)
14:39:07,246 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor4.invoke(U
nknown Source)
14:39:07,246 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
14:39:07,246 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
97)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.notification.NotificationListene
rProxy.invoke(NotificationListenerProxy.java:153)
14:39:07,246 ERROR [STDERR] at $Proxy224.handleNotification(Unknown Source)
14:39:07,246 ERROR [STDERR] at org.jboss.mx.util.JBossNotificationBroadcaste
rSupport.handleNotification(JBossNotificationBroadcasterSupport.java:127)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.util.JBossNotificationBroadcaste
rSupport.sendNotification(JBossNotificationBroadcasterSupport.java:108)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.SubDeployerSupport.emitN
otification(SubDeployerSupport.java:340)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.SubDeployerSupport.start
(SubDeployerSupport.java:308)
14:39:07,262 ERROR [STDERR] at org.jboss.web.AbstractWebContainer.start(Abst
ractWebContainer.java:482)
14:39:07,262 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor148.invoke
(Unknown Source)
14:39:07,262 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
14:39:07,262 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
97)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.
invoke(ReflectedDispatcher.java:155)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invoc
ation.java:94)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.
invoke(AbstractInterceptor.java:133)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationI
nterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.DynamicInterceptor.i
nvoke(DynamicInterceptor.java:97)
14:39:07,262 ERROR [STDERR] at org.jboss.system.InterceptorServiceMBeanSuppo
rt.invokeNext(InterceptorServiceMBeanSupport.java:238)
14:39:07,262 ERROR [STDERR] at org.jboss.wsf.container.jboss42.DeployerInter
ceptor.start(DeployerInterceptor.java:87)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.SubDeployerInterceptorSu
pport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.SubDeployerInterceptor.i
nvoke(SubDeployerInterceptor.java:95)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invo
ke(AbstractMBeanInvoker.java:264)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
eanServerImpl.java:659)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
roxyExt.java:210)
14:39:07,262 ERROR [STDERR] at $Proxy200.start(Unknown Source)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainD
eployer.java:1025)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(Main
Deployer.java:819)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(Main
Deployer.java:782)
14:39:07,262 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor27.invoke(
Unknown Source)
14:39:07,262 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
14:39:07,262 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
97)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.
invoke(ReflectedDispatcher.java:155)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invoc
ation.java:94)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.
invoke(AbstractInterceptor.java:133)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationI
nterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invo
ke(AbstractMBeanInvoker.java:264)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
eanServerImpl.java:659)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
roxyExt.java:210)
14:39:07,262 ERROR [STDERR] at $Proxy9.deploy(Unknown Source)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentSca
nner.deploy(URLDeploymentScanner.java:421)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentSca
nner.scan(URLDeploymentScanner.java:634)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeployme
ntScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeployme
ntScanner.startService(AbstractDeploymentScanner.java:336)
14:39:07,262 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInt
ernalStart(ServiceMBeanSupport.java:289)
14:39:07,262 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInt
ernalLifecycle(ServiceMBeanSupport.java:245)
14:39:07,262 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor3.invoke(U
nknown Source)
14:39:07,262 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
14:39:07,262 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
97)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.
invoke(ReflectedDispatcher.java:155)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invoc
ation.java:94)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:86)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invo
ke(AbstractMBeanInvoker.java:264)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
eanServerImpl.java:659)
14:39:07,262 ERROR [STDERR] at org.jboss.system.ServiceController$ServicePro
xy.invoke(ServiceController.java:978)
14:39:07,262 ERROR [STDERR] at $Proxy0.start(Unknown Source)
14:39:07,262 ERROR [STDERR] at org.jboss.system.ServiceController.start(Serv
iceController.java:417)
14:39:07,262 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor9.invoke(U
nknown Source)
14:39:07,262 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
14:39:07,262 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
97)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.
invoke(ReflectedDispatcher.java:155)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invoc
ation.java:94)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:86)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invo
ke(AbstractMBeanInvoker.java:264)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
eanServerImpl.java:659)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
roxyExt.java:210)
14:39:07,262 ERROR [STDERR] at $Proxy4.start(Unknown Source)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.SARDeployer.start(SARDep
loyer.java:304)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainD
eployer.java:1025)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(Main
Deployer.java:819)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(Main
Deployer.java:782)
14:39:07,262 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(Main
Deployer.java:766)
14:39:07,262 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)
14:39:07,262 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(N
ativeMethodAccessorImpl.java:39)
14:39:07,262 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
14:39:07,262 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5
97)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.
invoke(ReflectedDispatcher.java:155)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invoc
ation.java:94)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.
invoke(AbstractInterceptor.java:133)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationI
nterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:88)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invo
ke(AbstractMBeanInvoker.java:264)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
eanServerImpl.java:659)
14:39:07,262 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
roxyExt.java:210)
14:39:07,262 ERROR [STDERR] at $Proxy5.deploy(Unknown Source)
14:39:07,262 ERROR [STDERR] at org.jboss.system.server.ServerImpl.doStart(Se
rverImpl.java:482)
14:39:07,262 ERROR [STDERR] at org.jboss.system.server.ServerImpl.start(Serv
erImpl.java:362)
14:39:07,262 ERROR [STDERR] at org.jboss.Main.boot(Main.java:200)
14:39:07,262 ERROR [STDERR] at org.jboss.Main$1.run(Main.java:508)
14:39:07,262 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
14:39:07,262 ERROR [STDERR] Caused by: java.lang.ClassCastException: org.apache.
struts2.portlet.dispatcher.Jsr168Dispatcher cannot be cast to javax.portlet.Port
let
14:39:07,262 ERROR [STDERR] at org.jboss.portal.portlet.impl.jsr168.PortletC
ontainerImpl.start(PortletContainerImpl.java:231)
14:39:07,262 ERROR [STDERR] ... 119 more
Appreciate your help
Thanks
VK
I'm guessing you have the portlet api jar in the lib folder of your webapp. If you still have problems, try posting to the Struts 2 user mailing list.
Hi, thx for your Struts 2 Portlet post. I try to extend your portlet add my logic. And i have some problems. I try to submit action and getting NullPointerException. Here is stack trace piece:
javax.portlet.PortletException: org.apache.jasper.JasperException: java.lang.NullPointerException
at org.jboss.portal.portlet.impl.jsr168.api.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:91)
at org.apache.struts2.portlet.result.PortletResult.executeRenderResult(PortletResult.java:201)
at org.apache.struts2.portlet.result.PortletResult.doExecute(PortletResult.java:92)
...
org.apache.jasper.JasperException: java.lang.NullPointerException
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:415)
Thx.
Post a Comment