Examples Guide

 

+

Search Tips   |   Advanced Search

 

  1. Introduction
  2. Using the Split Development Directory Environment
  3. Basic Steps for Using the Examples
  4. The Examples Web Application
  5. More About Setting Up the Environment
  6. Set up the Environment for Type 4 Drivers
  7. More About Building Examples and examples.properties
  8. The Examples Database
  9. Running Examples from Another Directory
  10. Running the Examples Server Using a Different JVM
  11. Using Development or Production Mode To Run Examples
  12. Set up WebLogic Clusters for the Examples
  13. Use the Configuration Wizard to Create an Instance of WLS Examples Domain and Application
  14. Troubleshooting

 

Introduction

Examples are installed in...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\server

Source files are separated from the domain configuration files, just as they should be in a real-world scenario.

Source files are located in...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\server\examples\src

All examples include an instructions.html file that contain information required run that particular example, from building, to configuring, to running--and anything else you may need to know along the way.

The examples domain is in...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\domains\wl_server

...and contains...

Client and server classes required by the examples and PointBase are in...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\server\examples\build

The Pointbase demo database is in...

c:\oracle\Middleware\wlserver_10.3\common\eval\pointbase

...which also contains PointBase documentation and scripts that start, stop, and open the console for the PointBase database.

The sections below detail the general steps to take in order to run the examples. They also include tips, such as changing the port on which Oracle WebLogic Server listens, running the examples from a new directory, and troubleshooting.

To view the list of examples...

WebLogic Server Examples | Examples

 

Using the Split Development Directory Environment

Most of the Oracle WebLogic Server examples use the split development directory structure environment.

The source directory contains all editable files for the project

The build directory contents are generated automatically when you run the wlcompile ant task against a valid source directory.

The wlcompile task recognizes EJB, Web application, and shared library and class directories in the source directory, and builds those components in an order that supports common class path requirements. Additional Ant tasks can be used to build Web Services or generate deployment descriptor files from annotated EJB code.

The build directory contains only those files generated during the build process. The combination of files in the source and build directories form a deployable Java EE application.

 

Basic Steps for Using the Examples

The instructions.html file file for each example has all the documentation you need; this is a summary of the general steps you will take in every example.

 

Set up the Environment

Setting up the development environment includes...

To set up, run...

cd c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server
setExamplesEnv.cmd

If you ever change the number of the listen port of the Example server (from 7001), edit...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\server\examples\src\examples\jdbc\datasource\basic\simplesql.java

...and change the port number...

ht.put(Context.PROVIDER_URL, "t3://localhost:7001");

 

Building an Example

Some examples run directly from a browser when you boot up the server. These are the "out-of-the-box" examples that pop up in a window when you start the examples domain with Oracle WebLogic Server. The remaining Oracle WebLogic Server examples start off as Java source files that must be compiled into class files, or "built" before you can use them. WebLogic provides Ant scripts in XML files; running these scripts builds the corresponding example.

  1. Navigate to the directory of the example you want to run:

    cd c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\server\examples\src\examples\directoryName

  2. If the instructions.html file for the example instructs you to do so, edit...

    c:/oracle/Middleware/wlserver_10.3/samples/server/examples/src/examples.properties

    The Ant task uses this file to set system properties.

  3. The examples directory includes a build.xml file. This is the script that builds the example. Enter ant to build the example; Ant runs the script in the build.xml file.

 

Start the Examples Server

Start the examples server using one of the following procedures:

On Windows:

Start | All Programs | Oracle WebLogic | WebLogic Server | Examples | Start Examples Server

...or...

cd c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server
startWebLogic.cmd

On UNIX...

cd c:/oracle/Middleware/wlserver_10.3/samples/domains/wl_server/domains/wl_server
sh ./startWebLogic.sh

By default, the examples server uses port 7001 to listen for incoming connections. The MedRec server also uses the same listen port by default, which means that you cannot run both domains at the same time without changing one of the listen ports.

To run both domains at the same time, use the Administration Console to change the listen port of the examples server to something other than 7001, and then restart it. You can then run the MedRec server using its default listen port at the same that you run the examples server.

 

Start the Administration Console

To start the Administration Console:

  1. Start the examples server.

  2. Open a browser and point it to...

    http://localhost:7001/console

  3. Enter weblogic for the username and welcome1 for the password.

  4. Click Log In.

 

Running the Examples

To execute the run target that starts the example, cd to the example directory and execute...

ant run

