Skip to main content

Using NetBeans to Help Develop New JSR-168 and JSR-286 Portlets

Posted by garysweaver on August 19, 2008 at 12:59 PM PDT

Looking for information on how to quickly develop new JSR-168 and JSR-286 compliant portlets in an IDE an article called Developing Portlets with NetBeans Portal Pack 2.0.

Those instructions appear to mostly be geared for those looking to develop JSR-286 compliant portlets, so if that's your goal, those instructions may work for you.

However, I had a hard time getting through them for the purpose of using NetBeans 6.1 to quickly generate JSR-168 compliant portlets.

I really wanted to get it working as close to the original instructions as possible, so at first I attempted to add a "OpenPortal Portlet Container 1.0" Server in NetBeans. However I ran into a few problems with that. In the end, it was easiest for me to install portlet-container 1.0_02 (download) in Tomcat 5.5 using these instructions, then adding that Tomcat 5.5 instance as a server in NetBeans 6.1 via Tools -> Servers -> Add Server, and then mostly following the rest of the instructions in Developing Portlets with NetBeans Portal Pack 2.0 to create the portlet, with the exception of having to specify Tomcat 5.5 as the server.

When complete, I was a little surprised (I guess because I didn't understand the inner-workings well-enough) to find that the war I "deployed" to Tomcat wasn't actually in Tomcat's webapps directory. However, with a little searching, I found the war under my NetBeans project dir.

It would have also been nice to have it create a Maven 2 project, but it's still a great start if you just want to create a new portlet quickly! Note also that there are tools to do this in Eclipse. I couldn't find a way to do it in IDea though.

Related Topics >>

Comments

The other solution to the issue above mentioned by Cris J Holdorph was to just remove the resource-bundle element from portlet.xml generated by the portal pack. That might be a better solution than having to define properties, if you'd rather not use them. Also note, that Eric Dalquist thinks that the reason it worked without issue in uPortal 3.0.1 was because pluto 1.1.5 *might* have a bug related to this. If you're interested in that, you can track it: https://issues.apache.org/jira/browse/PLUTO-496

uPortal 3.0.1 can deploy, publish, and display a HelloWorld portlet created using the NetBeans Portal Pack 2.0 without modifications.

However, uPortal 2.5.3.1 GA will fail to render with the following error if the following properties are not set in Source Packages -> (portlet package) -> messages.properties:

javax.portlet.title=Hello World Portlet
javax.portlet.short-title=Hello World
javax.portlet.keywords=portlet,hello,world

then rebuild, and deploy the new war to uPortal via:

cd (uportal 2.5.3.1 quickstart)/uPortal_rel-2-5-3-1-GA/
ant deployPortletApp -DportletApp=(path to your home directory)/NetBeansProjects/HelloWorld/dist/HelloWorld.war

The error that you get if you don't set these properties in the messages.properties is:

[java] SEVERE: Servlet.service() for servlet MyPortlet threw exception
[java] java.util.MissingResourceException: Can't find resource for bundle org.jasig.portal.container.om.common.LanguageImpl$ResourceBundleImpl, key javax.portlet.title
[java] at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
[java] at java.util.ResourceBundle.getString(ResourceBundle.java:285)
[java] at org.jasig.portal.container.om.common.LanguageImpl.(LanguageImpl.java:53)
[java] at org.jasig.portal.container.om.common.LanguageSetImpl.createLanguage(LanguageSetImpl.java:104)
[java] at org.jasig.portal.container.om.common.LanguageSetImpl.addLanguage(LanguageSetImpl.java:98)
[java] at org.jasig.portal.container.om.common.LanguageSetImpl.initResourceBundle(LanguageSetImpl.java:130)
[java] at org.jasig.portal.container.om.common.LanguageSetImpl.get(LanguageSetImpl.java:64)
[java] at org.apache.pluto.core.impl.PortletConfigImpl.getResourceBundle(PortletConfigImpl.java:64)
[java] at javax.portlet.GenericPortlet.getTitle(GenericPortlet.java:203)
[java] at javax.portlet.GenericPortlet.render(GenericPortlet.java:177)
[java] at org.apache.pluto.core.PortletServlet.dispatch(PortletServlet.java:205)
[java] at org.apache.pluto.core.PortletServlet.doGet(PortletServlet.java:145)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)