Understanding the Java EE Application Server Runtime Environment


The Sun Java System Application Server integrates nicely with NetBeans IDE, via both well-published interfaces (JSR 88) for configuration and deployment and NetBeans IDE extensions called the J2EE Server Integration APIs (see http://j2eeserver.netbeans.org). Although the most complete runtime management tool for the application server is the Admin Console (a management tool in the form of a web page shown in Figure 13-25), some developer-oriented management features have been exposed from the IDE's Runtime window under the Servers node. From there, for each registered server instance, you can view the server log file (for local servers), launch the Admin Console tool, explore the list of deployed enterprise applications or enterprise resources (and undeploy them), and more.

If you want to explore the entire content of an application server domain or to see the configuration files, the log files, or the repository of the deployed applications, you can add this domain directory in the IDE's Favorites window.

By default, the Favorites window is not visible within the IDE, but you can display it in the explorer area of the IDE by choosing Windows | Favorites. Then you can right-click the Favorites root node, choose Add to Favorites, and navigate to the application server's domain directory. Once you have added this directory in the Favorites window, you can view those files in the IDE's Source Editor and take advantage of other IDE features, such as the Validate XML command, which is useful for validating things such as the config/domain.xml file.


Server Log

The Sun Java System Application Server instance container process uses a log file to track system and user messages ranging from severe errors to informational messages describing the current state of the server. The server log file is an important source of information that an enterprise application developer needs to use actively during development or deployment and execution of Java enterprise applications. There is one server log file per instance, usually located under the domain directory in the logs/server.log file. NetBeans IDE can display the content of the most recent lines of the server log via the server instance node popup menu called View Server Log. This menu is active only for local server instances, because the IDE needs access to the file.

Server Management

For a registered application server instance, whether the server is local (on the same machine that the IDE is running on) or remote, the IDE offers extensive administration capabilities via the Runtime window tree view (shown in Figure 13-29).

Figure 13-29. Runtime window with the node for a Sun Java System Application Server instance selected


Once the server is running, you can get read/write access to most of the developer-oriented administration parameters, such as:

  • The list of deployed enterprise applications, from where you can introspect their properties and undeploy them

  • The list of registered resources and their properties (JDBC resources, connection pools, Persistence Manager resources, JMS resources, JavaMail resources, JDNI names, and Connector and JVM settings)

Each of these management artifacts is represented as a node. The corresponding commands (Delete, Undeploy, Refresh, and so on) are available as popup menu items (when you right-click the node), and corresponding properties are available via the Properties popup menu item. For other management artifacts, you can always access them by opening the application server's Admin Console (right-click the server's node in the Runtime window and choose View Admin Console). This command opens a web browser that then displays the URL for the administration console.

JVM Options

The JVM parameters of a server instance are among the most important server administration parameters from a developer standpoint. You can access these parameters by right-clicking the server's JVMs node in the Runtime window and choosing Properties. The Properties dialog box for the JVMs node is shown in Figure 13-30.

Figure 13-30. Property sheet for the JVMs node for an application server in the Runtime window


Use the server-classpath entry (shown as ServerProperty in the property sheet) when you want to add shared libraries or JAR files that would be used by all the enterprise applications deployed to this server instance, as well as the necmessary JDBC driver JAR files to access databases. Use the jvm-options parameter (shown as JVMOptions in the property sheet) to define Java options like HTTP proxies or options that would be relevant to the deployed enterprise applications. You can modify the java-home entry (shown as JavaHome in the property sheet) to change the location of the JDK used by the server instance.

Most of these settings require a server instance restart to take effect. NetBeans IDE can figure out when a local instance has to restart, and at the next enterprise project deployment, execution, or debugging session, the server is restarted automatically. For remote servers, you have to log into the remote machine to perform a server restart, as there is no command (CLI or Admin Console based) to restart a remote server in Sun Java System Application Server 8.1.

JDBC Drivers

Using the Sun Resources template category in the New File wizard (shown in Figure 13-31), you can define Java enterprise resources such as:

  • JDBC connection pools

  • JDBC resources

  • JMS resources

  • JavaMail resources

  • Persistence resources

