Import Creator 2 JSR-168 Portlet Projects into NetBeans 6.0
By poting on Oct 06, 2007
Visual Web JSF Portlet Builder feature was dropped for NetBeans 5.5 due to schedule/resource constraints. As you may already know, Visual Web in NetBeans 6.0 product release will not support the JSR-168 portlet that Sun Java Studio Creator 2 supports as well. Creator 2 users are relying on this feature and cannot move to NetBeans until it is on par with what they have now. However, in this article, I will explain how to import your Creator 2 portlet projects into NetBeans 6.0 and continue to work on them and deploy them on OpenPortal Portlet Container and OpenPortal Portal Server from the NetBeans IDE. Hopefully, the Visual Web team will implement a solution to automate these manual steps and make it into an add-on download from the NetBeans update center.
There are 2 parts of tasks for this integration. The first part is to install and configure the Portlet Container on your NetBeans IDE. This is an one time only setup needed for NetBeans developers to use the open source software OpenPortal Project to develop and test their portlets. The second part is to import user's Creator 2 JSR-168 portlet projects from NetBeans 6.0 and deploy it on the OpenPortal portlet container.Install and Configure the OpenPortal Portal Server (one time only setup):
- Install GlassFish Application Server:
GlassFish is an open source enterprise application server. You can download the latest version of GlassFish Application server from here. There is no need to install separate GlassFish Application Server for portlet deployment if you have already installed it standalone or bundled by other IDE such as NetBeans.
- Install OpenPortal Portlet Container on GlassFish Application Server:
The OpenPortal Portlet Container is an enterprise-class Portlet Container which is part of the overall OpenPortal Project. To install OpenPortal Portlet Container on the GlassFish Application Server, download the latest binary first and then follow the installation instructions in the Download page (1.0_01 binary is been used here).
java -jar portlet-container-configurator.jar
- Install NetBeans Portal Pack 2.0 on NetBeans 6.0:
Portal Pack 2.0 is a plug-in for NetBeans IDE; it provides supports to create JSR-168 portlet and the deployment of portlets from the NetBeans IDE. You can find the installation instructions for the plug-ins in its download page. Only the following 2 plug-ins are needed for this article:
- Base PSFramework - Base framework library for portal server integration.
- OpenSource PC - Plug-in to integrate OpenPortal Portlet Container
- Add OpenPortal Portlet Container on NetBeans 6.0:
You can find more details and options of how to configure OpenPortal Portlet Container in your NetBeans IDE by using this user guide. Below are simple steps to add the server in the NetBeans IDE:
- Select Tools > Servers
- Click on "Add Server..."
- Select "OpenPortal Portlet Container 1.0" from the list of available servers
- Select "GlassFish" from the dropdown
- Enter "GlassFish Home" and "Password" fields
(Default password for GlassFish is "adminadmin"
- Click on "Next" and then "Finish" to accept all
- Prepare your Creator 2 Project:
I will use the Creator 2 tutorial Developing a Portlet Application to explain the migration. Before importing into NetBeans 6.0, remember to right click on the project node and select "Clean Project" to remove the Creator 2 bundled files that may conflict our later migration. Then copy the whole project to a new location.
- Open the Portlet Project from NetBeans 6.0:
When opening the portlet project, a warning dialog shown with the message "Reference Problems" will appear. That is because the current Visual Web Pack does not directly support the JSR-168 Portlet specification. We can resolve this reference issue by doing the following steps:
- Download the JSF/Portlet Integration Library file jsf-portlet.jar from OpenPortal JSF Portlet Bridge which allows JSF applications to run within a Portlet environment.
- Right click on the Project node and select Properties. Select category
"Packaging" and remove those 2 missing libraries,
portlet-runtime and jsf-portlet-runtime. Then use "Add File/Folder"
to add the Portlet Bridge jar file we just downloaded with the value
"WEB-INF/lib" for Path in WAR field.
Remove the missing libraries
Add the JSF/Portlet Integration Library file
- In the same Properties window, select category "Run"
and change the Server to "OpenPortal Portlet Container 1.0".
- Be careful to not use JDK 6 for "Source/Binary Format" under the category Sources. It will not work for most current servers!
- Deploy the Portlet Project on OpenPortal Portlet Container:
Now we have the final project ready to deploy. Click on the green arrow button "Run Main Project (F6)" to deploy the portlet project on OpenPortal Portlet Container.
You will see your portlet project deployed on your browser! If the server does not show, you can expand the Servers node under NetBeans IDE's Services tab until you see your portlet under the server OpenPortal Portlet Container 1.0. Right click on your portlet and select "Show Portlet". Or you can type the following URL in your browser to see all portlets that are currently deployed to the Portlet Container.
- Download the Example Project:
You can download the example project we used for this article.