Developing for WebLogic Server 8.1 with Oracle JDeveloper 10g

by Deepak Vohra
02/07/2006

Abstract

The Oracle JDeveloper 10g IDE is a full-featured J2EE IDE that can be used to develop and deploy J2EE applications on BEA WebLogic Server 8.1. In this tutorial, a simple JSP Web application is developed in JDeveloper and deployed to a WebLogic Server 8.1 instance. The tutorial also shows how to debug applications using the JDeveloper IDE.

Overview

The JDeveloper IDE supports development of J2EE applications for BEA WebLogic Server. WebLogic Server versions 6.x, 7.x, and 8.x are supported in JDeveloper 10.1.2. JDeveloper 10.1.3 (just released) supports versions 8.x and 9.x. JDeveloper also provides a remote debugger to debug applications deployed to WebLogic Server. A J2EE application developed in the JDeveloper IDE may consist of EJBs, JSPs, Struts, Java classes, applets, and servlets. In this tutorial, a Model-View J2EE application consisting of a session EJB and a JSP client is developed in the JDeveloper 10g IDE and deployed to a WebLogic Server 8.1 instance.

Preliminary Setup

I assume you have WebLogic Server 8.1 installed. Using the Configuration Wizard, create a WebLogic Server domain. Install the JDeveloper 10g (10.1.2) IDE. Copy the <Weblogic81>\server\lib\weblogic.jar to the <JDeveloper>\jdev\lib\ext directory. <WebLogic81> is the directory in which your WebLogic Server 8.1 is installed. <JDeveloper> is the directory in which JDeveloper 10g is installed. You are now set to go!

Configuring a Connection with WebLogic Server

In this section we'll configure a connection to WebLogic Server from the JDeveloper IDE. First, start WebLogic Server and JDeveloper IDE. In the JDeveloper console, select the Connections tab to configure a connection with WebLogic Server. The Connection>Application Server node is used for configuring a connection with an application server. Right-click on the Application Server node, and select New Application Server Connection.

Figure 1
Figure 1. New application server connection

The Create Application Server Connection Wizard will start. In the Type frame specify a Connection Name, and select Connection Type as WebLogic Server 8.x. Previous versions of WebLogic Server 6.x and 7.x are also supported. Click on Next.

Figure 2
Figure 2. Connection type

In the Authentication frame, specify a username and a password, and click on Next. In the Connection frame, specify the WebLogic Server host name, port, target server, and path to weblogic.jar. Click on Next.

Figure 3
Figure 3. Connection parameters

In the Test frame, select the Test Connection button to test the connection with WebLogic Server. If a connection with the server is established, a Success message will be displayed. Click on the Finish button. A connection with WebLogic Server 8.1 will now be configured, and a node for the connection will be added to the Connections-Navigator.

Figure 4
Figure 4. WebLogic Server connection

You now have a running WebLogic Server and JDeveloper IDE, and your JDeveloper will be able to interact with your WebLogic Server instance.

Deploying an Application to WebLogic Server

In this section, we will develop a J2EE application in the JDeveloper IDE and deploy it to WebLogic Server. The J2EE application consists of a session EJB and a JSP client for the session EJB. First, create an application workspace and project in JDeveloper. Select File>New, and in the New Gallery frame select General>Application Workspace. Click on the OK button. In the Create Application Workspace frame, specify an application name and a directory name, and select Web Application [JSP, EJB] as the application template. Click on the OK button. An application workspace will be added to the Applications-Navigator and the Model and View project nodes added to the workspace.

Figure 5
Figure 5. Model View Project

Next, create a session EJB. Right-click on the Model project node, and select New. In the New Gallery frame, select Business Tier>Enterprise JavaBeans (EJB) in the Categories listed and Session Bean in the Items listed. Click on the OK button.

Figure 6
Figure 6. New session bean

The Create Enterprise JavaBean Wizard will start. In the Select EJB Version frame, select Enterprise JavaBeans 2.0 as the EJB Version. Click on the Next button. In the EJB Name and Options frame, specify a EJB Name, Session Type, and Transaction Type ( or select the default ), and click on the Next button. In the Class Definitions frame, specify the Bean Class (or select the default). Click on the Next button. In the EJB Home and Component Interfaces frame, select the Include Local Interfaces checkbox, and specify the Local Home Interface and Local Interface (or select the default). Click on the Next button. In the Summary page, the bean class, local home interface, and local interface classes to be generated with the Create Enterprise JavaBean Wizard will be listed. Click on the Finish button to generate the session EJB classes. The session EJB will be added to the Model project. The ejb-jar.xml deployment descriptor is also generated.

The orion-ejb-jar.xml deployment is not required for a WebLogic Server application and should be deleted from the META-INF directory. We'll need to add a weblogic-ejb-jar.xml deployment descriptor. To do this right-click on the Model project node, and select New. In the New Gallery frame, select General>Deployment Descriptors in the Categories listed and weblogic-ejb-jar.xml in the Items listed.

Figure 7
Figure 7. New weblogic-ejb-jar.xml

The weblogic-ejb-jar.xml deployment descriptor will be added to the Model project. Modify the weblogic-ejb-jar.xml deployment descriptor. Replace jndi-name with local-jndi-name.

Figure 8
Figure 8. weblogic-ejb-jar.xml

Next, add a business method to the session EJB. Select the session EJB node in the Application-Navigator. In the EJB Module Editor, select Enterprise Java Beans>Session EJB>Methods. In the Method Category choice list, select Business methods, and click on the Add button. In the Business Method Details frame, specify a method name, a return type , and method parameters. As the example session EJB has local interfaces select the Expose through Local Interface checkbox. Click on the OK button. The specified method will be added to the session EJB. Click on the OK button in the EJB Module Editor.

Figure 9
Figure 9. Session EJB method

In the Applications-Navigator, select the session EJB node, and in the Structure frame, select SessionEJBBean. In the getAppServer() method of the SessionEJBBean class, add a return String.

Figure 10
Figure 10. getAppServer method