X

Java EE 6 Sample Application on WebLogic 12c: Conference Planner (TOTD #176)



href="http://www.oracle.com/technetwork/middleware/weblogic/overview/index.html">Oracle
WebLogic 12c provide a Java EE 6 Full Platform compliant
application server. During the href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&eventid=375727&sessionid=1&key=108E7A597FD93F05D40355E5A6A5F60C&partnerref=WLS12c_Launch_OTN&sourcepage=register">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 style="font-weight: bold;">Of The Day
(TOTD) shows how to deploy the application on WebLogic 12c.

  1. Check out the application from href="https://svn.java.net/svn/glassfish%7Esvn/branches/arun/ConferencePlanner/trunk/">svn.java.net/svn/glassfish~svn/branches/arun/ConferencePlanner/trunk/
    or download the href="http://glassfish.java.net/javaone2011/ConferencePlanner-devoxx-2011.zip">source
    bundle.
  2. Download and install href="http://db.apache.org/derby/releases/release-10.8.2.2.cgi">Apache
    Derby. If you are using JDK7 then it comes bundled with
    Derby and installed in directory
    (/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/db).
    Any other database can be used as well but the instructions will
    differ accordingly.


    1. Create "derby.properties" file in the main directory of and
      specify the following content:



      #

      derby.user.sa=sa



      This creates a user "sa" with the password "sa".

    2. Start the database by invoking the "bin/startNetworkServer"
      script.

    3. Copy "derbyclient.jar" to "mydomain/lib" directory and
      restart the server by using "mydomain/startWeblogic.sh"
      script.
    4. 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;


  3. href="http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html">Download,
    unzip, and configure WebLogic 12c as described in href="https://blogs.oracle.com/arungupta/entry/get_started_with_oracle_weblogic">TOTD
    #174. Here is my simple script that performs all the steps
    required:
    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.

  4. Access WebLogic Admin Console at href="http://localhost:7001/console">localhost:7001/console,
    the login/password used in href="https://blogs.oracle.com/arungupta/entry/get_started_with_oracle_weblogic">TOTD
    #174 is admin/admin007.
  5. Create a JDBC data source

    1. Click on "Data Sources" as shown.



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/eb12fc496a49521e492512b7f792996d/totd176_data_sources.png">

    2. Click on "New" and select "Generic Data Source" as shown.



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/7c2ae0e8610f86a315c7ec3d7a9ea8c5/totd176_generic_data_source.png">
    3. Specify the values as shown.



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/769b5c335225688d2c6d62c0a0d38b49/totd176_new_data_source.png">



      The JDBC resource name is "jdbc/cp" and the database is
      "Derby".

    4. 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.
    5. Take the defaults and select "Next".
    6. Specify the connection properties as shown.



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/d6db9ed452aae099e1821a3107087c8d/tod176_connection_properties.png">



      And click on "Next".

    7. 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".
    8. Select the target "myserver" as shown



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/947952f5b548a12d90b03b3e275ac8b6/totd176_targets.png">



      and click on "Finish".


  6. Deploy the application

    1. In the localhost:7001/console, click on "Home" (at the top
      center) and then "Deployments".



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/4dfd4a9f6dd4adac037ada18441ad8b9/totd176_deployments.png">

    2. Click on "Install".
    3. Specify the location of the WAR file as shown



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/e26f5f61e45a7483a6843e06411ddc96/totd176_war.png">



      Make sure to pick the WAR file by selecting the radio button
      and click on "Next".

    4. Take the defaults and click on "Next".
    5. Take the defaults again and click on "Next". Notice that
      "myserver" is chosen as the target of deployment.

    6. Click on "Finish". After the application is deployed the
      console shows the following snapshot:



      src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/5db99357b78eeaa2b62f789fd8988b9f/totd176_cp_deployed.png">


  7. Access the application at localhost:7001/ConferencePlanner to
    see the output as:



    src="//cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/f4a5b21d-66fa-4885-92bf-c4e81c06d916/Image/30a9d974e428e6239d94d32bf893a846/totd176_deploy_app_output.png">





Feel free to browse through the source code!



href="http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html">Download
WebLogic and play with it! href="https://blogs.oracle.com/arungupta/entry/java_ee_6_using_weblogic">Screencast
#39 explains how to build a more comprehensive Java EE 6
application using NetBeans and
WebLogic.

Join the discussion

Comments ( 4 )
  • Vidyadhar Sunday, May 20, 2012

    Hi,

    Nice tutorial. Tell me one thing how I can get the WAR file.


  • Arun Gupta Monday, May 21, 2012

    "mvn package" in the source bundle will build the WAR file.

    Arun


  • guest Saturday, July 13, 2013

    Do you have same tutorial on Java EE 7


  • Arun Gupta Wednesday, July 17, 2013

    Yes, Java EE 7 tutorial is available at:

    http://docs.oracle.com/javaee/7/tutorial/doc/home.htm


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services