Figure 13-31. New File wizard with the JDBC Connection Pool template selected


The wizard for the JDBC Connection Pool template (shown in Figure 13-32) is of particular help in improving your productivity. It enables you to create resources, either from live database connections registered within NetBeans IDE or from a predefined list of well-known JDBC driversincluding all the Sun DataDirect drivers for DB2, Oracle, Microsoft SQL Server, and Sybase, as well as drivers for the Pointbase and Apache Derby databases. Note that in the Sun Java System Application Server 8.1 Platform Edition, only the Pointbase driver is provided; for versions 8.2 or 9.0, the Derby driver is provided. The Sun DataDirect drivers are included with the Standard Edition and Enterprise Edition of Sun Java System Application Server 8.x.

Figure 13-32. Choose Database Connection page for the JDBC Connection Pool template in the New File wizard


These server-specific resources are created under the setup directory, which in the Projects window is represented as the project's Server Resources node. These server resources are then either automatically deployed to the server whenever the project is executed or manually registered, using the Register menu item, as shown in Figure 13-33.

Figure 13-33. Registering a database connection in a project


Double-clicking a server resource node opens the resource's property sheet (such as the one for the JDBC Connection Pool as shown in Figure 13-34), where you can modify all the necessary properties before doing a registration.

Figure 13-34. Property sheet for a JDBC connection pool


Server Properties

The server's Properties dialog box (shown in Figure 13-35), accessible via the Properties menu item of a server node, allows the editing of the admin username or password, as well as the setting for enabling the IDE's HTTP Monitor. The HTTP Monitor works only for local application servers.

Figure 13-35. Properties dialog box for the Sun Java System Application Server


Using JavaServer Faces Technology in a Web Application

Sun Java System Application Server 8.2 bundles all the latest JavaServer Faces(JSF) APIs and the JSF implementation out of the box. The JSF config

DTDs are also registered in the IDE, meaning that XML code completion and validation are available in the IDE for the JSFconfig 1.0 and 1.1 XML files.

The JSF libraries are automatically in the web application project classpath when the project targets the Sun Application Server, so that all the classes are available to import and use from your web application.

Furthermore, the Java BluePrints Solution Catalog is accessible directly through the IDE's Help | BluePrints Solutions Catalog menu item and contains some web tier solutions that incorporate JSF technology, which are installable as IDE projects with one click. Install a solution, run the project, study it, debug it, modify it, and use it as a starting point for your JSF project. See Chapter 10 for more details.

Working with Ant

NetBeans IDE's Ant-based project system is perhaps the biggest thing that sets NetBeans apart from other IDEs. All projects created within NetBeans IDE rely on the Ant tool for building. This applies to projects types for web applications, EJB modules, and enterprise applications. Therefore, these projects can be built both inside and outside the IDE using Ant.

The IDE-generated build script also includes targets for executing, debugging, and deploying the application. In NetBeans IDE 5.0, it is not possible to use these targets outside the IDE, because they would require an operational runtime environment.

Another NetBeans IDE advantage is that all of the Sun Java System Application Server optional Ant tasks are registered in the IDE. These tasks include

  • sun-appserv-deploy

  • sun-appserv-undeploy

  • sun-appserv-instance

  • sun-appserv-component

  • sun-appserv-admin

  • sun-appserv-input

  • sun-appserv-update

So if you have existing Ant scripts that are using these Ant task extensions, you can run these build.xml files directly from the IDE itself as though you were invoking the Sun Application Server tool asant (which itself is a wrapper around Ant to declare these extensions).

For example, if you download all the samples for the Sun Java System Application Server, all of the samples can be built from the IDE using the sample build.xml files provided with the sample. You could make the samples visible in the IDE by choosing Window | Favorites, right-clicking the Favorites node, choosing Add to Favorites, and navigating to the directory to display. Once the samples are visible in the Favorites window, you can navigate to a sample's build.xml file, right-click it, and choose an Ant target to run.

For more information regarding these tasks, refer to the application server documentation at http://docs.sun.com.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net