Installing, Configuring, and Testing WebLogic Server 12c Developer Zip Distribution in NetBeans


This tutorial covers how to install Oracle WebLogic Server 12c (12.1.1) developer zip file distribution on Windows and configure it as a Java EE Application Server in NetBeans.
Also covers how to test the WebLogic Server installation by deploying a Web application based on JSF and JPA entities.

Time to Complete
Approximately 45 minutes

Oracle WebLogic Server 12c is an application server for building and deploying enterprise Java EE applications and it is now available for download. The zip distribution for development offers Java EE 6 Full Profile development; it includes WebLogic Server only.
With NetBeans IDE you can create web applications and deploy them to the Oracle WebLogic Server.

In this tutorial, you perform the following:
  • Download WebLogic Server (WLS) 12c developer zip file and extract the contents
  • Set up environment variables as required
  • Run the installation configuration script
  • Set up WLS environment
  • Create a new WLS domain
  • Register the Oracle WebLogic Server with the NetBeans IDE
  • Open the Admin Console
  • Start Java DB
  • Use the sample database and generate the JPA entities from the database
  • Generate JSF pages from the Entities
  • Deploy the application to WebLogic Server

Download and install Java JDK 7 from this link.
Download and install NetBeans IDE 7.2 from this link.

Downloading WebLogic Zip File and Extracting the Contents

In this section you will download the development zip file and unzip the contents in a directory.

1. Open a browser and type the following URL:

2. ClickDownload Filefor "Zip for Windows x86, Linux x86, Mac OS X", underOracle Fusion Middleware Software Downloadssection.
You need toAccept Licence Agreementbefore you can download the file.

Windows, Linux, Mac OS X and Generic Installer (for use with 64-bit JVMs) are also options to download in addition to the developer zip file.

3. Create theD:\weblogic\wlsdirectory in your computer.

4. Unzip the downloaded file into thewlsdirectory folder.
#OUGTH: ทดลองกับ 12.1.3, file ชื่อ

Setting Up the Environment
In this section, you will set up the three environment variables needed: JAVA_HOME, MW_HOME and JAVA_VENDOR. Also, you will run the installation script and create the WebLogic Server domain.

Setting Up the Three Environment Variables
1. Verify the path and the folder name of your JDK 7 installation in your computer. Normally it is underC:\Program Files\Java\:

Your JDK 7 installation folder name could include a build version:jdk1.7.0_<build version>. You will need to type the full folder name when setting JAVA_HOME two steps further.

2. Open a command window.(Start>Run>cmd).
Type the following command togo to the D:\weblogic\wls folder, which is where you unzipped the developer zip file:
pushd D:\weblogic\wls

3. Type the following commands to set the three environment variables.

set JAVA_HOME=C:\PROGRA~1\Java\jdk1.7.0
set MW_HOME=D:\weblogic\wls

Note: The JAVA_HOME value cannot contain any spaces, and that is whyPROGRA~1is used as thePROGRAM FILESdirectory short name.
To discover the short name of your Program Files folder you can use thedir /Xcommand

4. Keep the Command Prompt window opened for the next step. This is in order to maintain the environment variables.

Running the Installation Configuration Script
1. In MW_HOME (D:\weblogic\wls), execute configure.cmd to launch the installation configuration script.

2. Type the following command to set up the WLS environment in the current shell :


#OUGTH: หน้าจอของ 12.1.3 จะถามให้ไปสร้าง domain ต่อเลย.

3. Keep the Command Prompt window opened for the next step.

Creating the Domain

Before you can develop and run WebLogic, you must first create a WebLogic Server domain, which is the basic administration unit:

1. Create the domain folder.
Type the following command:

mkdir D:\weblogic\domain

2. Move to the recently created domain folder:

cd D:\weblogic\domain

3. Run the following command to set up the domain on this folder:

%JAVA_HOME%\bin\java.exe weblogic.Server %JAVA_OPTIONS% -Xmx1024m -XX:MaxPermSize=350m

Because you are using JDK 7 you might encounter PermGen errors, and because of that you are using a MaxPermSize value of 350 to avoid it. Otherwise you can use the default of 128m:
%JAVA_HOME%\bin\java.exeweblogic.Server%JAVA_OPTIONS% -Xmx1024m -XX:MaxPermSize=128m

3.1. Answer the installation questions:
  • Create a default configuration and boot? y #OUGTH: ข้อนี้ใน 12.1.3 ไม่ถามแล้ว.
  • Enter username to boot Weblogic server: weblogic
  • Enter password to boot Weblogic server: welcome1

WebLogic finishes loading and displays<The server started in RUNNING mode.>in the output window.
There is additional information at the end of this tutorial about using 64-Bit JDK and using GUI mode when creating the domain.

#OUGTH: 12.1.3 จะสร้าง domain ไว้ที่ C:\wls1213\user_projects\domains\mydomain เป็น default.

4. Press Ctrl+C to stop the WebLogic Server.
Last command besides configuring the domain also started the WebLogic Server. However this is not the normal procedure to start the server. Following step shows how to 5. start the WebLogic Server from the command line.

5. Start the WebLogicServer by executing the following command, which is provided in the domain folder:

5.1. Press Ctrl + C To shut the WebLogic Server down.

Configuring WebLogic Server in NetBeans

This section will show you how to register the WebLogic Server with the NetBeans IDE.

1. Start NetBeans. Open the Services Window (Window -> Services).
#OUGTH: ต้องสร้าง project ขึ้นมาก่อน. ให้ New Java EE Application.

Expand the Servers folder - GlassFish Server is included with NetBeans Enterprise Edition and installed automatically.

2. Right-click the Servers folder. Select Add Server...

3. SelectOracle WebLogic Server. ClickNext.

4. EnterD:\weblogic\wls\wlserveras the Server Location. ClickNext.

5. Verify that the Domain location isD:\weblogic\domain.
Enterweblogicfor username andwelcome1for password.

NetBeans has created inServicestab the WebLogic Server instance.

6. From the Services tab, right-click theOracle WebLogic Serverunder the Servers node. Click Start.

WebLogic finishes loading and displays<The server started in RUNNING mode.>in the output window.
Now you can Start, Stop and Deploy Web Applications using WebLogic Server in the NetBeans IDE.

#OUGTH: ถ้า start จาก terminal ข้องนอกอยู่แล้ว, NetBeans จะรู้ว่าเปิดอยู่ menu start จะ click ไม่ได้.

7. Right-click theOracle WebLogic Server. ClickView Admin Console.

The Admin Console enables you to administer the WebLogic Server.
Alternatively, you can open a web browser and enter the URL http://localhost:7001/console

8. On the Admin Console, enterweblogicfor username andwelcome1for password.

With the Admin Console you can administer your WebLogic Server

Testing your WebLogic Server Installation
In this section, you will test your WebLogic Server installation by deploying a Web application using JSF and JPA entities from the sample database.

Opening Sample Database

1. In NetBeans, in theServicestab, expand the Databases folder.

2. Right-clickJava DB. ClickStart Server.

An Output Window opens and indicate that Apache Derby Network Server started.

3. Right-click the connection titled jdbc:derby://localhost:1527/sample [app on APP]. Click Connect.
4. Expand the connection. ExpandAPP.
This is the name of the schema for the sample database, it contains all of the tables, views and stored procedures associated with this schema.

5. Expand the Tables.
Right-click CUSTOMER. Select View Data.
This is one of the ways to perform SQL queries directly on the database tables. In the SQL Command Window that opened, you can execute other queries as well.

Creating a Java EE Web Application Project

1. ClickFile -> New Project.

2. SelectJava Webfrom Categories andWeb Applicationfrom Projects. ClickNext.

3. Enter JPASampleTest as the Project Name.
Set the Project Location toD:\NetBeansProjectsor the folder path that you want for your NetBeans projects.

4. Verify thatOracle WebLogic Serveris selected as the Server.
Verify that Java EE version isJava EE 6 Web.
Check the box forEnable Contexts and Dependency Injection.
Uncheck the default box toSet Source Level to 6.

5. SelectJavaServer Facesas the Framework. ClickFinish.

Adding Entities Generated from the Sample Database to the Project

The sample database is provided with every NetBeans installation. It contains a number of tables populated with data.

1. Right-click the project. SelectNew -> Other.

2. ChoosePersistencefrom Categories andEntity Classesfrom Database as the file type. ClickNext.

3. Click the Data Source drop-down list. SelectNew Data Source.

4. Enterjdbc/sampleDBas the JNDI Name.
Selectjdbc:derby//localhost:1527/sample [app on APP]as the Database connection.

5. ClickAdd Allto move all of the tables from theAvailable Tablescolumn to theSelected Tablescolumn. ClickNext.

6. Entercom.example.entityas the package name.
UncheckGenerate JAXB Annotations. JAXB is not used on this example.
NetBeans generates the Entity classes and Named queries for each of the tables in the database.

Reviewing the Entity Classes Created

1. Open theCustomer.javaentity file located under thecom.example.entityfolder:

At the top of the class is the@Entityannotation that indicates this is an entity for theCUSTOMERtable.
Named queries containJava Persistence Query Languagestatements, which look like SQL commands, one for every combination of query of the table:

The class declares a fields for each of the table's columns, using@Idto define the primary key column:

Near the bottom of the field list, there are some relationship annotations named@ManytoOne, which define the relationship between this entity and other entities.MicroMarketandDiscountCodeare two examples of@ManytoOneannotations:

The rest of the class contains getter/setter methods.

Adding JSF View Pages and Supporting Classes to the Project

1. Right-click the project. SelectNew -> Other.

2. SelectJavaServer Facesfrom Categories andJSF Pages from Entity Classesfrom File Types. ClickNext.

3. ClickAdd Allto move theAvailable Entity classescolumn to theSelected Entity classescolumn. ClickNext.

4. Modify the package name of theSession Bean Packagetocom.example.ejb.

Modify the package name of theJSF classestocom.example.bean.

NetBeans generates a set of view pages under the Web Pages folder, with each group of view functionality pages (view, edit, create, list) in a folder named by the table they support.

Thecom.example.beanfolder contains the generated view/controller classes (JSF managed beans) for each of the tables in the sample database.

Thecom.example.ejbpackage contains the session beans that perform the work of getting the data out of and into the database using EJB Session beans. These classes are named with Facade - for example,CustomerFacade. The class uses the facade design pattern - basically, this class represent the "face" of the Customer entity to the CustomerController class:

Running the Project and Testing the Code

1. Run the project.
Right-click the project. SelectRun.

This will take awhile to compile and build the classes, to copy the JDBC drivers to the appropriate folder in WebLogic server and to deploy the project and start the Web browser.

2. Test the Code.
Click theShow All Customer Itemslink.

2.1. Experiment wit theView,EditandDestroylinks on the far right side of the table:

This is a quick way to check that WebLogic Server is operating properly and can connect to the database through JPA.

Additional Information on Creating Domains

1. If you get the following error while creating the domain:
<Error><Security><BEA-090783><Server is Running in Development Mode and Native Library(terminalio) to read the password securely from commandline is not found.>
Then you are using a 64-bit JDK. You can either switch to a 32-bit JDK or change four environment variables in the%MW_HOME%\wlserver\server\common\bin\commEnv.cmdfile. Find the following lines in the file and change them as shown:
set JAVA_USE_64BIT=true
set WL_USE_X86DLL=false
set WL_USE_IA64DLL=false
set WL_USE_AMD64DLL=true

You might need to close the current Command Prompt window and open a new one, then set up the three environment variables and execute setWLSEnv.cmd again.

2. You can also create the domain by invoking the GUI configuration in the Command Prompt window:


You need to set up the three environment variablesJAVA_HOME,MW_HOMEandJAVA_VENDORto execute this command. You can extend an existing WebLogic Domain using the Configuration Wizard.

In this tutorial, you have learned how to:
  • Run the WebLogic Server 12c installation configuration script
  • Set up WebLogic Server environment
  • Create a new WebLogic Server domain
  • Register the Oracle WebLogic Server with the NetBeans IDE
  • Test your WebLogic Server installation by deploying a Web application that uses JSF and JPA entities.
  • Curriculum Developer: Edgar Martinez
  • Other Contributors: Tom Mcginn

Permalink: | E

• เพิ่ม.

• ทดลองทำ OBE นี้ด้วย 12.1.3, หน้าจอ configure.cmd เปลี่ยนไปนิดหน่อย.