Introduction to the Oracle Enterprise Pack for Eclipse (OEPE) IDE

This tutorial provides a tour of major components in Oracle Enterprise Pack for Eclipse, and shows you how they are used to build a basic application.

Approximately 20 minutes.

Topics

This tutorial covers the following topics:

Launching Eclipse

Setting the Workbench Perspective for a Project

Creating Your First Projects

Adding a New Web Project

Defining and Starting the WebLogic Server
Defining the Deployment Descriptors for your Projects
Creating JSP Pages

Debugging the Application

Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: This action loads all screenshots simultaneously, so response time may be slow depending on your Internet connection.)

Note: Alternatively, you can place the cursor over an individual icon in the following steps to load and view only the screenshot associated with that step. You can hide an individual screenshot by clicking it.

Overview

In the tutorial, you learn how to create various type of projects in the Eclipse tool, define and start the WebLogic Server and configure the deployment environment. Additionally you create JSP pages and run these pages.

Back to Topic List

Prerequisites

Before you begin this tutorial, you should:

1.

Have access to or have installed Eclipse. You can download it from Oracle Technology Network. Unzip to a directory of your choice, which in this tutorial is referred to as ECLIPSE_HOME.

 

2.

Have access to or have installed Oracle WebLogic Server 10.3. You can download it from Oracle Technology Network.

To install WebLogic, double click the .exe file to launch the Oracle Installer and install it into the directory of your choice, which in this tutorial is referred to as WEBLOGIC_HOME.

 

3.

Since we are using WLS 10.3 and because Weblogic Server 10.3 requires JDK 1.6, OEPE 11g must be launched with JDK 1.6 as well. There are two ways to do this:

  • update the system PATH variable so that JDK 1.6 is the default JDK for the OS. (ie: PATH=<WEBLOGIC_HOME>\jdk160_05\bin;%PATH%).
  • update the eclipse.ini with a –vm flag to specify which JDK they want Eclipse launched with.

To implement the second option, locate the directory where the WebLogic JDK was installed. (for example: <WEBLOGIC_HOME>\jdk160_05\bin) and copy the path in the clipboard.

 

4.

Locate the ECLIPSE_HOME directory and open the eclipse.ini file using notepad.

 

5.

Enter the following statements : -vm then copy the content of the clipboard.

 

6.

Save and close the eclipse.ini file.

Back to Topic List

Launching Eclipse

Now that the environment is set, you can start Eclipse. To launch the tool, perform the following steps:

1.

Start Eclipse by double clicking the Eclipse executable eclipse.exe found in the ECLIPSE_HOME directory.

 

2.

Eclipse starts loading up and a Workspace Launcher dialog pops up. Specify a Workspace folder for your work.

Click OK.

 

3.

The Eclipse Welcome screen appears.

 

4.

Hover your mouse on each icon of the Welcome screen and review the possible options.

  • Overview
  • What's New
  • Samples
  • Tutorials
  • Workbench

 

5.

To start working, click the Workbench icon.

 

6.

The Eclipse IDE opens up.

Back to Topic List

Setting the Workbench Perspective for a Project

The term Workbench refers to the desktop development environment. The Workbench aims to achieve seamless tool integration and controlled openness by providing a common paradigm for the creation, management, and navigation of workspace resources.

Each Workbench window contains one or more perspectives. A perspective defines the initial set and layout of views in the Workbench window. Within the window, each perspective shares the same set of editors. Each perspective provides a set of functionality aimed at accomplishing a specific type of task or works with specific types of resources. For example, the Java perspective combines views that you would commonly use while editing Java source files, while the Debug perspective contains the views that you would use while debugging Java programs. As you work in the Workbench, you will probably switch perspectives frequently. More than one Workbench window can exist on the desktop at any given time.

To define a perspective for a future project, perform the following steps:

1.

Click the Open Perspective icon to select the appropriate perspective for your development.

 

2.

In the list of perspectives, select the Other option to view all available perspectives.

 

3.

Review the list of possible perspectives, and select the Java EE one.

Click OK.

 

4.

The IDE updates to a new set of views and editors that are best suited to performing Java EE tasks.

 

