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
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.
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.
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");
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.
cd c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\server\examples\src\examples\directoryName
c:/oracle/Middleware/wlserver_10.3/samples/server/examples/src/examples.properties
The Ant task uses this file to set system properties.
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.
To start the Administration Console:
http://localhost:7001/console
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.
Use one of the following methods to stop the examples server:
c:\oracle\Middleware\wlserver_10.3\samples\domains\wl_server\domains\domain_name\bin
Start Menu | All Programs | Oracle WebLogic Products | WebLogic Server | Examples
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:
Deployments | examplesWebApp | Targets
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.
Using a WebLogic Type 4 JDBC driver as a client requires an additional entries to the CLASSPATH variable.
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 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.
To install, build, and run the examples from a location other than where they were installed.
Example procedure...
mkdir c:/MyExamples
mkdir c:/MyExamples/>domains
mkdir c:/MyExamples/> server
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
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
c:/MyExamples/domains/wl_server
set DOMAIN_HOME=c:\MyExamples\domains\wl_server
set DOMAIN_HOME=e:\MyExamples\domains\wl_server
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>
<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.
You can now build and run the examples from the MyExamples directory.
Follow these instructions to run the Oracle WebLogic Server examples using a specific JVM vendor:
set JAVA_VENDOR=Sun
set JAVA_VENDOR=ORACLE
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
A subset of examples demonstrate how to use Oracle WebLogic Server clusters. You can run any of the examples in a clustered environment.
See:
To create a separate instance of WLS Examples, including the domain, application deployments, and source files...
c:\oracle\Middleware\wlserver_10.3/common/templates/domains/wls.jar
c:\oracle\Middleware\wlserver_10.3/common/templates/applications/wls_default.jar
c:\oracle\Middleware\wlserver_10.3/common/templates/applications/wls_examples.jar
See:
This error indicates that the port on which Oracle WebLogic Server is configured is being used by another process such as another Oracle WebLogic Server instance. To correct the error, configure a unique port or terminate the currently running process that is bound to the configured port.
This may occur if the browser is set up to access all URLs through a proxy server. If the machine running Oracle WebLogic Server is not registered with the proxy server, you will receive a URL failure from the browser. To correct this error, you can configure the browser to not use the proxy server at all or to exclude use of the proxy server when accessing an address that begins with the name of the machine running Oracle WebLogic Server.