Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Sun Java System Application Server PE 8 and NetBeans 3.6 Integration: A Tour and an Inspection

 
by Vince Kraemer, June 25, 2004

Sun has released an installation bundle that contains Sun Java System Application Server PE 8 (Application Server PE 8) and NetBeans 3.6. The bundle also contains a NetBeans module that helps form an integrated environment for developing web applications for deployment to Application Server PE 8.

This paper highlights the capabilities of that module by giving you a quick, hands-on tour and then describing the module elements in more detail.


Note - You can also download the module from the NetBeans Update Center. If you do so, be sure to configure the Installation Root Directory property before starting the tour.



This paper contains the following major sections:



Tour of the Integration Module


Note - This tour assumes that you have installed the bundle and have started NetBeans and opened the Filesystem Explorer. For information, see the procedure under section 1 in the HelloWeb Mini-Tutorial for NetBeans.



This tour contains the following steps that describe many of the module's capabilities:



Creating a Web Module in NetBeans

This step introduces the concept of the web module. Web modules are special file systems that are recognized by NetBeans because of their content. NetBeans contains menu items from which you can create one of those file systems.

See FIGURE 1.

 
FIGURE 1: Initial Content of the Filesystems Explorer
FIGURE 1 Initial Content of the Filesystems Explorer

To create a web module, follow these steps:

  1. Select a mounted file system node.

  2. Right-click for the floating menu and, from the Tools menu, choose Convert Filesystem into Web Module.

    A confirmation dialog box appears.

  3. Click OK.

    The Filesystems Explorer shows a new file system, which holds the servlets that you create in the module. The selected file system contains a new child node, called WEBINF, that provides access to web module attributes, such as the context root.

    The context root for the module created in this step matches the last component of the path. For example, if the file system path is /home/user/userdir/sampledir, then /sampledir is the context root property value of the module. See FIGURE 2.

     
    FIGURE 2: Final Content of the Filesystems Explorer
    FIGURE 2 Final Content of the Filesystems Explorer
    You can also create a web module by following the procedure described in "Creating the PageDirectivesWeb Module" in The PageDirectives Mini-Tutorial for NetBeans.

Creating a JSP Page in the Web Module

This step introduces the JavaServer Pages (JSP) template and the Template Wizard. The latter creates files by completing templates with the values that you enter.

The JSP page you create in this step displays information on the web container that executes the JSP page, which verifies the Default Server property value of the Server Registry node.

To create a JSP page in the web module, do the following:

  1. Choose New from the File menu.

  2. Click JSPs & Servlets, then click JSPs, and then click JSP. Finally, click the Next button.

    See FIGURE 3.

     
    FIGURE 3: Front Page of New Wizard
    FIGURE 3 Front Page of New Wizard
  3. Accept the default values set by the wizard. Click Finish.

    See FIGURE 4.

     
    FIGURE 4: File System with the Wizard's Default Values
    FIGURE 4 File System with the Wizard's Default Values
  4. Open the JSP file and locate these two lines of code:

    <%-- <jsp:useBean id="beanInstanceName" scope="session" class="beanPackage.BeanClassName" /> --%>
    <%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
    

    Replace them with the following code:

    <pre>
    <% out.println(application.getServerInfo()); %>
    </pre>
    


  5. Save the JSP file.

Executing the JSP Page

This step demonstrates how the NetBeans environment automates the control of the web container state and deployment.

To execute the JSP page, do the following:

  • Click the JSP page in the Filesystems Explorer and then press F6.

    The Deployment Progress Monitor dialog box appears, showing the status of two processing phases that are required to execute the JSP page:

    • Starting the default server instance
    • Deploying the application to the default Application Server PE 8 instance

After these two phases are complete, the dialog box closes automatically. Next, the configured web browser opens and accesses the URL for the JSP page. The page that appears in the browser contains the following text:

Sun-Java-System/Application-Server-PE-8.0

For example, if you configured the default server instance to be the Tomcat server, the displayed page reads:

Apache Tomcat/5.0.19


Disabling a Web Module Deployed to an Application Server 8 Instance

This step describes the server configuration capabilities of the Runtime Explorer.