5.

Review each of the tabs in the bottom right pane. As the tutorial goes on, you get a chance to explore the content of some of the tabs.

6.

From the main menu, selecting Window --> Show View allows you to open or reopen specific views. Select the Other option.

In the Show View dialog, expand the General node. Notice that views or editors already opened are greyed out.

Back to Topic List

Creating Your First Projects

An enterprise application project ties together one or more J2EE modules, including application client modules, EJB modules, Connector modules, or Web modules. To create a new project, perform the following steps:

1.

Click File | New and select Enterprise Application Project.

 

2.

In the New EAR Application Project dialog, enter DemoEAR as the project name, and click the New button next to the Target Runtime field.

In the New Server Runtime Environment, expand the Oracle node and select Oracle WebLogic Server 10gR3.

Click Next.


3.

In the Oracle WebLogic Server 10gR3 dialog, click the Browse button next to the WebLogic Home field.

Locate the ECLIPSE_HOME and select wlserver_10.3

Click OK.

 

4.

Back to the New Server Runtime Environment, click Finish.

 

5.

Click the Modify button next to the Configuration field.

 

6.

The Project Facets dialog shows the facets that are enabled for your current project, allowing you to set up your own facet configuration.

Click OK, then click Next on the New EAR Application Project dialog.

 

7.

In the Enterprise Application dialog, click the New Module button.


8.

Java EE architecture supports component-based development of multi-tier enterprise applications. A Java EE application system typically includes the following tiers:

  • Client tier: In the client tier, Web components, such as Servlets and JavaServer Pages (JSPs), or standalone Java applications provide a dynamic interface to the middle tier.
  • Middle tier: In the server tier, or middle tier, enterprise beans and Web Services encapsulate reusable, distributable business logic for the application. These server-tier components are contained on a Java EE Application Server, which provides the platform for these components to perform actions and store data.
  • Enterprise data tier: In the data tier, the enterprise's data is stored and persisted, typically in a relational database.

In the Create default Java EE modules dialog, check the Web Module checkbox and uncheck others, then Finish.

The Web Module facet is installed in your project.

 

9.

On the New EAR Application Project, click Finish.

 

10.

Back to the Eclipse IDE, two projects now exist.

 

11.

Expand the nodes of the DemoEAR project to review the default environment created for an EAR project.

 

12.

Expand the nodes of the DemoEARWeb project to review the default environment created for an EAR Web project.

Collapse all the open nodes in the project explorer.

Back to Topic List

Adding a New Web Project

To add a new project to the existing ones, perform the following steps:

1.

Click File | New and select Dynamic Web Project .

 

2.

In the New Dynamic Web Project dialog, enter DemoWAR as the project name, and in the EAR section, click the Add project to an EAR checkbox so that the project is added to the DemoEAR one.
In the Configuration click the Modify button.


3.

The Project Facets dialog shows a list of all the available facets and among them, the ones that were added by default to your project.

Click OK. Then Next.

 

4.

On the New Dynamic Web Project dialog, click Finish to create the project.

 

5.

Back to the Project Explorer, right click the DemoEAR project and select Properties from context.

 

6.

Select the Java EE Module Dependencies node, and note that both projects DemoEARWeb and DemoWAR are dependent from the DemoEAR project.

Click OK.

Back to Topic List

Defining and Starting the WebLogic Server

To define and start the WebLogic server, perform the following steps:

1.

In the bottom pane, click the Servers tab. In the editor right click and select New-> Server.


2.

In the Define a New Server dialog, select Oracle WebLogic Server 10gR3.

Click Next.

 

3.

In the Domain Directory field, select the <WEBLOGIC_HOME>\wlserver_10.3\samples\domains\wl_server directory from the drop down list.

Notice that a new domain can be defined by clicking the link to start the new domain configuration wizard.

Click Next.

 

4.

In the Add and Remove Projects, select DemoEAR and click the Add button to shuttle the selection in the Configured projects.

Click Finish.

 

5.

The server entry appears in the Servers pane. It also shows the projects included in the server and the status of the server.

 

6.

