Oracle9iAS Portal Developer Kit
Using JDeveloper3.2 to Build Java Portlets

JDeveloper is a full-featured, integrated development environment for creating multi-tier Java applications. It enables you to develop, debug, and deploy Java client applications, dynamic HTML applications, Web and application server components and database stored procedures based on industry-standard models. JDeveloper can also be used to develop and debug Java portlets for Oracle9iAS Portal.

This document explains how you can use JDeveloper3.2 to develop, debug and deploy your Java portlets for Oracle9iAS Portal. This document covers:

  1. How to use JDeveloper to create your Workspace, Project and add your Java files to the project.
  2. How to setup your Project to work with PDK-Java, so you can compile portlets that use the PDK-Java API.
  3. How to deploy a Web provider on your local Oracle HTTP Server.
  4. How to register the Web provider with a remote Oracle9iAS Portal installation to run the portlets.
  5. How to setup Remote Debugging for JDeveloper so you can set breakpoints in your Java portlets and debug them.
  6. General guidelines to keep in mind while using JDeveloper to build Java portlets.

Assumptions

GETTING STARTED

JDeveloper comes with extensive online documentation that will help you get started. The section "Starting a New Programming Project" under the Help Menu covers most of these details.

As part of this exercise, we provide a simple set of steps for you to follow.

  1. Create a new Workspace From the File menu, click New Workspace. Next, choose Rename from the File menu and rename this as MyPortal. This creates a MyPortal.jws entry in your Jdeveloper Workspace window.

  2. Add a new Project From the File menu, click New Project. This option takes you through a few screens before creating a new project. Follow the online help for further details. We provide a few screenshots to provide a quick illustration.

 

 

 

  1. Add a File to the Project. In the Workspace tab window, click on the + icon, to add a file to the project. You can now add an existing PDK-Java sample java file to the project. Later you could add new empty files and code new Java files in JDeveloper itself. For now, add the HelloWorldRenderer.java file from where you have installed JPDK under jpdk\src\oracle\portal\sample\portlet\helloworld. Save the changes. Follow the online help for further details. We provide a screenshot to provide a quick illustration. 

Your first Java portlet project is now setup. 

CONFIGURING FOR JPDK

To setup JDeveloper for PDK-Java, you need to add the JPDK library to the project. The section "Including Libraries in a Project" under the Help Menu covers most of these details.

As part of this exercise, we provide a simple set of steps for you to follow.

  1. Create a new Library for PDK-Java.  Right click on the MyPortalJavaProject1 Project and choose Properties. From the Libraries option, click New to create a new JPDK Library. For the CLASSPATH, provide the complete path for your provider.jar file as well as the samples.jar file. For the source path, point to \jpdk\lib.

  2. Add the JPDK Library to the project. You can now add the JPDK Library to your project. You can now always add this JPDK library to other projects you create by selecting it from the list of Available Java Libraries.

 

  1. Make the Project to check whether your code compiles. You can compile the files by selecting "Make Project" under the Project menu. Your project is now setup for compiling with PDK-Java.

DEPLOYING ON ORACLE HTTP SERVER 

You can deploy your Web provider on the local Oracle HTTP Server by following the PDK-Java instructions for this purpose. 

Note: The PDK-Java sample HelloWorld portlet was deployed to your server as part of the JDK-Java installation process. Therefore, you don't need to do anything else for this section.

However, when you build a new portlet, remember to follow the required steps to deploy them to the Oracle HTTP Server.

  1. Add a new CLASSPATH entry for your portlet.  To allow the Provider Adapter to locate the class file, you must place the class file in the Oracle HTTP Server classpath.  To do this, you must first Zip or Jar your class file and point the wrapper.classpath to this path. The article How to build a Java portlet provides details on doing this.

  2. Create a provider.xml. The article How to build a Java portlet provides details on doing this.

  3. Update zone.properties. You need to add an entry for the Servlet Alias that can be used to access the servlet. Also make an entry for the Servlet's initArgs that points the Adapter to the directory where the provider.xml for the new portlet resides. The article How to build a Java portlet provides details on doing this.

  4. You can test that your portlet has been deployed to your local server by accessing the URL with the newly added alias. For example, type in the URL:

    http://host.domain:port/servlet/<ServletAliasName>

In this exercise, we simply use the sample provider that comes with PDK-Java. To check that your provider has been successfully deployed on the local server, use your browser to access http://host.domain:port/servlet/sample and check that you get the message "Congratulations! You have successfully reached your Provider's Test Page." 

REGISTERING PROVIDER WITH ORACLE PORTAL 

You can register your Web Provider with a local or even a remote Oracle Portal installation like the Portal Studio. Portal Studio is a hosted service where you can test your Java portlets by simply registering your Web provider and providing the URL of your local server where you deployed the portlets. To use Portal Studio you need to provide a URL that is accessible outside of any firewall.  This way, you don't need a local Oracle Portal installation to test your Java portlets.

Login to the Oracle Portal environment you choose to use and then register your provider. Note: You can skip this step if you have already registered the JPDK sample provider with this Oracle Portal instance.

  1. Under the Administer tab, click on Add a Portlet Provider within the portlet called Provider.

  2.  Fill out Provider information for the Sample.
    1. Name: SampleWebProvider

    2. Display Name: Sample Web Provider

    3. Timeout: 100

    4. Timeout Message: Application Timed Out

    5. Implementation Style: Web

    6. Provider Login Frequency: Once per User Session

    7. Register on Remote Nodes: No

    8. URL: http://myserver.mydomain.com:port/servlets/sample (replace this with your URL). Note: In case you've built a new portlet and provider, give the URL for the alias that you created in the zone.properties file. e.g. http://myserver.mydomain.com:port/servlet/myfirst

    9. Check the following radio button: The user has the same identity in the HTTP providers application as in the Single Sign-On identity. 

    10. Proxy:  No (As long as no proxy is required to contact the Provider Adapter).

  3. Click OK.