The module that contains the JSP page executed in the preceding step is deployed to the Application Server PE 8 instance. To disable that module from the Runtime Explorer, do the following:

  1. Click to expand the Server Registry node and then click to expand the Application Server 8 node.

  2. Select the localhost node, which represents a server instance that runs on the same computer as NetBeans.

  3. Right-click and then choose Refresh from the floating menu.

  4. Click to expand localhost, then click Applications, and then click Web Applications.

    See FIGURE 5.  
    FIGURE 5: Expanded Runtime Explorer
    FIGURE 5 Expanded Runtime Explorer
    If the web module is deployed to Application Server PE 8, this node contains at least one child. The names of the nodes correspond to the Context Root property of the module they represent.

  5. Select the node that corresponds to the module created in Creating a Web Module in NetBeans, right-click, and choose Disable from the floating menu.

    See FIGURE 6.

     
    FIGURE 6: Properties of the Disabled Module
    FIGURE 6 Properties of the Disabled Module
  6. Refresh the page in the browser that opened after you executed the JSP page.

    A page that shows the HTTP Status 503 appears, confirming that the module has been disabled. See FIGURE 7.

     
    FIGURE 7: Status Display of Disabled Web Module
    FIGURE 7 Status Display of Disabled Web Module

    Note - In step 5, if you choose Undeploy from the floating menu of the module and refresh your browser, a page that shows the HTTP Status 404 appears instead.

Capabilities of the Integration Module

The preceding tour briefly introduced the integration module, which integrates Application Server PE 8 into the workflow of developing web applications in NetBeans. The module provides NetBeans the following capabilities:

  • Configure and deploy web applications to the bundled Application Server PE 8 instance.

  • Manipulate a server instance's execution status.

  • Inspect and configure the Application Server PE 8 runtime environment.

  • Configure the execution status of the PointBase server--a component of Application Server PE 8.

  • Access the PointBase instance through the Database Explorer module's capabilities.

  • Register Application Server PE 8 instances that are installed on the local computer on which NetBeans is running or on a networked computer.

  • Create resource definitions and register them with instances of Application Server PE 8.

You can configure a web application from the floating menu of the sun-web.xml file, which is a sibling of the web.xml file in the application. To configure the Application Server PE 8 runtime environment, you work with the additional nodes in the Runtime Explorer. To manage resource definitions, which are created from templates, use the Filesystems Explorer.

The following subsections describe these elements of the module.

Configurations of Elements

The web container for Application Server PE 8 contains many configurable elements. You can revise most of them by editing the sun-web.xml file in the WEB-INF directory using either of the following:

  • A GUI, which is the default editor that opens when you double-click the sun-web.xml node under the web module (see FIGURE 8)

  • A text view, which opens when you choose Edit from the node's floating menu

     
    FIGURE 8: Editor for Configuring the Web Container
    FIGURE 8 Editor for Configuring the Web Container
    The editor maintains the relationships between the content of the web.xml file and the sun-web.xml file. If you revise the web.xml file, the editor synchronizes your changes in the sun-web.xml file.

    The editor also alerts you to data errors in the nodes by displaying a synopsis of the errors in the tree control. To browse the error messages, select the node. The editor displays the messages at the bottom of the right pane. See FIGURE 9.

     
    FIGURE 9: Example of an Error Message in the Editor
    FIGURE 9 Example of an Error Message in the Editor
    You can also edit the sun-web.xml file as text. The NetBeans autocompletion capabilities are enabled for the Application Server PE 8 deployment descriptor elements because the module registers their Document Type Definitions (DTDs). See FIGURE 10.

     
    FIGURE 10: Example of Autocompletion in the Editor
    FIGURE 10 Example of Autocompletion in the Editor

Deployment of Web Applications

The module extends NetBeans to deploy web applications to instances of Application Server PE 8. These instances can run locally on the same computer or remotely on a networked computer. Deployment starts upon execution or debugging of a web application, one of the JSP pages, or servlets associated with the application.

Deployment is optimized when execution occurs on a local instance. The code of the application is deployed in place. This mode eliminates many of the steps required for archive deployment.

New Runtime Explorer Nodes