To view the contents of the target, open the build.xml file with a text editor and locate the section with the target called "run."

The run target may use variables; in some cases you may need to edit the build.xml before you run the script. If you are having problems with an example, it is a good idea to check the run target. You may need to set a port, parameter, or some other information that is unique to the setup. Some examples require that you modify this command, if, for instance, there are multiple ways to run the example. Also, some examples do not include a run target, but must be started in a different manner. In all of the above cases, the example instructions.html will explain how to modify the command.

 

Stop the Examples Server

Use one of the following methods to stop the examples server:

 

The Examples Web Application

If an example uses servlets, JSP files, or applets, you can deploy it as a Web application. Oracle has taken many of these examples and put them into a single Web Application called examplesWebApp, located in...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\server\examples\build\examplesWebApp

Each example that requires the Web Application contains specific instruction on using examplesWebApp.

Follow these steps if you want to verify that examplesWebApp has been deployed:

  1. Start the Administration Console.

  2. Expand...

    Deployments | examplesWebApp | Targets

  3. Verify that the examplesServer target is checked.

  4. If the examplesServer is not targeted, select the checkbox next to examplesServer and click Save.

 

More About Setting Up the Environment

The setExamplesEnv script at...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server

...sets certain environment variables in the development shell, the command window from which you build and run the examples. These include...

The setExamplesEnv script also sets the CLASSPATH variable in the development shell to include certain classes you need to build and run the examples.

When you run setExamplesEnv, it overwrites anything that is currently in CLASSPATH. To run other Java applications or tools from within the development shell, edit the set CLASSPATH command in the setExamplesEnv script to include any classes those applications may require.

 

Set up Environment for Type 4 JDBC Drivers

Using a WebLogic Type 4 JDBC driver as a client requires an additional entries to the CLASSPATH variable.

 

More About Building Examples and the examples.properties file

Each example has an Ant task that builds the example. Each Ant task is named build.xml and is located in the example's source code directory.

To set system properties, the Ant task uses...

c:/oracle/Middleware/wlserver_10.3/samples/domains/wl_server/server/examples/src/examples.properties

You can use a text editor to edit examples.properties, if necessary. For example, if you have changed a directory location in the Oracle WebLogic Server home directory, are running the examples using an Oracle database, or have set the Oracle WebLogic Server to listen on a port other than 7001.

 

The Examples Database

The Oracle WebLogic Server examples use a demonstration database, Pointbase, which is a pure Java RDBMS that is included with Oracle WebLogic Server to allow you to run code examples.

The examples can also be run with Oracle as the database.

 

Running Examples from Another Directory

To install, build, and run the examples from a location other than where they were installed.

  1. Copy the directory structure that contains the source files to their own location
  2. Update examples.properties, startWebLogic, and config.xml to specify the new location of the source files

