Friday, January 15, 2010

Jetspeed-2 and NetBeans 6.8

Well, I have been looking at Open Source portal products that are "easy" to setup and use and yet powerful enough to satisfy an enterprise. I settled on trying Apache Jetspeed-2, since it has licensing that is favorable to a business that might want to use it in a product offering, and it is fully compliant to the Java Portlet Standard 2.0.

Installing the demo version was easy, and it came with a bunch of portlets ready to use. But, I want to be able to create portlets myself and the Java development tool I have been using the past several years is NetBeans.

At first, it seemed as if there would be no support for developing and deploying portlets from NetBeans to Jetspeed-2 or even modifying/building Jetspeed from source. I asked a friend and all he said was "use Eclipse instead!" Which really isn't an option where I'm working these days.

I installed the Generic Portlet plugin and added the Jetspeed-2 server (Tomcat 6 server type) to the Servers list in NetBeans. I created a new Java Web project and chose the Portal Framework, with View only premissions. NetBeans pulled in the Portlet Standard 2.0 libraries along with the Jetspeed-2 libraries and created a portlet source file for me. I thought, "cool, this will be easy.", but the hard part was just beginning. Of course, NetBeans creates an index.jsp file for you, but as I was working along and built the WAR file, I noticed that the portlet.xml file was not continuously updated like the web.xml file does.

After building, I tried to deploy via NetBeans. It works, but it was deployed as a regular web application and not as a portlet for Jetspeed-2. If the server properties for Tomcat allowed you to specify the deployment directory, then NetBeans might be able to deploy the code to the proper place. As it was, I could bring up my code as a web application, but Jetspeed-2 didn't know a thing about it, so it did not show up as an available portlet to add and use.

So for the moment, I have to manually drop the .war file into the /webapps/jetspeed/WEB-INF/deploy/local/ directory in order for my portlet to be usable. I also found that the path to my .jsp files is all messed up because you are deploying your .war file underneath Jetspeed-2, which is itself a web application. So the path I found that worked so nicely and that I was able to specify in my portlet.xml when I deployed dirctly from NetBeans, no longer worked and I kept getting NPE's or path not found errors from Jetspeed. Now that I know the actual path, I have a couple of ways to specify the correct path, but it was such a pain...

Now that I have a basic "Hello World" portlet running, I'll start working on more complicated portlets and plan on posting my experiences with NetBeans and Jetspeed-2. Until then, happy coding!