Monday, March 31, 2008

Experimenting with JSR286 (Portlet 2.0) support in Struts 2

I've started playing with portlet 2.0 support in Struts 2, and the experimental JSR286 plugin currently supports both basic event and resource serving, which are two of the most anticipated features of the new portlet specification. In parallel, I've adapted the maven-jetty-pluto-embedded artifact to support Pluto 2.0, so I can easily develop and test directly with Maven or my IDE.

This is still very experimental, but feel free to give it a try. I've also created a very basic sample portlet that uses the plugin which you can check out and build. Note that you might have to build Pluto 2.0 from source unless you find it in a Maven repository somewhere.

Please drop me a line if you find anything that doesn't work, or if you want to discuss implementation and features.

16 comments:

Anonymous said...

hi Nils,

this is awesome, i've been using your plug-in for my portlet development... thanks a bunch! =)

-edwin

Lee said...

Hi Nils,

how did you work around https://issues.apache.org/jira/browse/PLUTO-463 ?

I'm working on Porlet support for Grails and need to run an embedded Pluto in a similar manner to your maven plugin.

cheers

Lee

Nils-Helge Garli Hegvik said...

Hi!

I had to write my own session manager and instruct Jetty to use it. Take a look at these two classes:

https://boss.bekk.no/repos/projects/jsr286-portlet/src/test/java/org/apache/struts2/JettyPlutoLauncher.java

https://boss.bekk.no/repos/projects/maven-jetty-pluto-embedded/branches/2_0_BRANCH/src/main/java/com/bekk/boss/pluto/embedded/jetty/util/PlutoJettySessionManager.java

Lee said...

Thanks a lot Nils, I also found I had to override AbstrastSessionManager.complete() so I added the following to your SessionManager

public void complete(HttpSession session) {
if (session instanceof AbstractSessionManager.Session) {
super.complete(session);
} else {
session.invalidate();
}
}

cheers

Lee

Lee said...

Sorry, that complete method invalids the session too often. Best to change it to :

public void complete(HttpSession session) {
if (session instanceof AbstractSessionManager.Session) {
super.complete(session);
}
}

cheers

Lee

Anonymous said...

Portlet support is undergoing drastic changes. If you have already developed your portlet application in 2.0.9, you will have to do a couple of changes before you can move to 2.0.11 or 2.1. This includes changes in web.xml.

Anonymous said...

Nils,

In looking at your new embedded Pluto code I noticed you have a wrapper for the RequestDistpacher (CustomDispatcher). Can you explain why this is necessary? It looks like the wrapper is simply copying request attributes from the PortalServletRequest to the underlying jetty Request. Is there a bug/issue you are trying to work-around here?

Thanks for all your hard work on this stuff

Nils-Helge Garli Hegvik said...

Yes, if I remember correctly it was because of this issue: https://issues.apache.org/jira/browse/PLUTO-463

Anonymous said...

Nils,

I discovered that when using version 6.1.11 of the Jetty plugin I was able to get all of this working without either the CustomDispatcher or the PlutoJettySessionManager. Perhaps something has been fixed on the Jetty side?

Nils-Helge Garli Hegvik said...

Yeah, could be. When I reported the issue I was using 6.1.7. I'll take a note of it and try to figure it out when I dig up the code again!

Tim said...

Hi Nils, is Jsr268 Struts 2 libs yours hand made? Can't find it in Struts2 Portlet Plugin.

Tim said...

I'm stupid, forget it.

Anonymous said...

Hi Nils. Do you have some experience with JSR-286 on WebSphere Portal 6.1? I try to use your plugin, but it still throws some exception. Is needed some special instalation or somethink else important to do?

Thanks.

Camel

Nils-Helge Garli Hegvik said...

No, just install like a regular portlet. What exceptions are you getting?

Anonymous said...

He can´t found class LoggerFactory ...
Could you send me list of jars, which are you using? Because, I try to load lot of libraries, but always something missing, or is overrided by other class from the same package but other version.

Or could you send me your .war?
It will help me very much. (I hope ...)
Here is my e-mail: svetoslapek@email.cz

Thanks

Camel

Johannes said...

is there a struts2 release planned which includes the jsr286 support?

in the current version in sandbox the support for portlet events is broken.