Example procedure...

  1. In a directory outside the Oracle WebLogic Server product directory, create a new directory for the example source files.

    mkdir c:/MyExamples

  2. Make two subdirectories...

    mkdir c:/MyExamples/>domains
    mkdir c:/MyExamples/> server

  3. Copy...

    cp -r c:/oracle/Middleware/wlserver_10.3/samples/domains/wl_server/server/examples/ c:/MyExamples/server/examples
    cp c:/oracle/Middleware/wlserver_10.3/samples/domains/wl_server/domains/wl_server c:/MyExamples/domains/wl_server

  4. Edit...

    c:/MyExamples/server/examples/src/examples.properties

    ...and set appropriate values...


    ### This file contains property settings for
    ### use in Examples' ant build scripts.
    ###

    ### General locations
    oracle.home=c:/oracle/Middleware
    wl.home=c:/oracle/Middleware/wlserver_10.3
    samples.home=c:/MyExamples

    ### WebLogic configuration
    wls.hostname=localhost
    wls.port=7001
    wls.username=weblogic
    wls.password=weblogic
    wls.server.name=examplesServer

    ### Examples src and domain directory locations
    examples.home.dir=c:/MyExamples/server/examples
    examples.domain.dir=c:/MyExamples/domains/wl_server

    ### Examples locations.
    examples.src.dir=${examples.home.dir}/src
    examples.build.dir=${examples.home.dir}/build
    auto.deploy.dir=${examples.domain.dir}/autodeploy
    client.classes.dir=${examples.build.dir}/clientclasses
    ex.webapp.dir=${examples.build.dir}/examplesWebApp
    ex.webapp.webinf.dir=${ex.webapp.dir}/WEB-INF
    ex.webapp.classes.dir=${ex.webapp.webinf.dir}/classes
    main.webapp.dir=${examples.build.dir}/mainWebApp
    main.webapp.webinf.dir=${main.webapp.dir}/WEB-INF
    main.webapp.classes.dir=${main.webapp.webinf.dir}/classes
    server.classes.dir=${examples.build.dir}/serverclasses

    ### Example specific locations
    xml.registry=${examples.domain.dir}/xml/registries/examplesXMLRegistry

    ### Example jars
    baseClient.jar=baseClient.jar
    utils.jar=utils.jar

    ### Examples classpath
    ex.classpath=${client.classes.dir};${client.classes.dir}/${utils.jar};${client.classes.dir}/${baseClient.jar};${java.class.path}

    ### Ant evaluted OS
    win.os="Windows XP,Windows 2000,Windows NT,Windows 98,Windows 95"
    unix.os="HP-UX,Solaris,SunOS,AIX,Linux"

    ### Database properties

    ### PointBase
    pointbase.dir=${wl.home}/common/eval/pointbase/databases
    pointbase.driver=com.pointbase.jdbc.jdbcUniversalDriver
    pointbase.url=jdbc:pointbase:server://localhost/demo
    pointbase.username=examples
    pointbase.password=examples
    pointbase.log=${examples.domain.dir}/pointbase.log

    ### Oracle
    oracle.driver=oracle.jdbc.OracleDriver
    oracle.host=samples
    oracle.port=1521
    oracle.sid=samples
    oracle.user=scott
    oracle.password=tiger

    ### MySQL
    mysql.driver=com.mysql.jdbc.Driver
    mysql.url=jdbc:mysql://localhost/test
    mysql.userid=
    mysql.password=
    mysql.classpath=#specify location of mysql-connector jar

    ### Compile options
    compiler=modern
    deprecation=yes
    debug=true
    failondeploy=true

    ### Designate which EJBGen annotation tags are used; 1.5 == JSR 175
    sourceVersion=1.5

  5. Navigate to...

    c:/MyExamples/domains/wl_server

  6. Edit setExamplesEnv, and set the DOMAIN_NAME location...

    set DOMAIN_HOME=c:\MyExamples\domains\wl_server

  7. Edit startWebLogic and set the DOMAIN_NAME location...

    set DOMAIN_HOME=e:\MyExamples\domains\wl_server

  8. Edit...

    DOMAIN_HOME\config\config.xml

    Several of the examples are dynamically deployed and have entries written to the config.xml on start up. If you have run the examples server at least once, you will have to remove the entries for the dynamic deployments from the config.xml

    Do not delete the application entries for the mainWebApp or examplesWebApp. Only delete entries for the remaining API examples, such as:

        <app-deployment>
    
          <name>ejb20BeanMgedEar</name>
          <target>examplesServer</target>
          <module-type>ear</module-type>
          <C:\Oracle\Middleware\wlserver_10.3\samples/server/examples/build/ejb20BeanMgedEar</source-path>
          <deployment-order>100</deployment-order>
          <security-dd-model>DDOnly</security-dd-model>
    
        </app-deployment>
    

  9. Search for the entries for the mainWebApp and examplesWebApp. Change the directory name in the Path attribute to the correct directory under MyExamples below:

        <app-deployment>
          <name>mainWebApp</name>
          <target>examplesServer</target>
          <module-type>war</module-type>
          <source-path>C:\Oracle\Middleware\wlserver_10.3\samples/server/examples/build/mainWebApp</source-path>
          <deployment-order>100</deployment-order>
          <ecurity-dd-model>DDOnly</security-dd-model>
        </app-deployment>
    
        <app-deployment>
          <name>examplesWebApp</name>
          <target>examplesServer</target>
          <module-type>war</module-type>
          <source-path>c:\Oracle\Middleware\wlserver_10.3\samples/server/examples/build/examplesWebApp</source-path>
          <deployment-order>100</deployment-order>
          <security-dd-model>DDOnly</security-dd-model>
       </app-deployment>
    

    Do not change the values in the <Server> element.

  10. Save the config.xml file.

    You can now build and run the examples from the MyExamples directory.

 

Running the Examples Server Using a Different JVM