Right click the server entry and select Open from context.

 

7.

The server Overview opens in the editor. The left part of the overview page shows 3 sections describing the server (General Information, Server, and Startup & Deployment).

Note that even if in the Startup & Deployment section Eclipse allows you to publish a project that has compilation errors, you should avoid this option and deploy projects that are errors free.

 

8.

Back in the Servers pane, right click and select Start from context.

 

9.

A new Console tab opens up showing the server launching steps.

Wait for the server to be started.

The Status should now display Synchronized.

 

10.

The deployed components are now listed in the Published Modules section.

 

11.

In the server overview page, click the Open WebLogic Server Admin Console link.

 

12.

The WebLogic Server Administration Console opens. Provide the default username/password (weblogic/weblogic).

Click Log In.

 

13.

The WebLogic console opens in the embedded browser.

Note that launching the WebLogic Server may also open the administration console in your default web browser. If so, close the web browser window to avoid resource conflicts.

 

Back to Topic List

Defining the Deployment Descriptors for your Projects

To define the deployment profile for your projects, perform the following steps:

1.

In the Project Explorer expand the DemoEAR | EarContent | META-INF nodes and double click the weblogic-application.xml file.

The WebLogic Application Deployment Descriptor opens.

 

2.

Using the General node, you can indicate the version of Oracle WebLogic Server on which this application is intended to be deployed. Modifying the Server version updates the descriptor source code to the appropriate schema.

 

3.

In the General node, select Application Parameters.

Double click the default webapp.encoding.default to open a list of possible values and select webapp.encoding.usevmdefault.

Click OK.

 

4.

Note that when selecting this new encoding value an error appears because the UTF-8 value is not valid for this encoding choice.

To clear out the error, double click in the Value field and select True.

Click OK.

 

5.

At any time, click F1 to open a context related help. The Application Parameters help window gives you additional information.

 

6.

Expand the DemoWAR | WebContent | WEB-INF nodes and double click the weblogic.xml file.

The WebLogic Web Application Deployment Descriptor opens.

 

7.

Expand the General | FastSwap nodes and select the Enable class redefinition checkbox. This allows containers to reload altered classes without disturbing running applications. You can make your changes, auto compile, and then see the effects immediately.

 

8.

In the General | Logging nodes in the Logging pane, enter a file name for the log, and in the Log File Rotation select the no rotation option so that messages accumulate in a single file, meaning that you must erase the contents of the file when the size is unwieldy.

 

9.

Click the Servers tab, and click the Stop icon to stop the WebLogic Server.

 

10.

The server state is now on Stopped.

Back to Topic List

Creating JSP Pages

Back to Topic List

Creating a Java Bean

To create a Java bean to interact with two JSP Pages, perform the following steps:

1.

Right click the DemoEARWeb | Java Resources | src node and select New --> Package from context.

 

2.

In the New Java Package dialog, enter bean as the name for the package.

Click Finish. The package is added to the project.


3.

Right click the bean node and select New --> Class from context.

 

4.

In the New Java Class dialog, type Hello as the name for the class.

Click Finish.

 

5.

The Hello.java class opens up in the java editor.

 

6.

Add a new statement to the class: private String name = "";

 

7.

In the code editor, right click the name variable and select Source --> Generate Getters and Setters from context.

 

8.

In the Generate Getters and Setters dialog, click OK to accept the default options.

 

9.

The new class should now look like this:

Back to Topic

Back to Topic List

Creating the JSP Pages

To create two JSP Pages passing a variable value from one page to the other using the Java bean, perform the following steps:

1.

Right click the DemoEARWeb | WebContent node and select New --> Folder from context.

 

2.

In the New Folder dialog, enter pages as the name for the folder.

Click Finish. The folder is added to the project.


3.

Right click the pages node and select New --> JSP from context.

 

4.

In the New JavaServer Page dialog, type greeting.jsp as the name for the page.

Click Next.

 

5.

The following dialog allows you to select a template to use for your pages. It can be a one of the predefined templates or your own. Keep the default selected one.

The Preview pane displays the html code.

Click Finish.

 

6.