The module adds many nodes to the Runtime Explorer. See FIGURE 11.

 
FIGURE 11: Expanded View of the Runtime Explorer
FIGURE 11 Expanded View of the Runtime Explorer

The most important node is the Sun Java System Application Server 8 node, which represents the integration module. This node is visible as a child of the Server Registry node. You can configure its properties to your environment. FIGURE 12 shows an example of the Properties window.

 
FIGURE 12: Example of the Properties Window for the Sun Java System Application Server 8 Node
FIGURE 12 Example of the Properties Window for the Sun Java System Application Server 8 Node

The most important property is Installation Root Directory, which directs the module to access classes from the installed Application Server PE 8 lib directory. The bundle installation process sets the value of Installation Root Directory correctly. If you install the module from the NetBeans Update Center, you must set that value and restart NetBeans.

Each registered instance of Application Server PE 8 appears under the integration module node. The setup of the node hierarchy is the same as that in the Administration Console.

The menu items and property editors for the nodes in the hierarchy perform many of the tasks that are available in the Administration Console or the asadmin command-line utility. You can also open the Administration Console for the instance from the server-instance nodes.

In addition, the module does the following:

  • Registers the PointBase driver and connection definitions under the Databases node of the Runtime Explorer

  • Extends the Tools menu for control of the PointBase server that's part of Application Server PE 8 from within NetBeans

  • Registers the DTDs and schemas that define deployment descriptors that are valid for Application Server PE 8 with the XML Entity Catalog

    The XML editors in NetBeans use these entries as the basis for autocompletion.

Additional Server Instances

You can register multiple server instances from the Register Server Instance dialog box (see FIGURE 13). They appear as additional nodes in the Runtime Explorer.

 
FIGURE 13: NetBeans Dialog Box for Registering Server Instances
FIGURE 13 NetBeans Dialog Box for Registering Server Instances

You can select one of these nodes as the default instance for deployment and execution. For more information, see the next section.

Because remote instances execute on a networked computer, you cannot start the server or view the logs for those instances: Those tasks require access to the instances' installation directories.

Default Server Instance

Many tasks that are associated with web applications use the default server as an implicit argument--for example, the Execute item on a web application node's floating menu. The web application executes in the default instance's web container.

To execute a web application on a server instance, you designate that instance as the default server by choosing Set As Default from an instance node's floating menu.

The bundle installation process registers an Application Server PE 8 server instance as the default instance. However, if you install the module from the NetBeans Update Center, you must register an Application Server PE 8 instance and configure it as the default.

Templates

The module extends the File Creation wizard with additional templates. See FIGURE 14.

 
FIGURE 14: Wizard Screen with Additional File Types
FIGURE 14 Wizard Screen with Additional File Types

From these templates, you can define resources for Application Server PE 8. Because the definitions are saved to the file system, you can register them to multiple servers. If a resource depends on another resource, you can create multiple definitions in a single invocation from a template. See FIGURE 15.

 
FIGURE 15: Example of an Execution in the Wizard
FIGURE 15 Example of an Execution in the Wizard

After the wizard is complete, NetBeans creates an XML file that defines the resource. You can use this file to register the resource on multiple server instances. Although the file content is hidden, you can edit the resource definitions from the Properties Editor. See FIGURE 16.

 
FIGURE 16: Properties Editor for a Resource Definition File
FIGURE 16 Properties Editor for a Resource Definition File

An additional menu item for resource definition file nodes is Register, which pushes a definition to a server instance. When registration is complete, NetBeans shows the resource as a child of the instance in the Runtime Explorer. See FIGURE 17 for an example.

 
FIGURE 17: Example of a Registered JDBC Resource
FIGURE 17 Example of a Registered JDBC Resource

You can edit the resource instance from its Properties Editor. FIGURE 18 shows an example of the properties of a registered resource.

 
FIGURE 18: Example of the Properties of a Registered Resource
FIGURE 18 Example of the Properties of a Registered Resource
References
About the Author

Vince Kraemer, currently a staff engineer at Sun, joined the company in 1997. He has been working with Sun products for more than 18 years and developing tools for programmers for more than 12 years. The integration module for NetBeans is the latest of a string of projects that are slated to ease the process of developing and deploying J2EE applications.

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.