I have just deployed an updated version of the Struts 2 portlet archetype, which is based on Struts 2.1.1. The archetype also includes the jetty-pluto integration which should reduce the roundtrip from development to testing and running quite a lot.
To create a basic Struts 2 portlet with the archetype, run the command
mvn archetype:create
-DgroupId=<groupId>
-DartifactId=<artifactId>
-DarchetypeGroupId=org.apache.struts
-DarchetypeArtifactId=struts2-archetype-portlet
-DarchetypeVersion=2.1.1-SNAPSHOT
-DremoteRepositories=
http://people.apache.org/repo/m2-snapshot-repository
(all on one line)
Just replace <groupId> and <artifactId> with your real groupId and artifactId. Now you can just type mvn jetty:run -P pluto-embedded to run the portlet in pluto. The pluto-embedded profile does the magic of setting up the integration between the maven-jetty-plugin and pluto. To test it, just open a browser and point it to http://localhost:8080/<artifactId>/pluto/index.jsp
I have also included a class called JettyPlutoLauncher (you might recognize it from a previous entry) in the test sources of the generated project. It is simply a class with a main method that can be used to launch the portlet from your IDE. To use it with eclipse simply type mvn eclipse:eclipse -P pluto-embedded, import the project in Eclipse, and select to run the JettyPlutoLauncher class. Then open a browser to the same URL as described above.
This will hopefully get you up and running with Struts 2 portlet development pretty quick!
11 comments:
after following your steps, i get java.lang.NoClassDefFoundError: com.opensymphony.xwork2.util.logging.LoggerFactory
where can i get this dependency, and does a pom need to be updated?
Hi!
Thanks for the feedback.
Struts 2.1 and XWork 2.1 has not been officially released yet, so work is being done. Aparently, there has been a change somewhere that break things since this entry was written. Both Struts 2.1 and XWork 2.1 will have releases very soon, so I'll make sure to update the archetype and this example. Until then, you can check out the XWork 2 and Struts 2 trunks (http://www.opensymphony.com/xwork/cvs.action, http://struts.apache.org/dev/builds.html) to build and install the latest code and see if it works.
thanks for the quick response! i was able to download and install the sources ... unfortunately, i had to skip the test cases b/c many were failing ... oh well, at least your handy development tool works now! thanks for the work
as a follow up, i have built and tested my portlet, and now i want to deploy it to a Websphere App Server. Can you give any more information about the changes from 2.0.x to 2.1 in terms of portlet / web.xml configuration changes? i see that the PreparatorServlet but have not been able to find documentation on the usage of its replacements
The PreparatorServlet and the ServletContextHolderListener. The related issue can be found here
Other than that, you can find all the changes here
The major change is that the portlet support has been refactored into a plugin.
It does not work with Jahia Portal which works with JSR168.
Hi!
The Struts 2 Portlet framework is 100% JSR168 compliant. However, deployment of the portlet application can vary from server to server. If you have problems getting it to run in a specific portlet container, I suggest that you try the Struts 2 user mailing list, or register an issue at https://issues.apache.org/struts/secure/Dashboard.jspa with the details of your problem.
Thank you for your quick answer. I will post an issue.
For your information, when I deploy into Jahia Portal, I get a message :"Failed to load portlet org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher: javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found".
With OpenPortal Portlet Container, it runs well.
At the moment the the struts2 portlet archetype is no longer available at http://people.apache.org/repo/m2-snapshot-repository. Could you publish it in some other repository ?
Thanks
Do you know how tu use annotation validation within struts2 portlets?
I did tutorials for struts2 webapps. But there's no example for struts2 portlets.
Hi All,
I am trying to create a simple Struts 2 web application. I downloaded the latest Struts2 package (2.1.8...)
And i put all libs (jars in the lib folder) into my classpath.
my simple sample application can compile, but when i want to run it throws java.lang.NoClassDefFoundError: Lcom/opensymphony/xwork2/util/logging/Logger error.
I am pretty sure this file does exist and it is my classpath, but it keeps throwing this error.
Does anyone have any idea?
Post a Comment