Follow these instructions to run the Oracle WebLogic Server examples using a specific JVM vendor:

  1. Open a command shell, and set the JAVA_VENDOR environment variable to the name of the vendor whose JVM you want to use. For example, to use Sun's JVM, enter:
    set JAVA_VENDOR=Sun
    

    To use the JRockit JVM, enter:
    set JAVA_VENDOR=ORACLE
    

    Other vendor types installed with different versions of Oracle WebLogic Server include HP, IBM, and so forth. To see the default JVM used in the installation, check the contents of the c:\oracle\Middleware\wlserver_10.3\common\bin\commEnv script.

  2. Set the environment according to the instructions in Basic Steps for Using the Examples.

 

Using Development or Production Mode To Run Examples

You can run the Oracle WebLogic Server examples in either Production or Development mode.

In Development mode, applications stored in a domain are dynamically deployed, that is, deployed automatically when you start the server from...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server/wl_server/autodeploy

In Production mode, applications in the autodeploy directory are not automatically deployed; deploy them using either the Administration Console or the weblogic.Deployer tool.

By default, when you start the examples server, the examples domain is in Development mode.

To change a domain mode, set the production option in...

c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server/domains/wl_server/setExamplesEnv

...before starting the examples server. For example:

cd c:\Oracle\Middleware\wlserver_10.3\samples\domains\wl_server
setExamplesEnv.cmd production
startWebLogic.cmd

 

Set up WebLogic Clusters for the Examples

A subset of examples demonstrate how to use Oracle WebLogic Server clusters. You can run any of the examples in a clustered environment.

See:

 

Use the Configuration Wizard to Create an Instance of WLS Examples Domain and Application

To create a separate instance of WLS Examples, including the domain, application deployments, and source files...

  1. Start the Configuration Wizard and create a new Oracle WebLogic Server domain. Base the domain on...

    c:\oracle\Middleware\wlserver_10.3/common/templates/domains/wls.jar

  2. Re-run the Configuration Wizard and extend the base domain with the WLS Default extension template...

    c:\oracle\Middleware\wlserver_10.3/common/templates/applications/wls_default.jar

  3. Re-run the Configuration Wizard and extend the WLS Default domain with the WLS Examples extension template...

    c:\oracle\Middleware\wlserver_10.3/common/templates/applications/wls_examples.jar

See:

 

Troubleshooting

 

 

Instructions

  1. webservices - wss1.1 - instructions
  2. webservices - mtom - instructions
  3. webservices - jaxws - java2wsdl - instructions
  4. webservices - jaxws - wsdl2service - instructions
  5. webservices - security_jws - instructions
  6. webservices - jws_basic - complex - instructions
  7. webservices - jws_basic - simple - instructions
  8. webservices - jws_basic - ejbClient - instructions
  9. webservices - reliable - instructions
  10. webservices - wsrm_security - instructions
  11. webservices - wsdl2service - instructions
  12. diagnostics - wldfprofiles - instructions
  13. i18n - simple - instructions
  14. resadapter - simple - instructions
  15. webapp - jsf - basic - instructions
  16. webapp - jsp - tags - simple - instructions
  17. webapp - jsp - tags - taghandler - instructions
  18. webapp - jsp - expressions - instructions
  19. webapp - servlets - async - instructions
  20. webapp - servlets - annotations - extension - instructions
  21. webapp - servlets - annotations - standard - instructions
  22. webapp - lifecycle - instructions
  23. webapp - pubsub - stock - instructions
  24. wlst - online - instructions
  25. cluster - ejb - statefulSession - instructions
  26. cluster - sessionrep - inmemrep - instructions
  27. jta - jmsjdbc - instructions
  28. security - jaas - instructions
  29. security - sslclient - instructions
  30. xml - stax - instructions
  31. xml - xmlbean - instructions
  32. splitdir - helloWorldEar - instructions
  33. ejb - ejb20 - sequence - userDesignated - instructions
  34. ejb - ejb20 - basic - statefulSession - instructions
  35. ejb - ejb20 - basic - containerManaged - instructions
  36. ejb - ejb20 - basic - statelessSession - instructions
  37. ejb - ejb20 - basic - beanManaged - instructions
  38. ejb - ejb20 - message - instructions
  39. ejb - ejb20 - relationships - bands - instructions
  40. ejb - ejb30 - instructions
  41. ejb - ejb21 - ejbql - instructions
  42. ejb - ejb21 - timerService - instructions
  43. jms - messageformat - instructions
  44. jms - topic - instructions
  45. jms - sender - instructions
  46. jms - queue - instructions
  47. spring - sconfig - instructions
  48. jdbc - multidatasource - instructions
  49. jdbc - datasource - basic - instructions
  50. jdbc - rowsets - instructions