Add Portlet to a Page

  1. Add the HelloWorld portlet listed under the Provider called "SampleWebProvider" to a Portal page.  Please refer to Oracle Portal online documentation for more information on adding portlets to a page.

You have now successfully registered the sample Web provider with the HelloWorld portlet and run the portlet from the Oracle Portal environment.


DEBUGGING THE SETUP REMOTELY

The JDeveloper online help section on "Remote Debugging Servlets" under the Help Menu covers most of the details on setting up Remote Debugging. The section below covers the setup requirements, but feel free to use the online documentation as reference. 

JDeveloper allows you to use one of two protocols for remote debugging - the Oracle Java Virtual Machine (OJVM) debugging protocol, or the Sun Java Platform Debugging Architecture (JPDA). Before you start your remote debugging session, you must choose which method to use. If you use the OJVM protocol, your debugging session will run more quickly and you will have some additional features to assist you. You can only use OJVM on a Windows NT system. If your server is running UNIX or another operating system, you must use the "classic" JVM.


Configure the Oracle HTTP Server

Note:  This section will update three Oracle HTTP Server configuration files. Please backup these files prior to making changes. The jserv.properties is located at:  %ORACLE_HOME%\Apache\Jserv\conf on NT and $ORACLE_HOME/Apache/Jserv/etc on UNIX.  The zone.properties is located at %ORACLE_HOME%\Apache\Jserv\servlets on NT and $ORACLE_HOME/Apache/Jserv/etc on UNIX. The jserv.conf is located at:  %ORACLE_HOME%\Apache\Jserv\conf on NT and $ORACLE_HOME/Apache/Jserv/etc on UNIX.

The following options must be changed on the host running the Apache/Jserv server. These instructions assume the server is running Windows NT.

  1. Stop the HTTP Server before you make these configuration changes.

  2. Open the jserv.properties file and change the option that controls which Java Virtual Machine is used and how it is loaded. 

  3. The next option controls the parameters passed to Java interpreter by the wrapper.bin.parameters. The value you put for this parameter depends on which Debugging Protocol you will choose in the Remote Debugging Dialog in JDeveloper when you start debugging. 

  4. For the PATH environment value passed to the JVM parameter wrapper.path, enter the location of jdwp.dll, which is part of the Java Platform Debugging Architecture. This parameter is only necessary if you will choose the Java Platform Debugging Architecture debugging protocol:
    wrapper.path=C:\jpda\bin

  5. For the CLASSPATH environment value passed to the JVM parameter wrapper.classpath: 

    Note: Do not comment out the location of jsdk.jar as indicated by the Remote Debugging help of JDeveloper.  You need the jsdk.jar to run your portlets. Keep the location of the jsdk.jar file or add it if it does not exist:
    wrapper.classpath=C:\Program Files\Oracle_Home\\Apache\Jsdk\lib\jsdk.jar

  6. Save and close the jserv.properties file.

  7. Open the zone.properties file. This document uses the root zone which has a virtual path of "/servlets". For manageability, you may choose to use a different zone.

  8. In the Servlet Init Parameters section, add the following lines: 

        servlet.oracle.jsp.JspServlet.initArgs=emit_debuginfo=true

        servlet.oracle.jsp.JspServlet.initArgs=jspcompiler=oracle.jdeveloper.jsp.JspOjcCompiler

        servlet.oracle.jsp.JspServlet.initArgs=classpath=C:\Program Files\Oracle\JDeveloper 3.2\java1.3\jre\lib\frt.jar

  9. Save and close the zone.properties file.

  10. Open the jserv.conf file. 

  11. Save and close the jserv.conf file.

  12. Restart your HTTP Server.

Setting up your project for Remote Debugging

You now need to set your project options so that remote debugging is enabled:

  1. From the Project menu, select Project Properties.

  2. Click the Run/Debug tab.

  3. From Debug Files as: dropdown list, select Remote Debugging.

  4. Click OK. 


Debugging a portlet

Debugging a portlet is very similar to debugging any other Java program.

  1. Set a breakpoint in the Java portlet code.

  2. Start the debugger by selecting the Run->Debug menu option. This will bring up the Remote Debugging dialog. Choose the Oracle JVM option if you are using the Oracle JVM, or Java Platform Debugging Architecture for a classic VM. Specify the hostname where JServ is running. The port number has to be identical to the one specified in the JServ properties file. Clicking on Attach will start the debugger in JDeveloper. 

  3. In this example we have specified the VM to debug on demand. Start your Web browser and open a connection to the Oracle9iAS Portal page with the HelloWorld portlet you created earlier. 

  1. When we refresh the Java portlet page from the browser, the portlet will stop at the breakpoint specified. From this point onwards you can debug the portlet as if you were debugging any other Java file. You can look at the value of variables and expressions or jump to conditional breakpoints or the next breakpoint.

 

You can also make changes to the code, save, compile and test it in the debug mode to check the required functionality. Use the "Reset" icon (red circle) when you want to stop the debugging.

GUIDELINES FOR USING JDEVELOPER WITH ORACLE PORTAL 

When you use JDeveloper to develop and debug your portlets, you should keep the following guidelines in mind.

For detailed information on building your own Web portlet, please review How to Build a Java Portlet .  For more information about Remote Debugging, read the article Remote Debugging Server Side Java. The JDeveloper Online Demo Walkthroughs are also very helpful. 


Revision History: