Java EE 6 Sample Application on WebLogic 12c: Conference Planner (TOTD #176)
By arungupta on May 02, 2012
Oracle WebLogic 12c provide a Java EE 6 Full Platform compliant application server. During the launch event last year, a Java EE 6 application was shown that demonstrated all the features of Java EE 6. This application allows conference organizers to publish details about their conference such as tracks, sessions, and speakers. It also allows attendees to register for the conference and prepare their schedule. The application is built as a typical 3-tier Java EE 6 application using JavaServer Faces (with PrimeFaces widgets) for the front-end, Enterprise JavaBeans for the middle tier business logic, and Java Persistence API for connectivity with the database.
This Tip Of The Day (TOTD) shows how to deploy the application on WebLogic 12c.
- Check out the application from svn.java.net/svn/glassfish~svn/branches/arun/ConferencePlanner/trunk/ or download the source bundle.
- Download and install Apache
Derby. If you are using JDK7 then it comes bundled with
Derby and installed in directory
Any other database can be used as well but the instructions will
- Create "derby.properties" file in the main directory of and
specify the following content:
This creates a user "sa" with the password "sa".
- Start the database by invoking the "bin/startNetworkServer"
- Copy "derbyclient.jar" to "mydomain/lib" directory and restart the server by using "mydomain/startWeblogic.sh" script.
- Create and populate the database by invoking the interactive
SQL scripting tool "bin/ij". Specify the location of the SQL
from the application as shown.
./ij ij version 10.8 ij> driver 'org.apache.derby.jdbc.ClientDriver'; ij> connect 'jdbc:derby://localhost:1527/cp;ServerName=localhost;databaseName=cp;user=sa;password=sa;create=true'; ij> run '/Users/arungup/code/workspaces/arun/ConferencePlanner/trunk/src/main/sql/javaone-sf-2011.sql'; ij> . . . 1 row inserted/updated/deleted ij> exit;
unzip, and configure WebLogic 12c as described in TOTD
#174. Here is my simple script that performs all the steps
mkdir 12c cd 12c export CLASSPATH=/Users/arungup/tools/db-derby-10.8.2.2-bin/lib/derbyclient.jar
unzip ~/Downloads/wls1211_dev.zip export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home ./configure.sh . $MW_HOME/wlserver/server/bin/setWLSEnv.sh cd .. mkdir mydomain cd mydomain $JAVA_HOME/bin/java $JAVA_OPTIONS -Xmx1024m -XX:MaxPermSize=256m weblogic.Server
Notice, here we are explicitly including "derbyclient.jar" in the CLASSPATH. This will ensure that Derby database's JDBC driver is available to WebLogic Administration Console which was not able to pick up JAR files from "mydomain/lib" directory otherwise.
- Access WebLogic Admin Console at localhost:7001/console, the login/password used in TOTD #174 is admin/admin007.
- Create a JDBC data source
- Click on "Data Sources" as shown.
- Click on "New" and select "Generic Data Source" as shown.
- Specify the values as shown.
The JDBC resource name is "jdbc/cp" and the database is "Derby".
- Change the "Database Driver" to "Derby's Driver (Type 4) Versions: Any" and click on "Next". Make sure to not choose Type 4 XA driver which is the default.
- Take the defaults and select "Next".
- Specify the connection properties as shown.
And click on "Next".
- Click on "Test Configuration" to make sure that every thing is configured correctly. Make sure to see the message "Connection test succeeded.". Verify the defaults and click on "Next".
- Select the target "myserver" as shown
and click on "Finish".
- Deploy the application
- In the localhost:7001/console, click on "Home" (at the top
center) and then "Deployments".
- Click on "Install".
- Specify the location of the WAR file as shown
Make sure to pick the WAR file by selecting the radio button and click on "Next".
- Take the defaults and click on "Next".
- Take the defaults again and click on "Next". Notice that
"myserver" is chosen as the target of deployment.
- Click on "Finish". After the application is deployed the
console shows the following snapshot:
- Access the application at localhost:7001/ConferencePlanner to
see the output as:
Feel free to browse through the source code!
Download WebLogic and play with it! Screencast #39 explains how to build a more comprehensive Java EE 6 application using NetBeans and WebLogic.