|
|
|
|
Examples Index Ant PointBase Run Examples with PointBase Samples and Tutorials
|
|
Introduction
Basic Steps for Using the Examples
The Examples Web Application
More About Setting Up Your Environment
Setting Up Your Environment for Type 2 Drivers
More About Building Examples and examples.properties
The Examples Database
Examples Passwords and Server Start Up
Running Examples from Your Own Directory
Using Development or Production Mode To Run Examples
Setting up WebLogic Clusters for the Examples
Troubleshooting
*Please note the following conventions that are used throughout this document:
/ for
\ in path names.
bea_home represents the central support
directory for all BEA products installed on one machine; for example, c:\bea.
WL_HOME represents the top-level installation directory for the entire WebLogic Platform.
The default path is c:\bea\weblogic700, however, you are not required to install this directory
under bea_home.
SAMPLES_HOME
represents the WebLogic Server Platform examples home directory at
bea_home\weblogic700\samples.
This guide serves as a reference for the examples included with WebLogic Server. The examples are included with your
WebLogic installation in your SAMPLES_HOME\server directory. Within this directory we have separated out our source files
from the domain just as you might in a real world scenario.
The SAMPLES_HOME\server\src directory contains all the source files for the WebLogic Server Examples,
including the Pet Store Application. Included with each WebLogic Server example is a package-summary.html file.
This file contains all the information you will need to run that particular example,
from building, to configuring, to running--and anything else you may need to know along the way.
The SAMPLES_HOME\server\config
directory contains your examples domain; it contains your applications and the XML configuration files that define how your applications and WebLogic Server
will behave, as well as startup and environment scripts.
The SAMPLES_HOME\server\stage
directory contains client and server classes required by the examples, Pet Store, and PointBase.
The SAMPLES_HOME\server\eval directory contains PointBase, a demonstration database that the examples
are configured to use. It also contains the PointBase documentation and scripts that start, stop, and open the console for the PointBase
database.
The sections below detail the general steps that you will have to take in order to run the examples. They also include tips,
such as changing the port WebLogic listens on, running the examples from a new directory, and troubleshooting notes. If you
are looking for further information or help on how the examples are set up, read on. If you
are comfortable with WebLogic Server, go right to the overview-summary page that is in your
SAMPLES_HOME\samples\server\src\examples directory. This page has links to all the WebLogic examples.
These instructions describe the general tasks that need to be accomplished in order to run the WebLogic examples.
The package-summary.html file for each example has all the documentation you need; this is a summary of the general steps you will take.
Further along in this document it is explained in detail what exactly you are doing, and why.
Before you can build and run the examples, you need to properly set up your development environment. This includes specifying the location of a JDK, determining where client and server classes are placed, setting the CLASSPATH, and having certain tools available. We have included a script that will properly set all these values :
cd %SAMPLES_HOME%\server\config\examples.
setExamplesEnv.cmd - on Windows/CMD shell
. setExamplesEnv.sh - on UNIX Bourne shell
Some examples run right from a browser when you boot up the server. These are the 'out-of-the-box' examples and will pop up in a window when you start the examples domain with WebLogic Server. As in the real development world, the rest of the WebLogic examples start off as java source files. They must be compiled into class files, or 'built', first. We provide ant scripts in XML files; running these scripts will build the corresponding example. Here are the general steps:
cd SAMPLES_HOME\server\src\examples\directoryName.
package-summary.html file for your example instructs you to do so, edit the
examples.properties file at SAMPLES_HOME\server\src. The Ant task uses this file to set system properties.
build.xml file inside your examples directory, this is the script that builds the example.
Enter ant to build the example; it will run the script in the build.xml file. (if your example's
instructions indicate a different Ant target or build command, please follow the documentation).
The following are ways in which to start the examples server. On Windows:
Or ...
SAMPLES_HOME\server\config\examples
directory.
startExamplesServer.cmd
On UNIX Bourne shell:
cd $SAMPLES_HOME/server/config/examples
sh startExamplesServer.sh
You often need to use the WebLogic Server Console to set up an example before you run it.
To start the Console:
HTTP://localhost:7001/console.
The build scripts included with each example contain a run command. To run an example, go to the directory where the example is located and type:
ant run
This will execute the run target that starts the example; to view the command, go into the build.xml file and look for the section with the target
called 'run.' This command 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 your setup. Also, some examples require that you modify this command, if, for instance, there are multiple ways to run the example. In
all of the above cases, the example's package-summary.html will contain instructions telling you how to modify the command.
If an example uses servlets, JSP files, or applets,
you can deploy it as a Web application. We have taken many of these examples and put them into one Web Application
called examplesWebApp, located in the SAMPLES_HOME\server\stage\examples\examplesWebApp directory. Each example that requires it contains specific instruction on using the examplesWebApp.
Follow these steps if you wish to verify that the examplesWebApp has been deployed:
The setExamplesEnv script
at SAMPLES_HOME\server\config\examples
sets certain environment
variables in your development shell, the command window
from which you build and run the examples. It also sets the CLASSPATH properly.
When you develop in Java, you need a controlled
development environment to avoid class conflicts
and other problems that can be difficult to diagnose.
setExamplesEnv sets these variables that refer to specific locations:
SAMPLES_HOME - where the examples were installed
APPLICATIONS - application archives created when you build the examples
CLIENT_CLASSES - classes that the examples client applications require
SERVER_CLASSES - classes that the examples server-side classes require
COMMON_CLASSES - utility classes used by the examples, Pet Store, and PointBase
EX_WEBAPP_CLASSES -
classes required by the Examples Web Application used by the WebLogic Examples server
These variables point to directory locations in
SAMPLES_HOME\server\config\examples
or
SAMPLES_HOME\server\stage\examples.
If you are modifying the examples on your own, you can run the setExamplesEnv script and then use the above
variables when you develop. This saves you the time of having to set these items every time you need them.
The syntax for using environment variables
varies by platform. If you were using the CLIENT_CLASSES variable:
On Windows, you enter, for example:
%CLIENT_CLASSES%
On UNIX systems, enter
$CLIENT_CLASSES
The setExamplesEnv script also sets the CLASSPATH variable
in your development shell to include certain classes that you need as you build and run the examples. Since these classes could be anywhere on your system or
network, you need to specify where to find the classes you are trying to run. The contents of your CLASSPATH will vary
depending on the system you are running and how your directories are organized. Running the setExamplesEnv
script sets the CLASSPATH correctly for you when you are using the WebLogic Examples. Specifically, here are the jar files
and directories that setExamplesEnv puts in your CLASSPATH:
- BEA_HOME\jdk131\lib\tools.jar
- WL_HOME\server\lib\weblogic_sp.jar
- WL_HOME\server\lib\weblogic.jar
- SAMPLES_HOME\stage\examples\clientclasses
- SAMPLES_HOME\stage\examples\serverclasses
- SAMPLES_HOME\stage\examples\applications\examplesWebApp\WEB-INF\classes
- SAMPLES_HOME\server\eval\pointbase\client\lib\pbclient41ev.jar
- SAMPLES_HOME\server\eval\pointbase\server\libpbserver42ev.jar
When you run setExamplesEnv, it overwrites anything
that is currently in CLASSPATH.
If you want to run other Java applications or
tools from within your development shell, you
must edit the set CLASSPATH command in the
setExamplesEnv script to include any classes
those applications may require.
Using a WebLogic Type 2 JDBC driver as a client requires an additional
entry to your PATH variable.
For instructions on setting PATH,
see Installing WebLogic jDriver for Oracle.
If you want to use a Type 2 JDBC driver in a three-tier
architecture, also modify the PATH variable you use to start
WebLogic Server.
The WebLogic Server Examples Database Guide has instructions for setting up an
Oracle database for the examples.
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.
The Ant task uses the examples.properties file
to set system properties when it runs. The
examples.properties file is located at
SAMPLES_HOME/server/src.
By default, when you download WebLogic Server, the
examples.properties file looks like this:
choose classic, modern, jikes, or jvc
JAVAC=modern
WL_HOME=C:/bea/weblogic700
BEA_HOME=C:/bea
SAMPLES_HOME=C:/bea/weblogic700/samples
CLIENT_CLASSES=C:/bea/weblogic700/samples/server/stage/examples/clientclasses
SERVER_CLASSES=C:/bea/weblogic700/samples/server/stage/examples/serverclasses
EX_WEBAPP_CLASSES=C:/bea/weblogic700/samples/server/stage/examples/examplesWebApp/WEB-INF/classes
APPLICATIONS=C:/bea/weblogic700/samples/server/config/examples/applications
CLASSPATH=java.class.path
XMLRegistry=C:/bea/weblogic700/samples/server/config/examples/xml/registries/examplesXMLRegistry
PORT=7001
# Database properties
# These user defined properties are available to automate
# table setup for those examples that use an Oracle database.
DBSERVER=
DBPORT=
SID=
USER=
PASSWORD=
You can use a text editor to edit examples.properties
if you need to. For example, if you have changed a directory
location in your WebLogic home directory, are running the examples using an Oracle database, or have set your WebLogic
Server to listen on a port other than 7001.
If you changed the port number when you
installed WebLogic Server, rather than accepting
the default port of 7001, you will need to edit
the examples.properties file to change it
there as well.
The examples use a demonstration database: Pointbase 4.2. PointBase Server is a pure Java relational database management system (RDBMS) that is included with WebLogic Server. Its purpose is to allow you to run code examples with a functional database server. For more information on PointBase and the examples see our PointBase page. The examples can also be run with Oracle as the database; for instructions on how to do so, see the database setup page.
The examples and PetStore domains use weblogic/weblogic as their username/password combination. The
startExamplesServer scripts set these
values as:
set WLS_USER=weblogic
This script sets some additional values for initial server startup, and then calls the startWebLogic script located in your
set WLS_PW=weblogicWL_HOME\server\bin directory. This script is what actually starts the server.
In there the following parameters are set:
-Dweblogic.management.username=%WLS_USER%
-Dweblogic.management.password=%WLS_PW%
If you ever need to change your username/password for the examples and Pet Store domains, you will have to change the values in the examples startExampleServer script.
In the default configuration the server will start up without prompting for a password. If you wish to reenable start-up security, simply remove the username/password values from the startWebLogic script; the server will then prompt for a username/password when you start it.
You may want to install, build, and run the examples from a location other than where they were installed. This is useful if several developers are working with one WebLogic Server installation, or if you simply want to become accustomed to developing in a directory of your own choosing. It is also a best practice; keeping your domains in a separate location apart from you WebLogic installation helps keep potential conflicts to a minimum, and means you won't have multiple developers altering files that are inside WebLogic's own directories.
These instructions show you an example of how
to set up your own directory structure to build and
run examples from a location you choose using Windows Explorer.
The general idea behind these steps are two-fold; you must copy the directory structure with the source files of the
examples to your own location and also inform WebLogic Server where your new domain resides.
WebLogic will know where your new domain is located as long as you modify the following files as instructed below:
examples.properties, startExamplesServer,
and config.xml files.
myexamples_home and I put it in my C: drive. When you follow
these instructions, replace the value of myexamples_home with the location you have chosen for the examples.
myexamples_home, make a directory named
server.
server, make directories named
config and src and stage.
SAMPLES_HOME\server\src\examples
to myexamples_home\server\src.
SAMPLES_HOME\server\config\examples
to myexamples_home\server\config.
SAMPLES_HOME\server\stage\examples and SAMPLES_HOME\server\stage\common
to myexamples_home\server\stage.
SAMPLES_HOME\server\src\examples.properties
to myexamples_home\server\src.
You should now have this directory structure:
examples.properties file in the myexamples_home\server\src directory
to change the value of certain variables
(shown in blue):
#choose classic, modern, jikes, or jvc
JAVAC=modern
WL_HOME=C:/bea/weblogic700
BEA_HOME=C:/bea
SAMPLES_HOME=C:/myexamples_home
CLIENT_CLASSES=C:/myexamples_home/server/stage/examples/clientclasses
SERVER_CLASSES=C:/myexamples_home/server/stage/examples/serverclasses
EX_WEBAPP_CLASSES=C:/myexamples_home/server/stage/examples/examplesWebApp/WEB-INF/classes
EX_WEBAPP=C:/myexamples_home/server/stage/examples/examplesWebApp
APPLICATIONS=C:/myexamples_home/server/config/examples/applications
CLASSPATH=java.class.path
XMLRegistry=myexamples_home/server/examples/server/config/examples/xml/registries/examplesXMLRegistry
PORT=7001
# Database properties
# These user defined properties are available to automate
# table setup for those examples that use an Oracle database.
DBSERVER=
DBPORT=
SID=
USER=
PASSWORD=
myexamples_home\server\config\examples directory.
startExamplesServer
script, and set the SAMPLES_HOME to the location you've chosen for the examples:
set SAMPLES_HOME=C:\myexamples_home
@rem ******
@rem Pointbase and examples domain specific configuration
set SAMPLES_HOME=C:\myexamples_home
set APPLICATIONS=%SAMPLES_HOME%\server\config\examples\applications
set CLIENT_CLASSES=%SAMPLES_HOME%\server\stage\clientclasses
set SERVER_CLASSES=%SAMPLES_HOME%\server\stage\serverclasses
set COMMON_CLASSES=%SAMPLES_HOME%\server\stage\common
set POINTBASE_HOME=%SAMPLES_HOME%\server\eval\pointbase
set EX_WEBAPP_CLASSES=%SAMPLES_HOME%\server\stage\examplesWebApp\WEB-INF\classes
config.xml file
with a text editor. 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 following entries from
the config.xml in your myexamples/home/server/config directory, make sure to not to delete the three
application entries that are not in this list (the security, default Web Application, and examples Web Application):
<Application Deployed="true"
Name="_appsdir_ejb20_basic_beanManaged_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\ejb20_basic_beanManaged.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="ejb20_basic_beanManaged.jar"
Targets="examplesServer" URI="ejb20_basic_beanManaged.jar"/>
</Application>
<Application Deployed="true"
Name="_appsdir_ejb20_basic_containerManaged_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\ejb20_basic_containerManaged.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="ejb20_basic_containerManaged.jar"
Targets="examplesServer" URI="ejb20_basic_containerManaged.jar"/>
</Application>
<Application Deployed="true"
Name="_appsdir_ejb20_basic_statefulSession_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\ejb20_basic_statefulSession.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="ejb20_basic_statefulSession.jar"
Targets="examplesServer" URI="ejb20_basic_statefulSession.jar"/>
</Application>
<Application Deployed="true"
Name="_appsdir_ejb20_basic_statelessSession_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\ejb20_basic_statelessSession.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="ejb20_basic_statelessSession.jar"
Targets="examplesServer" URI="ejb20_basic_statelessSession.jar"/>
</Application>
<Application Deployed="true" Name="_appsdir_ejb20_homemethods_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\ejb20_homemethods.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="ejb20_homemethods.jar"
Targets="examplesServer" URI="ejb20_homemethods.jar"/>
</Application>
<Application Deployed="true" Name="_appsdir_ejb20_message_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\ejb20_message.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="ejb20_message.jar" Targets="examplesServer" URI="ejb20_message.jar"/>
</Application>
<Application Deployed="true" Name="_appsdir_jdbc_oracle_ext_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\jdbc_oracle_ext.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="jdbc_oracle_ext.jar"
Targets="examplesServer" URI="jdbc_oracle_ext.jar"/>
</Application>
<Application Deployed="true" Name="_appsdir_jms_messageformat_jar"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="jms_messageformat" Targets="examplesServer" URI="jms_messageformat.jar"/>
</Application>
<Application Deployed="true" Name="_appsdir_jta_ejb_jmsjdbc_jar"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="jta_ejb_jmsjdbc" Targets="examplesServer" URI="jta_ejb_jmsjdbc.jar"/>
</Application>
<Application Deployed="true" Name="_appsdir_webservices_trader_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\webservices_trader.ear"
StagedTar<gets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="trader.jar" Targets="examplesServer" URI="trader.jar"/>
<WebServiceComponent Name="trader_service.war"
Targets="examplesServer" URI="trader_service.war"/>
</Application>
<Application Deployed="true" Name="_appsdir_xml_xslt_content_ear"
Path="D:\load19\weblogic700\myexamples_home\server\config\examples\applications\xml_xslt_content.ear"
StagedTargets="examplesServer" StagingMode="stage" TwoPhase="true">
<EJBComponent Name="xml_xslt_content.jar"
Targets="examplesServer" URI="xml_xslt_content.jar"/>
</Application>
<application>
entries that are left.
Change the directory name in the PATH attribute to myexamples_home
or the correct directory under myexamples_home:
<Application
Deployed="true"
Name="DefaultWebApp"
Path="C:\myexamples_home\server\config\examples\applications"
>
<Application
Deployed="true"
Name="security"
Path="C:\myexamples_home\server\src\examples\webapp">
<Application
Deployed="true"
Name="examplesWebApp"
Path="C:\myexamples_home\server\stage\examples" TwoPhase="false">
Do not change the values
in the <server> element.
In config.xml, leave those values
alone.
config.xml file.
myexamples_home directory.
Build and run the examples according
the instructions in the example's documentation that you wish to run.
You can run the WebLogic Server examples and Pet Store 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; in Production mode, this is not the case and you must deploy an application manually. For instructions on deploying applications, see the Deploying Applications chapter in the Administration Guide. By default, when you start the examples server, the examples domain is in development mode, and the petstore domain is in production mode.
If you want to change a domain's mode, follow these steps:
SAMPLES_HOME\server\config\examples\startExamplesServer
SAMPLES_HOME\server\config\petStore\startPetStore
set STARTMODE=
to add the value True or False.
It looks like this:
@rem Set Production Mode. When this is set to true, the server starts up in
@rem production mode. When set to false, the server starts up in development
@rem mode. If it is not set, it will default to false.
set STARTMODE=
True is for production mode, and false
or no value is for development mode.
Some of the examples demonstrate how to use WebLogic in clusters, also you can run any of the examples in a clustered environment. For information on clusters and how to set them up, read our Examples Cluster Guide. Also, check out our WebLogic Clustering Documentation.
java.net.BindException - Address already in use.
You can continue safely with this error. It means that the PointBase database has already been started by another process. If you see this error, simply disregard it.
Page cannot be displayed or a
Error 404 - Not found error when attempting to
access the server with a browser.
This can happen if your browser is set up to access all URLs through a proxy server. If the machine running WebLogic Server is not registered with the proxy server, you will receive a URL failure from your browser. To fix this, you can configure your browser to not use the proxy server, or to not use the proxy server to access an address that begins with the name of the machine running WebLogic Server.
![]()
|
Last updated: April 2002 |
|
|
Home |
Corporate Info |
News |
Solutions |
Products |
Partners |
Services |
Events |
Download |
How to Buy
Copyright © 2002, BEA Systems, Inc. All rights reserved.
Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.
Contact BEA