Right click the pages node and select New --> JSP from context, to create a new JSP.

 

7.

In the New JavaServer Page dialog, type response.jsp as the name for the page.

Click Finish.

 

8.

Right click the greeting.jsp node and select Open With | Web Page Editor.

 

9.

The page is now displaying in Web Page mode and JSP Code mode.

 

10.

In the JSP Code pane, cut and paste the following statements to replace the existing ones.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="bean.Hello" %>
<jsp:useBean id="hello" scope="page" class="bean.Hello"></jsp:useBean>
<jsp:setProperty name="hello" property="*" />

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table border="0" width="700">
<tr>
<td width="500">
Welcome to the Oracle Enterprise Pack for Eclipse Tutorial
</td>
</tr>
<tr>
<td width="500">
<form method="get">
Please enter your name: <input type="text" name="name" size="50">
<br>
<input type="submit" value="Submit">
</form>
</td>
</tr>
</table>
<%
if ( request.getParameter("name") != null ) {
%>
<%@ include file="response.jsp" %>
<%
}
%>
</body>
</html>

 

11.

The page should now look like this:

Notice that the following statements refer to the Java Bean previously created.

<%@ page import="bean.Hello" %>
<jsp:useBean id="hello" scope="page" class="bean.Hello"></jsp:useBean>
<jsp:setProperty name="hello" property="*" />

 

12.

Click the Preview tab at the bottom of the Page editor.

The editor displays the page rendering.

 

13.

Right click the response.jsp node and select Open With | Web Page Editor.

 

14.

In the JSP Code pane, cut and paste the following statements to replace the existing ones.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table border="0" width="700">
<tr>
<td width="500">
Hello, <jsp:getProperty name="hello" property="name" />!
</td>
</tr>
</table>
</body>
</html>

 

15.

The page should now look like this:

 

16.

Click the Properties tab in the bottom pane to view the page info.

 

17.

In the Save Resources dialog, click OK to save your work.

 

18.

Click the Servers tab, right click the Oracle WebLogic Server and select Publish from context.

 

19.

Once the server is started, right click the greeting.jsp node and select Run As --> Run on Server.

 

20.

In the Run on Server dialog, check the Always use this server when running this project checkbox, since we want to run the demo on this server.

Click Finish.

 

21.

The page loads up in the embedded browser.

 

22.

Enter your name in the field.

Click Submit.

 

23.

Your name is returned in the page.

Back to Topic

Back to Topic List

Debugging the Application

Back to Topic List

Placing a Break Point for Debugging

To create a Break Point in your application for debugging, perform the following steps:

1.

In the Project Explorer double click the response.jsp to open the file in the editor.

 

2.

In the code editor, double click in the left margin next to the Hello statement.


3.

This adds a breakpoint in your application.

Back to Topic

Back to Topic List

Running the Application in Debug Mode

Torun your application in debugging mode, perform the following steps:

1.

In the Project Explorer, right click the greeting.jsp node and select Debug As --> Debug on Server.

 

2.

On the Debug On Server dialog, choose the Switch mode option.

Click OK.

 

3.

In the embedded browser, click the Refresh button.

 

4.

Enter a name in the field name

Click Submit.

 

5.

The application runs up to the break point, and opens a Debug window.

The code editor pane indicates where the break occured.

 

6.

Open the Variables pane and select the hello entry. The property of the hello variable indicates that it is related to the bean.Hello class.

 

7.

Expand the hello node to display some additional information about the variable.

 

8.

The toolbar icons in the Debug pane allows you to control the debug process. Move the mouse over each icon to display each function.

Click the Disconnect icon to finish running the debug mode.

 

9.

In the Perspective menu, Select the Java EE to reopen the development environment.

You can close Eclipse. You've successfully performed this Eclipse overview OBE.

Back to Topic

Back to Topic List

This tutorial gave you a basic overview of Oracle Enterprise Pack for Eclipse. You created several projects, defined and started the WebLogic server, defined the deployment descriptors, created some JSP pages, set a break point and debugged the application on the server.

You've learned how to:

Back to Topic List

Place the cursor over this icon to hide all screenshots.