Programming
Programming
Server
Contents
iii
Upgrading Deployment Descriptors From Previous Releases of J2EE and WebLogic Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15 Deployment Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16 Development Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Apache Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Source Code Editor or IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18 Database System and JDBC Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18 Web Browser. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19 Third-Party Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
iv
libclasspath Task Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 libclasspath Ant Task Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 Main libclasspath Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 Nested libclasspath Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 Example libclasspath Ant Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
vi
Versioned Applications Access the Current Version JNDI Tree by Default . . . . . . . 6-3 Security Providers Must Be Compatible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Applications Must Specify a Version Identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Applications Can Access Name and Identifier. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Client Applications Use Same Version when Possible. . . . . . . . . . . . . . . . . . . . . . . . 6-4 Assigning an Application Version. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 Application Version Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 Upgrading Applications to Use Production Redeployment. . . . . . . . . . . . . . . . . . . . . . . . 6-6 Accessing Version Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
vii
javax.annotation.security.RunAs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
viii
ix
xi
xii
CHAPTER
The following sections provide an overview of WebLogic Server applications and basic concepts. Document Scope and Audience on page 1-2 Overview of Java EE Applications and Modules on page 1-3 Web Application Modules on page 1-4 Enterprise JavaBean Modules on page 1-5 Connector Modules on page 1-6 Enterprise Applications on page 1-7 WebLogic Web Services on page 1-8 JMS and JDBC Modules on page 1-9 WebLogic Diagnostic Framework Modules on page 1-10 XML Deployment Descriptors on page 1-10 Deployment Plans on page 1-16 Development Software on page 1-17
1-1
1-2
Constructing web applications is made easier with JavaServer Faces (JSF) technology and the JSP Standard Tag Library (JSTL). Java EE 5 supports rich thin-client technologies such as AJAX, for building applications for Web 2.0. WebLogic Server Java EE applications are based on standardized, modular components. WebLogic Server provides a complete set of services for those modules and handles many details of application behavior automatically, without requiring programming. Java EE defines module behaviors and packaging in a generic, portable way, postponing run-time configuration until the module is actually deployed on an application server. Java EE includes deployment specifications for Web applications, EJB modules, Web Services, Enterprise applications, client applications, and connectors. Java EE does not specify how an application is deployed on the target serveronly how a standard module or application is packaged. For each module type, the specifications define the files required and their location in the directory structure. Note: Because Java EE is backward compatible, you can still run Java EE applications on WebLogic Server versions 8.1 and higher. Java is platform independent, so you can edit and compile code on any platform, and test your applications on development WebLogic Servers running on other platforms. For example, it is common to develop WebLogic Server applications on a PC running Windows or Linux, regardless of the platform where the application is ultimately deployed. For more information, refer to the Java EE specification at:
http://java.sun.com/javaee/5/docs/api/
A WebLogic application can also include the following WebLogic-specific modules: JDBC and JMS modulesSee JMS and JDBC Modules on page 1-9. WebLogic Diagnostic FrameWork (WLDF) modulesSee WebLogic Diagnostic Framework Modules on page 1-10.
Servlets
Servlets are Java classes that execute in WebLogic Server, accept a request from a client, process it, and optionally return a response to the client. An HttpServlet is most often used to generate dynamic Web pages in response to Web browser requests.
JavaServer Pages
JavaServer Pages (JSPs) are Web pages coded with an extended HTML that makes it possible to embed Java code in a Web page. JSPs can call custom Java classes, known as tag libraries, using HTML-like tags. The appc compiler compiles JSPs and translates them into servlets. WebLogic Server automatically compiles JSPs if the servlet class file is not present or is older than the JSP source file. See Building Modules and Applications Using wlappc on page 4-4. You can also precompile JSPs and package the servlet class in a Web Application (WAR) file to avoid compiling in the server. Servlets and JSPs may require additional helper classes that must also be deployed with the Web application.
1-4
E nt e r pr i s e J av aB e a n M o d ul e s
EJB Overview
Session beans execute a particular business task on behalf of a single client during a single session. Session beans can be stateful or stateless, but are not persistent; when a client finishes with a session bean, the bean goes away. Entity beans represent business objects in a data store, usually a relational database system. Persistenceloading and saving datacan be bean-managed or container-managed. More than
Developing Applications with WebLogic Server 1-5
just an in-memory representation of a data object, entity beans have methods that model the behaviors of the business objects they represent. Entity beans can be accessed concurrently by multiple clients and they are persistent by definition. The container creates an instance of the message-driven bean or it assigns one from a pool to process the message. When the message is received in the JMS destination, the message-driven bean assigns an instance of itself from a pool to process the message. Message-driven beans are not associated with any client. They simply handle messages as they arrive.
Connector Modules
Connectors (also known as resource adapters) contain the Java, and if necessary, the native modules required to interact with an Enterprise Information System (EIS). A resource adapter deployed to the WebLogic Server environment enables Java EE applications to access a remote EIS. WebLogic Server application developers can use HTTP servlets, JavaServer Pages (JSPs), Enterprise Java Beans (EJBs), and other APIs to develop integrated applications that use the EIS data and business logic. To deploy a resource adapter to WebLogic Server, you must first create and configure WebLogic Server-specific deployment descriptor, weblogic-ra.xml file, and add this to the deployment
1-6
directory. Resource adapters can be deployed to WebLogic Server as stand-alone modules or as part of an Enterprise application. See Enterprise Applications on page 1-7. For more information on connectors, see Programming WebLogic Resource Adapters.
Enterprise Applications
An Enterprise application consists of one or more Web application modules, EJB modules, and resource adapters. It might also include a client application. An Enterprise application can be optionally defined by an application.xml file, which was the standard J2EE deployment descriptor for Enterprise applications.
For development purposes, BEA recommends the WebLogic split development directory structure. Rather than having a single archived EAR file or an exploded EAR directory structure, the split development directory has two parallel directories that separate source files and output files. This directory structure is optimized for development on a single WebLogic Server instance. See Chapter 3, Creating a Split Development Directory Environment. BEA provides the wlpackage Ant task, which allows you to create an EAR without having to use the JAR utility; this is exclusively for the split development directory structure. See Packaging Applications Using wlpackage on page 5-1. For development purposes, BEA further recommends that you package stand-alone Web applications and Enterprise JavaBeans (EJBs) as part of an Enterprise application, so that you can take advantage of the split development directory structure. See Organizing Java EE Components in a Split Development Directory on page 3-6. For production purposes, BEA recommends the exploded (unarchived) directory format. This format enables you to update files without having to redeploy the application. To update an archived file, you must unarchive the file, update it, then rearchive and redeploy it. You can choose to package your application as a JAR archived file using the jar utility with an .ear extension. Archived files are easier to distribute and take up less space. An EAR file contains all of the JAR, WAR, and RAR module archive files for an application and an XML descriptor that describes the bundled modules. See Packaging Applications Using wlpackage on page 5-1. The optional META-INF/application.xml deployment descriptor contains an element for each Web application, EJB, and connector module, as well as additional elements to describe security roles and application resources such as databases. If this descriptor is present the WebLogic deployer picks the list of modules from this descriptor. However if this descriptor is not present, the container guesses the modules from the annotations defined on the POJO (plain-old-Java-object) classes. See Appendix A, Enterprise Application Deployment Descriptor Elements.
J MS a nd J DB C M o d ul e s
A Web service consists of the following modules: A Web Service implementation hosted by a server on the Web. WebLogic Web Services are hosted by WebLogic Server. A Web Service module may include either Java classes or EJBs that implement the Web Service. Web Services are packaged either as Web Application archives (WARs) or EJB modules (JARs) depending on the implementation. See Programming Web Services for WebLogic Server for more information. A standard for transmitting data and Web service invocation calls between the Web service and the user of the Web service. WebLogic Web Services use Simple Object Access Protocol (SOAP) 1.1 as the message format and HTTP as the connection protocol. A standard for describing the Web service to clients so they can invoke it. WebLogic Web Services use Web Services Description Language (WSDL) 1.1, an XML-based specification, to describe themselves. A standard for clients to invoke Web services (JAX-RPC). A standard for finding and registering the Web service (UDDI).
1-9
1-10
Modules and applications have deployment descriptorsXML documentsthat describe the contents of the directory or JAR file. Deployment descriptors are text documents formatted with XML tags. The Java EE specifications define standard, portable deployment descriptors for Java EE modules and applications. BEA defines additional WebLogic-specific deployment descriptors for deploying a module or application in the WebLogic Server environment. Table 1-1 lists the types of modules and applications and their Java EE-standard and WebLogic-specific deployment descriptors. Note: The XML Schemas for the WebLogic deployment descriptors listed in the following table include elements from the weblogic-javaee.xsd schema, which describes common elements shared among all WebLogic-specific deployment descriptors. Table 1-1 Java EE and WebLogic Deployment Descriptors Module or Application
Web Application
Scope
Java EE
Deployment Descriptors
web.xml
Schema: http://www.bea.com/ns/weblogic/920/weblogic-web-app.xsd See weblogic.xml Deployment Descriptor Elements in Developing Web Applications for WebLogic Server. Enterprise Bean 3.0 Java EE
ejb-jar.xml
Schema: http://www.bea.com/ns/weblogic/10.0/weblogic-ejb-jar.xsd
persistence-configuration.xml
1-11
Scope
J2EE
Deployment Descriptors
ejb-jar.xml
Schema: http://www.bea.com/ns/weblogic/920/weblogic-ejb-jar.xsd See The weblogic-ejb-jar.xml Deployment Descriptor in Programming WebLogic Enterprise JavaBeans.
weblogic-cmp-rdbms-jar.xml
Schema: http://www.bea.com/ns/weblogic/920/weblogic-rdbms20-persistence .xsd See The weblogic-cmp-rdbms-jar.xml Deployment Descriptor in Programming WebLogic Enterprise JavaBeans. Web Services Java EE
webservices.xml
Schema: http://www.bea.com/ns/weblogic/920/weblogic-wsee.xsd See WebLogic Web Service Deployment Descriptor Element Reference in WebLogic Web Services: Reference. Resource Adapter Java EE
ra.xml
1-12
Scope
Java EE
Deployment Descriptors
application.xml
Schema: http://www.bea.com/ns/weblogic/920/weblogic-application.xsd See weblogic-application.xml Deployment Descriptor Elements on page A-1. Client Application Java EE
application-client.xml
Schema: http://www.bea.com/ns/weblogic/10.0/weblogic-appclient.xsd See Developing a J2EE Application Client (Thin Client) in Programming Stand-alone Clients. JMS Module WebLogic
FileName-jms.xml, where FileName can be anything you want.
Schema: http://www.bea.com/ns/weblogic/920/weblogic-jmsmd.xsd See Configuring JMS Application Modules for Deployment in Configuring and Managing WebLogic JMS. JDBC Module WebLogic
FileName-jdbc.xml, where FileName can be anything you want.
Schema: http://www.bea.com/ns/weblogic/920/weblogic-jdbc.xsd See Configuring JDBC Application Modules for Deployment in Configuring and Managing WebLogic JDBC. WLDF Module WebLogic
weblogic-diagnostics.xml
Schema: http://www.bea.com/ns/weblogic/920/diagnostics.xsd See Deploying WLDF Application Modules in Configuring and Using the WebLogic Diagnostics Framework.
1-13
When you package a module or application, you create a directory to hold the deployment descriptorsWEB-INF or META-INFand then create the XML deployment descriptors in that directory.
EJBGen
EJBGen is an Enterprise JavaBeans 2.x code generator or command-line tool that uses Javadoc markup to generate EJB deployment descriptor files. You annotate your Bean class file with Javadoc tags and then use EJBGen to generate the Remote and Home classes and the deployment descriptor files for an EJB application, reducing to a single file you need to edit and maintain your EJB .java and descriptor files. See EJBGen Reference in Programming WebLogic Enterprise JavaBeans.
descriptors for Web applications. For an example of DDInit, assume that you have created a directory called c:\stage that contains the JSP files and other objects that make up a Web application but you have not yet created the web.xml and weblogic.xml deployment descriptors. To automatically generate them, execute the following command:
prompt> java weblogic.marathon.ddinit.WebInit c:\stage
The utility generates the web.xml and weblogic.xml deployment descriptors and places them in the WEB-INF directory, which DDInit will create if it does not already exist.
1-14 Developing Applications with WebLogic Server
Upgrading Deployment Descriptors From Previous Releases of J2EE and WebLogic Server
So that your applications can take advantage of the features in the current Java EE specification and release of WebLogic Server, BEA recommends that you always upgrade deployment descriptors when you migrate applications to a new release of WebLogic Server. To upgrade the deployment descriptors in your J2EE applications and modules, first use the weblogic.DDConverter tool to generate the upgraded descriptors into a temporary directory. Once you have inspected the upgraded deployment descriptors to ensure that they are correct, repackage your J2EE module archive or exploded directory with the new deployment descriptor files. Invoke weblogic.DDConverter with the following command:
prompt> java weblogic.DDConverter [options] archive_file_or_directory
where archive_file_or_directory refers to the archive file (EAR, WAR, JAR, or RAR) or exploded directory of your Enterprise application, Web application, EJB, or resource adapter. The following table describes the weblogic.DDConverter command options. Table 1-2 weblogic.DDConverter Command Options Option
-d <dir>
Description
Specifies the directory to which descriptors are written. Prints the standard usage message. Turns off output messages except error messages. Turns on additional output used for debugging.
-help -quiet
-verbose
The following example shows how to use the weblogic.DDConverter command to generate upgraded deployment descriptors for the my.ear Enterprise application into the subdirectory tempdir in the current directory:
prompt> java weblogic.DDConverter -d tempdir my.ear
1-15
Deployment Plans
A deployment plan is an XML document that defines an applications WebLogic Server deployment configuration for a specific WebLogic Server environment. A deployment plan resides outside of an applications archive file, and can apply changes to deployment properties stored in the applications existing WebLogic Server deployment descriptors. Administrators use deployment plans to easily change an applications WebLogic Server configuration for a specific environment without modifying existing Java EE or WebLogic-specific deployment descriptors. Multiple deployment plans can be used to reconfigure a single application for deployment to multiple, differing WebLogic Server environments. After programmers have finished programming an application, they export its deployment configuration to create a custom deployment plan that administrators later use for deploying the application into new WebLogic Server environments. Programmers distribute both the application deployment files and the custom deployment plan to deployers (for example, testing, staging, or production administrators) who use the deployment plan as a blueprint for configuring the application for their environment. BEA WebLogic Server provides the following tools to help programmers export an applications deployment configuration:
weblogic.PlanGenerator creates a template deployment plan with null variables for selected categories of WebLogic Server deployment descriptors. This tool is recommended if you are beginning the export process and you want to create a template deployment plan with null variables for an entire class of deployment descriptors.
The Administration Console updates or creates new deployment plans as necessary when you change configuration properties for an installed application. You can use the Administration Console to generate a new deployment plan or to add or override variables in an existing plan. The Administration Console provides greater flexibility than weblogic.PlanGenerator, because it allows you to interactively add or edit individual deployment descriptor properties in the plan, rather than export entire categories of descriptor properties. For complete and detailed information about creating and using deployment plans, see: Understanding WebLogic Server Deployment Exporting an Application for Deployment to New Environments Understanding WebLogic Server Deployment Plans
1-16
D e v e l o p m e nt S o f tw ar e
Development Software
This section reviews required and optional tools for developing WebLogic Server applications.
Apache Ant
The preferred BEA method for building applications with WebLogic Server is Apache Ant. Ant is a Java-based build tool. One of the benefits of Ant is that is it is extended with Java classes, rather than shell-based commands. BEA provides numerous Ant extension classes to help you compile, build, deploy, and package applications using the WebLogic Server split development directory environment. Another benefit is that Ant is a cross-platform tool. Developers write Ant build scripts in eXtensible Markup Language (XML). XML tags define the targets to build, dependencies among targets, and tasks to execute in order to build the targets. Ant libraries are bundled with WebLogic Server to make it easier for our customers to build Java applications out of the box. To use Ant, you must first set your environment by executing either the setExamplesEnv.cmd (Windows) or setExamplesEnv.sh (UNIX) commands located in the WL_SERVER\samples\domains\wl_server directory, where WL_SERVER is your WebLogic Server installation directory. For a complete explanation of ant capabilities, see:
http://jakarta.apache.org/ant/manual/index.html
Note: The Apache Jakarta Web site publishes online documentation for only the most current version of Ant, which might be different from the version of Ant that is bundled with WebLogic Server. Use the following command, after setting your WebLogic environment, to determine the version of Ant bundled with WebLogic Server:
prompt> ant -version
To view the documentation for a specific version of Ant, such as the version included with WebLogic Server, download the Ant zip file from http://archive.apache.org/dist/ant/binaries/ and extract the documentation. For more information on using Ant to compile your cross-platform scripts or using cross-platform scripts to create XML scripts that can be processed by Ant, refer to any of the WebLogic Server examples, such as
WL_HOME/samples/server/examples/src/examples/ejb20/basic/beanManaged/build .xml.
Also refer to the following WebLogic Server documentation on building examples using Ant:
WL_HOME/samples/server/examples/src/examples/examples.html.
1-17
If you plan to use a different version of Ant, you can replace the appropriate JAR file in the WL_HOME\server\lib\ant directory with an updated version of the file (where WL_HOME refers to the main WebLogic installation directory, such as c:\bea\wlserver_10.0) or add the new file to the front of your CLASSPATH.
If you want to set the heap size permanently, add or update the MEM_ARGS variable in the scripts that set your environment, start WebLogic Server, and so on, as shown in the following snippet from a Windows command script that starts a WebLogic Server instance:
set MEM_ARGS=-Xms32m -Xmx200m
See the scripts and commands in WL_HOME/server/bin for examples of using the MEM_ARGS variable.
D e v e l o p m e nt S o f tw ar e
Server, IBM DB2, or PointBase. Refer to Supported Configurations to find out about supported database systems and JDBC drivers.
Web Browser
Most Java EE applications are designed to be executed by Web browser clients. WebLogic Server supports the HTTP 1.1 specification and is tested with current versions of the Firefox and Microsoft Internet Explorer browsers. When you write requirements for your application, note which Web browser versions you will support. In your test plans, include testing plans for each supported version. Be explicit about version numbers and browser configurations. Will your application support Secure Socket Layers (SSL) protocol? Test alternative security settings in the browser so that you can tell your users what choices you support. If your application uses applets, it is especially important to test browser configurations you want to support because of differences in the JVMs embedded in various browsers. One solution is to require users to install the Java plug-in from Sun so that everyone has the same Java run-time version.
Third-Party Software
You can use third-party software products to enhance your WebLogic Server development environment. See BEA WebLogic Developer Tools Resources, which provides developer tools information for products that support the BEA application servers. To download some of these tools, see BEA WebLogic Server Downloads at
http://commerce.bea.com/downloads/weblogic_server_tools.jsp.
Note: Check with the software vendor to verify software compatibility with your platform and WebLogic Server version.
1-19
1-20
CHAPTER
The following sections describe how to start and stop WebLogic Server instances and configure WebLogic Server domains using WebLogic Ant tasks that you can include in your development build scripts: Overview of Configuring and Starting Domains Using Ant Tasks on page 2-1 Starting Servers and Creating Domains Using the wlserver Ant Task on page 2-2 Configuring a WebLogic Server Domain Using the wlconfig Ant Task on page 2-9 Using the libclasspath Ant Task on page 2-22
2-1
Configure the new domain with required application resources using the wlconfig Ant task. Deploy the application using the wldeploy Ant task. Automatically start a compiled client application to demonstrate or test product features. The sections that follow describe how to use the configuration Ant tasks, wlserver and wlconfig.
Starting Servers and Creating Domains Using the wlserver Ant Task
The wlserver Ant task enables you to start, reboot, shutdown, or connect to a WebLogic Server instance. The server instance may already exist in a configured WebLogic Server domain, or you can create a new single-server domain for development by using the generateconfig=true attribute. When you use the wlserver task in an Ant script, the task does not return control until the specified server is available and listening for connections. If you start up a server instance using wlserver, the server process automatically terminates after the Ant VM terminates. If you only connect to a currently-running server using the wlserver task, the server process keeps running after Ant completes. The wlserver WebLogic Server Ant task extends the standard java Ant task (org.apache.tools.ant.taskdefs.Java). This means that all the attributes of the java Ant task also apply to the wlserver Ant task. For example, you can use the output and error attributes to specify the name of the files to which output and standard errors of the wlserver Ant task is written, respectively. For full documentation about the attributes of the standard java Ant task, see Java on the Apache Ant site.
2-2
On UNIX, execute the setWLSEnv.sh command, located in the directory WL_HOME/server/bin, where WL_HOME is the top-level directory of your WebLogic Server installation. Note: The wlserver task is predefined in the version of Ant shipped with WebLogic Server. If you want to use the task with your own Ant installation, add the following task definition in your build file:
<taskdef name="wlserver" classname="weblogic.ant.taskdefs.management.WLServer"/>
2. Add a call to the wlserver task in the build script to start, shutdown, restart, or connect to a server. See wlserver Ant Task Reference on page 2-4 for information about wlserver attributes and default behavior. 3. Execute the Ant task or tasks specified in the build.xml file by typing ant in the staging directory, optionally passing the command a target argument:
prompt> ant
Use ant -verbose to obtain more detailed messages from the wlserver task.
This target connects to an existing, running server using the indicated connection parameters and username/password combination:
<target name="connect-server"> <wlserver host="127.0.0.1" port="7001" username="weblogic" password="weblogic" action="connect"/> </target>
This target starts a WebLogic Server instance configured in the config subdirectory:
<target name="start-server"> <wlserver dir="./config" host="127.0.0.1" port="7001" action="start"/> </target>
2-3
This target creates a new single-server domain in an empty directory, and starts the domains server instance:
<target name="new-server"> <delete dir="./tmp"/> <mkdir dir="./tmp"/> <wlserver dir="./tmp" host="127.0.0.1" port="7001" generateConfig="true" username="weblogic" password="weblogic" action="start"/> </target>
Description
The path to the security policy file for the WebLogic Server domain. This attribute is used only for starting server instances. The path that holds the domain configuration (for example, c:\bea\user_projects\mydomain). By default, wlserver uses the current directory. The path to the BEA home directory (for example, c:\bea). The path to the WebLogic Server installation directory (for example, c:\bea\wlserver_10.0).
Data Type
File
Required?
No
dir
File
No
beahome
File
No
weblogichome
File
No
2-4
Description
The name of the server to start, shutdown, reboot, or connect to. A WebLogic Server instance is uniquely identified by its protocol, host, and port values, so if you use this set of attributes to specify the server you want to start, shutdown or reboot, you do not need to specify its actual name using the servername attribute. The only exception is when you want to shutdown the Administration server; in this case you must specify this attribute. The default value for this attribute is myserver.
Data Type
String
Required?
Required only when shutting down the Administrati on server.
domainname
The name of the WebLogic Server domain in which the server is configured. The URL to access the Administration Server in the domain. This attribute is required if you are starting up a Managed Server in the domain.
String
No
adminserverurl
String
username
The username of an administrator account. If you omit both the username and password attributes, wlserver attempts to obtain the encrypted username and password values from the boot.properties file. See Boot Identity Files in the Managing Server Startup and Shutdown for more information on boot.properties. The password of an administrator account. If you omit both the username and password attributes, wlserver attempts to obtain the encrypted username and password values from the boot.properties file. See Boot Identity Files in the Managing Server Startup and Shutdown for more information on boot.properties. The private key password for decrypting the SSL private key file.
String
password
String
No
pkpassword
String
No
2-5
Description
The maximum time, in milliseconds, that wlserver waits for a server to boot. This also specifies the maximum amount of time to wait when connecting to a running server. The default value for this attribute is 0, which means the Ant task never times out.
Data Type
long
Required?
No
timeoutSeconds
The maximum time, in seconds, that wlserver waits for a server to boot. This also specifies the maximum amount of time to wait when connecting to a running server. The default value for this attribute is 0, which means the Ant task never times out.
long
No
productionmodeenable d
Specifies whether a server instance boots in development mode or in production mode. Development mode enables a WebLogic Server instance to automatically deploy and update applications that are in the domain_name/autodeploy directory (where domain_name is the name of a WebLogic Server domain). In other words, development mode lets you use auto-deploy. Production mode disables the auto-deployment feature. See Deploying Applications and Modules for more information. Valid values for this attribute are True and False. The default value is False (which means that by default a server instance boots in development mode.) Note: If you boot the server in production mode by setting this attribute to True, you must reboot the server to set the mode back to development mode. Or in other words, you cannot reset the mode on a running server using other administrative tools, such as the WebLogic Server Scripting Tool (WLST).
boolean
No
host
The DNS name or IP address on which the server instance is listening. The default value for this attribute is localhost.
String
No
2-6
Description
The TCP port number on which the server instance is listening. The default value for this attribute is 7001.
Data Type
int
Required?
No
generateconfig
Specifies whether or not wlserver creates a new domain for the specified server. Valid values for this attribute are true and false. The default value is false.
boolean
No
action
Specifies the action wlserver performs: start, shutdown, reboot, or connect. The shutdown action can be used with the optional forceshutdown attribute perform a forced shutdown. The default value for this attribute is start.
String
No
failonerror
This is a global attribute used by WebLogic Server Ant tasks. It specifies whether the task should fail if it encounters an error during the build. Valid values for this attribute are true and false. The default value is false.
Boolean
No
forceshutdown
This optional attribute is used in conjunction with the action="shutdown" attribute to perform a forced shutdown. For example:
<wlserver host="${wls.host}" port="${port}" username="${wls.username}" password="${wls.password}" action="shutdown" forceshutdown="true"/>
Boolean
No
Valid values for this attribute are true and false. The default value is false. protocol Specifies the protocol that the wlserver Ant task uses to communicate with the WebLogic Server instance. Valid values are t3, t3s, http, https, and iiop. The default value is t3. String No
2-7
Description
Specifies whether the wlserver Ant task, if run against an 8.1 (or previous) domain, should implicitly upgrade it to version 9.2. Valid values are true or false. The default value is false, which means that the Ant task does not implicitly upgrade the domain, but rather, will fail with an error indicating that the domain needs to be upgraded to version 9.2 of WebLogic Server. For more information about upgrading domains, see Upgrading WebLogic Application Environments.
Data Type
Boolean
Required?
No.
configFile
Specifies the configuration file for your domain. The value of this attribute must be a valid XML file that conforms to the XML schema as defined in the BEA WebLogic Server 9.2 Domain Configuration Schema Reference. The XML file must exist in the Administration Server's root directory, which is either the current directory or the directory that you specify with the dir attribute. If you do not specify this attribute, the default value is config.xml in the directory specified by the dir attribute. If you do not specify the dir attribute, then the default domain directory is the current directory.
String
No.
2-8
Description
Specifies whether to use the boot.properties file when starting a WebLogic Server instance. If this attribute is set to true, WebLogic Server uses the username and encrypted password stored in the boot.properties file to start rather than any values set with the username and password attributes. Note: The values of the username and password attributes are still used when shutting down or rebooting the WebLogic Server instance. The useBootProperties attribute applies only when starting the server.
Data Type
Boolean
Required?
No
Valid values for this attribute are true and false. The default value is false.
verbose Specifies that the Ant task output additional information as it is performing its action. Valid values for this attribute are true and false. The default value is false. Boolean No
2-9
Create MBeans and set their attributes in one step by nesting set attribute commands within create MBean commands. Query MBeans, optionally storing the query results in an Ant property reference. Query MBeans and set attribute values on all matching results. Establish a parent/child relationship among MBeans by nesting create commands within other create commands. WARNING: The wlconfig Ant task works only against MBeans that are in the compatibility MBean server, which has been deprecated as of version 9.0 of WebLogic Server. In particular, the wlconfig Ant task uses the deprecated BEA proprietary API weblogic.management.MBeanHome to access WebLogic MBeans, the same as it did in Version 8.1 of WebLogic Server. The Ant task does not use the standard JMX interface (javax.management.MBeanServerConnection) to discover MBeans. This means that the only MBeans that you can access using wlconfig are those listed under the Deprecated MBeans category in the WebLogic Server MBean Reference.
2. wlconfig is commonly used in combination with wlserver to configure a new WebLogic Server domain created in the context of an Ant task. If you will be using wlconfig to configure such a domain, first use wlserver attributes to create a new domain and start the WebLogic Server instance. 3. Add an initial call to the wlconfig task to connect to the Administration Server for a domain. For example:
<target name=doconfig> <wlconfig url="t3://localhost:7001" username="weblogic"
2-10
password="weblogic"> </target>
4. Add nested create, delete, get, set, and query elements to configure the domain. 5. Execute the Ant task or tasks specified in the build.xml file by typing ant in the staging directory, optionally passing the command a target argument:
prompt> ant doconfig
Use ant -verbose to obtain more detailed messages from the wlconfig task.
Complete Example
This example shows a single build.xml file that creates a new domain using wlserver and performs various domain configuration tasks with wlconfig. The configuration tasks set up domain resources required by the Avitek Medical Records sample application. The script starts by creating the new domain:
<target name="medrec.config"> <mkdir dir="config"/> <wlserver username="a" password="a" servername="MedRecServer" domainname="medrec" dir="config" host="localhost" port="7000" generateconfig="true"/>
The script then starts the wlconfig task by accessing the newly-created server:
<wlconfig url="t3://localhost:7000" username="a" password="a">
Within the wlconfig task, the query element runs a query to obtain the Server MBean object name, and stores this MBean in the ${medrecserver} Ant property:
<query domain="medrec" type="Server" name="MedRecServer" property="medrecserver"/>
The script the uses a create element to create a new JDBC connection pool in the domain, storing the object name in the ${medrecpool} Ant property. Nested set elements in the create operation set attributes on the newly-created MBean. The new pool is target to the server using the ${medrecserver} Ant property set in the query above:
2-11
<create type="JDBCConnectionPool" name="MedRecPool" property="medrecpool"> <set attribute="CapacityIncrement" value="1"/> <set attribute="DriverName" value="com.pointbase.jdbc.jdbcUniversalDriver"/> <set attribute="InitialCapacity" value="1"/> <set attribute="MaxCapacity" value="10"/> <set attribute="Password" value="MedRec"/> <set attribute="Properties" value="user=MedRec"/> <set attribute="RefreshMinutes" value="0"/> <set attribute="ShrinkPeriodMinutes" value="15"/> <set attribute="ShrinkingEnabled" value="true"/> <set attribute="TestConnectionsOnRelease" value="false"/> <set attribute="TestConnectionsOnReserve" value="false"/> <set attribute="URL" value="jdbc:pointbase:server://localhost/demo"/> <set attribute="Targets" value="${medrecserver}"/> </create>
Next, the script creates a JDBC TX DataSource using the JDBC connection pool created above:
<create type="JDBCTxDataSource" name="Medical Records Tx DataSource"> <set attribute="JNDIName" value="MedRecTxDataSource"/> <set attribute="PoolName" value="MedRecPool"/> <set attribute="Targets" value="${medrecserver}"/> </create>
The script creates a new JMS connection factory using nested set elements:
<create type="JMSConnectionFactory" name="Queue"> <set attribute="JNDIName" value="jms/QueueConnectionFactory"/> <set attribute="XAServerEnabled" value="true"/> <set attribute="Targets" value="${medrecserver}"/> </create>
2-12
When creating a new JMS server, the script uses a nested create element to create a JMS queue, which is the child of the JMS server:
<create type="JMSServer" name="MedRecJMSServer"> <set attribute="Store" value="${medrecjdbcstore}"/> <set attribute="Targets" value="${medrecserver}"/> <create type="JMSQueue" name="Registration Queue"> <set attribute="JNDIName" value="jms/REGISTRATION_MDB_QUEUE"/> </create> </create>
Finally, the script obtains the WebServer MBean and sets the log filename using a nested set element:
<query domain="medrec" type="WebServer" name="MedRecServer"> <set attribute="LogFileName" value="logs/access.log"/> </query> </wlconfig> </target>
2-13
2-14
Main Attributes
The following table describes the main attributes of the wlconfig Ant task. Table 2-2 Main Attributes of the wlconfig Ant Task Attribute
url username password
Description
The URL of the domains Administration Server. The username of an administrator account. The password of an administrator account. To avoid having the plain text password appear in the build file or in process utilities such as ps, first store a valid username and encrypted password in a configuration file using the WebLogic Scripting Tool (WLST) storeUserConfig command. Then omit both the username and password attributes in your Ant build file. When the attributes are omitted, wlconfig attempts to login using values obtained from the default configuration file. If you want to obtain a username and password from a non-default configuration file and key file, use the userconfigfile and userkeyfile attributes with wlconfig. See the command reference for storeUserConfig in the WLST Command and Variable Reference for more information on storing and encrypting passwords.
Data Type
String String String
Required?
Yes No No
failonerror
This is a global attribute used by WebLogic Server Ant tasks. It specifies whether the task should fail if it encounters an error during the build. This attribute is set to true by default.
Boolean
No
2-15
Description
Specifies the location of a user configuration file to use for obtaining the administrative username and password. Use this option, instead of the username and password attributes, in your build file when you do not want to have the plain text password shown in-line or in process-level utilities such as ps. Before specifying the userconfigfile attribute, you must first generate the file using the WebLogic Scripting Tool (WLST) storeUserConfig command as described in the WLST Command and Variable Reference.
Data Type
File
Required?
No
userkeyfile
Specifies the location of a user key file to use for encrypting and decrypting the username and password information stored in a user configuration file (the userconfigfile attribute). Before specifying the userkeyfile attribute, you must first generate the key file using the WebLogic Scripting Tool (WLST) storeUserConfig command as described in the WLST Command and Variable Reference.
File
No
Nested Elements
wlconfig also has several elements that can be nested to specify configuration options:
2-16
create
The create element creates a new MBean in the WebLogic Server domain. The wlconfig task can have any number of create elements. A create element can have any number of nested set elements, which set attributes on the newly-created MBean. A create element may also have additional, nested create elements that create child MBeans. The create element has the following attributes. Table 2-3 Attributes of the create Element Attribute
name
Description
The name of the new MBean object to create.
Data Type
String
Required?
No (wlconfig supplies a default name if none is specified.) Yes No
type property
The MBean type. The name of an optional Ant property that holds the object name of the newly-created MBean. Note: If you nest a create element inside of another create element, you cannot specify the property attribute for the nested create element.
String String
2-17
delete
The delete element removes an existing MBean from the WebLogic Server domain. delete takes a single attribute: Table 2-4 Attribute of the delete Element Attribute
mbean
Description
The object name of the MBean to delete.
Data Type
String
Required?
Required when the delete element is a direct child of the wlconfig task. Not required when nested within a query element.
set
The set element sets MBean attributes on a named MBean, a newly-created MBean, or on MBeans retrieved as part of a query. You can include the set element as a direct child of the wlconfig task, or nested within a create or query element. The set element has the following attributes: Table 2-5 Attributes of the set Element Attribute
attribute value
Description
The name of the MBean attribute to set. The value to set for the specified MBean attribute. You can specify multiple object names (stored in Ant properties) as a value by delimiting the entire value list with quotes and separating the object names with a semicolon. See Example of Setting Multiple Attribute Values on page 2-14.
Data Type
String String
Required?
Yes Yes
2-18
Description
The object name of the MBean whose values are being set. This attribute is required only when the set element is included as a direct child of the main wlconfig task; it is not required when the set element is nested within the context of a create or query element.
Data Type
String
Required?
Required only when the set element is a direct child of the wlconfig task. No
domain
This attribute specifies the JMX domain name for Security MBeans and third-party SPI MBeans. It is not required for administration MBeans, as the domain corresponds to the WebLogic Server domain. Note: You cannot use this attribute if the set element is nested inside of a create element.
String
get
The get element retrieves attribute values from an MBean in the WebLogic Server domain. The wlconfig task can have any number of get elements. The get element has the following attributes. Table 2-6 Attributes of the get Element Attribute
attribute
Description
The name of the MBean attribute whose value you want to retrieve.
Data Type
String
Required?
Yes
2-19
Description
The name of an Ant property that will hold the retrieved MBean attribute value. The object name of the MBean you want to retrieve attribute values from.
Data Type
String
Required?
Yes
mbean
String
Yes
query
The query elements finds MBean that match a search pattern. The query element supports the following nested child elements:
setperforms set operations on all MBeans in the result set. getperforms get operations on all MBeans in the result set. createeach MBean in the result set is used as a parent of a new MBean. deleteperforms delete operations on all MBeans in the result set. invokeinvokes all matching MBeans in the result set. wlconfig can have any number of nested query elements. query has the following attributes:
Description
The name of the WebLogic Server domain in which to search for MBeans. The type of MBean to query. The name of the MBean to query. A JMX query pattern.
Data Type
String
Required?
No
No No No
2-20
Description
The name of an optional Ant property that will store the query results. This attribute specifies the JMX domain name for Security MBeans and third-party SPI MBeans. It is not required for administration MBeans, as the domain corresponds to the WebLogic Server domain.
Data Type
String
Required?
No
domain
String
No
invoke
The invoke element invokes a management operation for one or more MBeans. For WebLogic Server MBeans, you usually use this command to invoke operations other than the getAttribute and setAttribute that most WebLogic Server MBeans provide. The invoke element has the following attributes. Table 2-8 Attributes of the invoke Element Attribute
mbean
Description
The object name of the MBean you want to invoke.
Data Type
String
Required?
You must specify either the mbean or type attribute of the invoke element. You must specify either the mbean or type attribute of the invoke element.
type
String
2-21
Description
The method of the MBean to invoke. The list of arguments (separated by spaces) to pass to the method specified by the methodName attribute.
Data Type
String String
Required?
Yes No
2-22
Description
The root of .ear or .war file to extract from. The name of the .war file to extract from.
Required
One of the two attributes is required. If basewar is specified, basedir is ignored and the library referenced in basewar is used as the .war file to extract classpath or resourcepath information from. Yes.
basewar
tmpdir
The fully qualified name of the directory to be used for extracting libraries. Contains the classpath for the referenced libraries. For example, if basedir points to a .war file that references web application libraries in the weblogic.xml file, the classpathproperty contains the WEB-INF/classes and WEB-INF/lib directories of the web application libraries. Additionally, if basedir points to a .war file that has .war files under WEB-INF/bea-ext, the classpathproperty contains the WEB-INF/classes and WEB-INF/lib directories for the BEA extensions.
classpathproperty
resourcepathprope rty
Contains library resources that are not classes. For example, if basedir points to a .war file that has .war files under WEB-INF/bea-ext, resourcepathproperty contains the roots of the exploded extensions.
2-23
one of the elements is required when using the libclasspath Ant task:
librarydir
The following attribute is required when using this element:
dirSpecifies that all files in this directory are registered as available libraries.
library
The following attribute is required when using this element:
fileRegister this file as an available library.
2-24
. . .
2-25
2-26
CHAPTER
The following sections describe the steps for creating a WebLogic Server split development directory that you can use to develop a Java EE application or module: Overview of the Split Development Directory Environment on page 3-1 Using the Split Development Directory Structure: Main Steps on page 3-5 Organizing Java EE Components in a Split Development Directory on page 3-6 Organizing Shared Classes in a Split Development Directory on page 3-11 Generating a Basic build.xml File Using weblogic.BuildXMLGen on page 3-13 Developing Multiple-EAR Projects Using the Split Development Directory on page 3-15 Best Practices for Developing WebLogic Server Applications on page 3-17
3-1
Fast development and deployment. By minimizing unnecessary file copying, the split development directory Ant tasks help you recompile and redeploy applications quickly without first generating a deployable archive file or exploded archive directory. Simplified build scripts. The BEA-provided Ant tasks automatically determine which Java EE modules and classes you are creating, and build components in the correct order to support common classpath dependencies. In many cases, your project build script can simply identify the source and build directories and allow Ant tasks to perform their default behaviors. Easy integration with source control systems. The split development directory provides a clean separation between source files and generated files. This helps you maintain only editable files in your source control system. You can also clean the build by deleting the entire build directory; build files are easily replaced by rebuilding the project.
3-2
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. Figure 3-1 Source and Build Directories
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 build and source directory contents can be place in any directory of your choice. However, for ease of use, the directories are commonly placed in directories named source and build, within a single project directory (for example, \myproject\build and \myproject\source).
3-3
WebLogic Server discovers the location of the source directory by examining the .beabuild.txt file that resides in the top level of the applications build directory. If you ever move or modify the source directory location, edit the .beabuild.txt file to identify the new source directory name. Deploying and Packaging from a Split Development Directory on page 5-1 describes the wldeploy Ant task that you can use to automate deployment from the split directory environment. Figure 3-2 shows a typical deployment process. The process is initiated by specifying the build directory with a WebLogic Server tool. In the figure, all compiled classes and generated deployment descriptors are discovered in the build directory, but other application resources (such as static files and editable deployment descriptors) are missing. WebLogic Server uses the hidden .beabuild.txt file to locate the applications source directory, where it finds the required resources. Figure 3-2 Split Directory Deployment
3-4
Us ing the Split Dev elo pment Dire ctory Stru cture: Main Steps
annotated .ejb files into deployment descriptors, as described in Compiling Applications Using wlcompile on page 4-1.
wlappcThis Ant task invokes the appc compiler, which generates JSPs and container-specific EJB classes for deployment. See Building Modules and Applications Using wlappc on page 4-4. wldeployThis Ant task deploys any format of Java EE applications (exploded or
archived) to WebLogic Server. To deploy directly from the split development directory environment, you specify the build directory of your application. See wldeploy Ant Task Reference on page B-1.
wlpackageThis Ant task uses the contents of both the source and build directories to generate an EAR file or exploded EAR directory that you can give to others for deployment.
3-5
5. Use the weblogic.BuildXMLGen utility to generate a default build.xml file for use with your project. Edit the default property values as needed for your environment. See Generating a Basic build.xml File Using weblogic.BuildXMLGen on page 3-13. 6. Use the default targets in the build.xml file to build, deploy, and package your application. See Generating a Basic build.xml File Using weblogic.BuildXMLGen on page 3-13 for a list of default targets.
3-7
The Enterprise Application directory will also have one or more subdirectories to hold a Web Application, EJB, utility class, and/or third-party Jar file, as described in the following sections.
Web Applications
Web Applications use the basic source directory layout shown in the figure below.
3-8
The key directories and files for the Web Application are:
helloWebApp\ The top level of the Web Application module can contain JSP files and static content such as HTML files and graphics used in the application. You can also store static files in any named subdirectory of the Web Application (for example, helloWebApp\graphics or helloWebApp\static.) helloWebApp\WEB-INF\ Store the Web Applications editable deployment descriptor files (web.xml and weblogic.xml) in the WEB-INF subdirectory. helloWebApp\WEB-INF\src Store Java source files for Servlets in package subdirectories under WEB-INF\src.
When you build a Web Application, the appc Ant task and jspc compiler compile JSPs into package subdirectories under helloWebApp\WEB-INF\classes\jsp_servlet in the build directory. Editable deployment descriptors are not copied during the build process.
Developing Applications with WebLogic Server 3-9
EJBs
EJBs use the source directory layout shown in the figure below. Figure 3-6 EJB Source and Build Directories
During the build process, EJB classes are compiled into package subdirectories of the helloEJB module in the build directory. If you use annotated .ejb source files, the build process also generates the EJB deployment descriptors and stores them in the helloEJB\META-INF subdirectory of the build directory.
3-10
3-11
Place the source for Java utility classes in a named subdirectory of the top-level Enterprise Application directory. Beneath the named subdirectory, use standard package subdirectory conventions. During the build process, the wlcompile Ant task invokes the javac compiler and compiles Java classes into the APP-INF/classes/ directory under the build directory. This ensures that the classes are available to other modules in the deployed application.
Third-Party Libraries
You can extend an Enterprise Application to use third-party .jar files by placing the files in the APP-INF\lib\ directory, as shown below: Figure 3-8 Third-party Library Directory
Third-party JARs are generally not compiled, but may be versioned using the source control system for your application code. For example, XML parsers, logging implementations, and Web Application framework JAR files are commonly used in applications and maintained along with editable source code.
3-12 Developing Applications with WebLogic Server
Gene ra ti ng a Basi c b uil d.xml Fil e Usi ng web log ic. Buil dX MLGe n
During the build process, third-party JAR files are not copied to the build directory, but remain in the source directory for deployment.
where options include: -helpprint standard usage message -versionprint version information -projectName <project name>name of the Ant project -d <directory>directory where build.xml is created. The default is the current directory. -file <build.xml>name of the generated build file
-librarydir <directories>create build targets for shared Java EE libraries in the comma-separated list of directories. See Creating Shared Java EE Libraries and Optional Packages on page 9-1.
After running weblogic.BuildXMLGen, edit the generated build.xml file to specify properties for your development environment. The list of properties you need to edit are shown in the listing below. Listing 3-1 build.xml Editable Properties
<!-- BUILD PROPERTIES ADJUST THESE FOR YOUR ENVIRONMENT --> <property name="tmp.dir" value="/tmp" /> <property name="dist.dir" value="${tmp.dir}/dist"/> <property name="app.name" value="helloWorldEar" /> <property name="ear" value="${dist.dir}/${app.name}.ear"/> <property name="ear.exploded" value="${dist.dir}/${app.name}_exploded"/> <property name="verbose" value="true" /> <property name="user" value="USERNAME" /> <property name="password" value="PASSWORD" /> <property name="servername" value="myserver" /> <property name="adminurl" value="iiop://localhost:7001" />
In particular, make sure you edit the tmp.dir property to point to the build directory you want to use. By default, the build.xml file builds projects into a subdirectory tmp.dir named after the application (/tmp/helloWorldEar in the above listing). The following listing shows the default main targets created in the build.xml file. You can view these targets at the command prompt by entering the ant -projecthelp command in the EAR source directory. Listing 3-2 Default build.xml Targets
appc Runs weblogic.appc on your application build Compiles helloWorldEar application and runs appc clean Deletes the build and distribution directories compile Only compiles helloWorldEar application, no appc compile.appStartup Compiles just the appStartup module of the application compile.appUtils Compiles just the appUtils module of the application compile.build.orig Compiles just the build.orig module of the application compile.helloEJB Compiles just the helloEJB module of the application compile.helloWebApp Compiles just the helloWebApp module of the application compile.javadoc Compiles just the javadoc module of the application deploy Deploys (and redeploys) the entire helloWorldEar application descriptors Generates application and module descriptors
3-14
Dev eloping Multi ple -EAR Proje cts Usi ng the Split Deve lopment Direc to ry
Package a standard J2EE EAR for distribution Package a standard exploded J2EE EAR Redeploys just the appStartup module of the application Redeploys just the appUtils module of the application Redeploys just the build.orig module of the application Redeploys just the helloEJB module of the application Redeploys just the helloWebApp module of application Redeploys just the javadoc module of the application Undeploys the entire helloWorldEar application
3-15
MedRec takes a similar approach to utility classes that are shared by multiple EARs in the project. Instead of including the source for utility classes within the scope of each ear that needs them, MedRec keeps the utility class source independent of all EARs. After compiling the utility classes, the build script archives them and copies the JARs into the build directory under the APP-INF/LIB subdirectory of each EAR that uses the classes, as shown in figure Figure 3-9.
The above task instructs Ant to execute the file named build.xml in the /startupEar subdirectory. The inheritAll parameter instructs Ant to pass only user properties from the master build file tot the build.xml file in /startupEar. MedRec uses multiple tasks similar to the above to build the startupEar, medrecEar, and physicianEar applications, as well as building common utility classes and client applications.
3-16
3-17
3-18
CHAPTER
The following sections describe the steps for building WebLogic Server Java EE applications using the WebLogic split development directory environment: Compiling Applications Using wlcompile on page 4-1 Building Modules and Applications Using wlappc on page 4-4
The following is the order in which events occur using this task: 1. wlcompile compiles the Java components into an output directory: WL_HOME\samples\server\examples\build\helloWorldEar\APP-INF\classes\ where WL_HOME is the WebLogic Server installation directory. 2. wlcompile builds the EJBs and automatically includes the previously built Java modules in the compiler's classpath. This allows the EJBs to call the Java modules without requiring you to manually edit their classpath.
4-1
3. Finally, wlcompile compiles the Java components in the Web application with the EJB and Java modules in the compiler's classpath. This allows the Web applications to refer to the EJB and application Java classes without requiring you to manually edit the classpath.
Description
The source directory. The build/output directory. Allows you to change the classpath used by wlcompile. Allows you to include specific directories from the build. Allows you to exclude specific directories from the build. Specifies a directory of shared Java EE libraries to add to the classpath. See Creating Shared Java EE Libraries and Optional Packages on page 9-1.
4-2
C o m pi l i ng A pp l i c a t i o n s U s i ng wlc o m pi l e
4-3
The name and version information are specified as attributes to the library element, described in Table 4-2. Table 4-2 Library attributes Attribute
file name specificationversion implementationversion
Description
Required filename of a Java EE library The optional name of a required Java EE library. An optional specification version required for the library. An optional implementation version required for the library.
The format choices for both specificationversion and implementationversion are described in Referencing Shared Java EE Libraries in an Enterprise Application on page 9-11. The following output shows a sample library reference:
<library file=c:\mylibs\lib.jar name=ReqLib specificationversion=90Beta implementationversion=1.1 />
Both weblogic.appc and the wlappc Ant task compile modules in the order in which they appear in the application.xml deployment descriptor file that describes your Enterprise application.
4-4
B u i l d i n g M o d ul e s a nd A pp l i c a ti o n s U s i n g wla pp c
Notes: See weblogic.appc Reference on page 4-7 for a list of weblogic.appc options. See also Library Element for wlcompile and wlappc on page 4-3.
Description
Prints the standard usage message. Prints appc version information. Specifies an alternate output archive or directory. If not set, the output is placed in the source archive or directory. Forces generation of EJB and JSP classes. Without this flag, the classes may not be regenerated (if determined to be unnecessary). Adds line numbers to generated class files to aid in debugging. Specfies that the application or module contains deployment descriptors with annotation information. Does not include deployment descriptors in client JARs generated for EJBs. Generates IDL for EJB remote interfaces. Always overwrites existing IDL files. Displays verbose information for IDL generation. Does not generate valuetypes and the methods/attributes that contain them. Does not generate abstract interfaces and methods/attributes that contain them. Generates factory methods for valuetypes. Generates IDL somewhat compatible with Visibroker 4.5 C++. Generates IDL somewhat compatible with Orbix 2000 2.0 C++.
forceGeneration
basicClientJar
idlNoAbstractInterfaces
4-5
idlMethodSignatures <>
keepgenerated librarydir
compiler <javac>
debug optimize
advanced
4-6
B u i l d i n g M o d ul e s a nd A pp l i c a ti o n s U s i n g wla pp c
The following is an example of a wlappc Ant task command that invokes two options (idl and idlOrverWrite) from Table 4-3.
<wlappc source="${dest.dir}"idl="true" idlOrverWrite="true" />
weblogic.appc Reference
The following sections describe how to use the command-line version of the appc compiler. The weblogic.appc command-line compiler reports any warnings or errors encountered in the descriptors and compiles all of the relevant modules into an EAR file, which can be deployed to WebLogic Server.
weblogic.appc Syntax
Use the following syntax to run appc:
prompt>java weblogic.appc [options] <ear, jar, or war file or directory>
4-7
weblogic.appc Options
The following are the available appc options: Table 4-4 appc Options Option
-print -version -output <file>
Description
Prints the standard usage message. Prints appc version information. Specifies an alternate output archive or directory. If not set, the output is placed in the source archive or directory. Forces generation of EJB and JSP classes. Without this flag, the classes may not be regenerated (if determined to be unnecessary). A comma-separated list of shared Java EE libraries. Optional name and version string information must be specified in the format described in Referencing Shared Java EE Libraries in an Enterprise Application on page 9-11.
-forceGeneration
Specfies that the application or module contains deployment descriptors with annotation information. Adds line numbers to generated class files to aid in debugging. Does not include deployment descriptors in client JARs generated for EJBs. Generates IDL for EJB remote interfaces. Always overwrites existing IDL files. Displays verbose information for IDL generation. Does not generate valuetypes and the methods/attributes that contain them. Does not generate abstract interfaces and methods/attributes that contain them. Generates factory methods for valuetypes. Generates IDL somewhat compatible with Visibroker 4.5 C++.
-basicClientJar
-idlNoAbstractInterfaces
-idlFactories -idlVisibroker
4-8
B u i l d i n g M o d ul e s a nd A pp l i c a ti o n s U s i n g wla pp c
-idlDirectory <dir>
-idlMethodSignatures <>
-keepgenerated -compiler <javac> -g -O -nowarn -verbose -deprecation -normi -J<option> -classpath <path> -clientJarOutputDir <dir>
-advanced
4-9
4-10
CHAPTER
The following sections describe the steps for deploying WebLogic Server Java EE applications using the WebLogic split development directory environment: Deploying Applications Using wldeploy on page 5-1 Packaging Applications Using wlpackage on page 5-1
The above task is automatically created when you use weblogic.BuildXMLGen to create the build.xml file. See wldeploy Ant Task Reference on page B-1 for a complete command reference.
5-1
Application (exploded .EAR directory). Use wlpackage when you want to deliver your application to another group or individual for evaluation, testing, performance profiling, or production deployment.
5-2
Description
Name of the EAR archive file into which the wlpackage Ant task packages the split development directory application.
Data Type
String
Required?
You must specify one of the following two attributes: tofile or todir. You must specify one of the following two attributes: tofile or todir. Yes.
todir
Name of an exploded directory into which the wlpackage Ant task packages the split devleopment directory application.
String
srcdir
Specifies the source directory of your split development directory application. The source directory contains all editable files for your projectJava source files, editable descriptor files, JSPs, static content, and so forth.
String
destdir
Specifies the build directory of your split development directory application. It is assumed that you have already executed the wlcompile Ant task against the source directory to generate the needed components into the build directory; these components include compiled Java classes and generated deployment descriptors.
String
Yes.
5-3
5-4
CHAPTER
The following sections describes how to program and maintain applications use the production redeployment strategy: What is Production Redeployment? on page 6-1 Supported and Unsupported Application Types on page 6-2 Programming Requirements and Conventions on page 6-2 Assigning an Application Version on page 6-5 Upgrading Applications to Use Production Redeployment on page 6-6 Accessing Version Information on page 6-6
6-1
multiple instances of the application can co-exist in a WebLogic Server domain. The following sections describe each programming convention required for using production redeployment.
WARNING: Set weblogic.jndi.WLContext.RELAX_VERSION_LOOKUP to true only if you are certain that the newer and older version of the resource that you are looking up are compatible with one another.
6-4
applications with strict version requirements, BEA recommends packaging all of the applications together to ensure version consistency during production redeployment.
For example, the following manifest file content describes an application with version v920.beta:
Manifest-Version: 1.0 Created-By: 1.4.1_05-b01 (Sun Microsystems Inc.) Weblogic-Application-Version: v920.beta
6-5
Description
A String that represents the deployment name of the application A String that uniquely identifies the current application version across all versions of the same application A String that uniquely identifies the current application version across all deployed applications and versions
VersionIdentifier
ApplicationIdentifier
6-6
Description
A String that represents the deployment name of the application A string that represents the version of the application. An integer that indicates the current state of the active application version. Valid states for an active version are: ACTIVATEDindicates that one or more modules of the application are active and available for processing new client requests. PREPAREDindicates that WebLogic Server has prepared one or more modules of the application, but that it is not yet active. UNPREPAREDindicates that no modules of the application are prepared or active.
ApplicationVersion
ActiveVersionState
See the WebLogic Server 9.2 API Reference for more information. Note that the currently active version does not always correspond to the last-deployed version, because the Administrator can reverse the production redeployment process. See Rolling Back the Production Redeployment Process in Deploying Applications to WebLogic Server.
6-7
6-8
CHAPTER
The following sections describe the concepts of MetaData annotation and dependency injection: Annotation Processing on page 7-1 Dependency Injection of Resources on page 7-3 Standard JDK Annotations on page 7-4 Standard Security-Related JDK Annotations on page 7-9
Annotation Processing
With Java EE annotations, the standard application.xml and web.xml deployment descriptors are optional. The Java EE programming model uses the JDK 5.0 annotations feature for Web containers, such as EJBs, servlets, Web applications, and JSPs. Annotations simplify the application development process by allowing developers to specify within the Java class itself how the application component behaves in the container, requests for dependency injection, and so on. Annotations are an alternative to deployment descriptors that were required by older versions of Enterprise applications (J2EE 1.4 and earlier).
Annotation Parsing
The application components can use annotations to define their needs. Annotations reduce or eliminate the need to deal with deployment descriptors. Annotations simplify the development of application components. The deployment descriptor can still override values defined in the annotation. One usage of annotations is to define fields or methods that need Dependency
Developing Applications with WebLogic Server 7-1
Injection (DI). Annotations are defined on the POJO (plain old Java object) component classes like the EJB or the servlet. An annotation on a field or a method can declare that fields/methods need injection, as described in Dependency Injection of Resources on page 7-3. Annotations may also be applied to the class itself. The class-level annotations declare an entry in the application components environment but do not cause the resource to be injected. Instead, the application component is expected to use JNDI or component context lookup method to lookup the entry. When the annotation is applied to the class, the JNDI name and the environment entry type must be specified explicitly.
7-2
For more information on using appc, see weblogic.appc Reference on page 4-7. For more information on using appmerge, see Using weblogic.appmerge to Merge Libraries on page 9-18.
7-3
// The minimum number of tax exemptions, configured by the Deployer. @Resource int minExemptions; .. }
In the above code the @Resource annotation has not specified a name; therefore, the container would look for an env-entry name called <class-name>/maxExemptions and inject the value of that entry into the maxExemptions variable. The field or method may have any access qualifier (public, private, etc.). For all classes except application client main classes, the fields or methods must not be static. Because application clients use the same life cycle as J2EE applications, no instance of the application client main class is created by the application client container. Instead, the static main method is invoked. To support injection for the application client main class, the fields or methods annotated for injection must be static.
7-4
S ta nd ar d J DK A nn o t at i o n s
javax.annotation.PreDestroy on page 7-6 javax.annotation.Resource on page 7-7 javax.annotation.Resources on page 7-8 For detailed information about EJB-specific annotations for WebLogic Server Enterprise JavaBeans, see Programming WebLogic Enterprise JavaBeans, Version 3.0. For detailed information about web component-specific annotations WebLogic Server applications, see WebLogic Annotation for Web Components in Developing Web Applications, Servlets, and JSPs for WebLogic Server.
javax.annotation.PostConstruct
Description
Target: Method Specifies the life-cycle callback method that the application component should execute before the first business method invocation and after dependency injection is done to perform any initialization. This method will be called after all injections have occurred and before the class is put into service. This method will be called even if the class doesn't request any resources to be injected. You must specify a @PostConstruct method in any component that includes dependency injection. Only one method in the component can be annotated with this annotation. The method annotated with @PostConstruct must follow these requirements: The method must not have any parameters, except in the case of EJB interceptors, in which case it takes an javax.interceptor.InvocationContext object as defined by the EJB specification. The return type of the method must be void. The method must not throw a checked exception. The method may be public, protected, package private or private. The method must not be static except for the application client. The method may be final or non-final, except in the case of EJBs where it must be non-final.
Developing Applications with WebLogic Server 7-5
If the method throws an unchecked exception the class must not be put into service. In the case of EJBs, the method annotated with PostConstruct can handle exceptions and cleanup before the bean instance is discarded. This annotation does not have any attributes.
javax.annotation.PreDestroy
Description
Target: Method Specifies the life-cycle callback method that signals that the application component is about to be destroyed by the container. You typically apply this annotation to methods that release resources that the class has been holding. Only one method in the bean class can be annotated with this annotation. The method annotated with @PreDestroy must follow these requirements: The method must not have any parameters, except in the case of EJB interceptors, in which case it takes an javax.interceptor.InvocationContext object as defined by the EJB specification. The return type of the method must be void. The method must not throw a checked exception. The method may be public, protected, package private or private. The method must not be static except for the application client. The method may be final or non-final, except in the case of EJBs where it must be non-final. If the method throws an unchecked exception the class must not be put into service. In the case of EJBs, the method annotated with PreDestroy can handle exceptions and cleanup before the bean instance is discarded. This annotation does not have any attributes.
7-6
S ta nd ar d J DK A nn o t at i o n s
javax.annotation.Resource
Description
Target: Class, Method, Field Specifies a dependence on an external resource, such as a JDBC data source or a JMS destination or connection factory. If you specify the annotation on a field or method, the application component injects an instance of the requested resource into the bean when the bean is initialized. If you apply the annotation to a class, the annotation declares a resource that the component will look up at runtime.
Attributes
Table 0-1 Attributes of the javax.annotation.Resource Annotation Name
name
Description
Specifies the JNDI name of the resource. If you apply the @Resource annotation to a field, the default value of the name attribute is the field name, qualified by the class name. If you apply it to a method, the default value is the component property name corresponding to the method, qualified by the class name. If you apply the annotation to class, there is no default value and thus you are required to specify the attribute.
Data Type
String
Required?
No
type
Specifies the Java data type of the resource. If you apply the @Resource annotation to a field, the default value of the type attribute is the type of the field. If you apply it to a method, the default is the type of the component property. If you apply it to a class, there is no default value and thus you are required to specify this attribute.
Class
No
authentication Type
Specifies the authentication type to use for the resource. Valid values for this attribute are: AuthenticationType.CONTAINER
AuthenticationType.APPLICATION
Authentica tionType
No
7-7
Description
Indicates whether a resource can be shared between this component and other components. Valid values for this attribute are true and false. Default value is true.
Data Type
boolean
Required?
No
mappedName
Specifies a WebLogic Server-specific name to which the component reference should be mapped. However, if you do not specify a JNDI name in the WebLogic deployment descriptor file, then the value of mappedName will always be used as the JNDI name to look up. For example:
@Resource(mappedName = "http://www.bea.com";) URL url; @Resource(mappedName="customerDB") DataSource db; @Resource(mappedName = "jms/ConnectionFactory") ConnectionFactory connectionFactory; @Resource(mappedName = "jms/Queue") Queue queue;
String
No
In other words, MappedName is honored as JNDI name only when there is no JNDI name specified elsewhere, typically in the WebLogic deployment descriptor file. description Specifies a description of the resource. String No
javax.annotation.Resources
Description
Target: Class Specifies an array of @Resource annotations. Since repeated annotations are not allowed, the Resources annotation acts as a container for multiple resource declarations.
7-8
St an da r d S e c u r i ty - R e l at e d J DK A nn o t at i o n s
Attributes
Table 0-2 Attributes of the javax.annotation.Resources Annotation Name
value
Description
Specifies the array of @Resource annotations.
Data Type
Resourc e[]
Required?
Yes
javax.annotation.security.DeclareRoles
Description
Target: Class Defines the security roles that will be used in the Java EE container. You typically use this annotation to define roles that can be tested from within the methods of the annotated class, such as using the isUserInRole method. You can also use the annotation to explicitly declare roles that are implicitly declared if you use the @RolesAllowed annotation on the class or a method of the class. You create security roles in WebLogic Server using the Administration Console. For details, see Manage Security Roles.
7-9
Attributes
Table 0-3 Attributes of the javax.annotation.security.DeclareRoles Annotation Name
value
Description
Specifies an array of security roles that will be used in the Java EE container.
Data Type
String[]
Required?
Yes
javax.annotation.security.DenyAll
Description
Target: Method Specifies that no security role is allowed to access the annotated method, or in other words, the method is excluded from execution in the Java EE container. This annotation does not have any attributes.
javax.annotation.security.PermitAll
Description
Target: Method Specifies that all security roles currently defined for WebLogic Server are allowed to access the annotated method. This annotation does not have any attributes.
javax.annotation.security.RolesAllowed
Description
Target: Class, Method Specifies the list of security roles that are allowed to access methods in the Java EE container. If you specify it at the class-level, then it applies to all methods in the application component. If you specify it at the method-level, then it only applies to that method. If you specify the annotation at both the class- and method-level, the method value overrides the class value.
7-10 Developing Applications with WebLogic Server
St an da r d S e c u r i ty - R e l at e d J DK A nn o t at i o n s
You create security roles in WebLogic Server using the Administration Console. For details, see Manage Security Roles.
Attributes
Table 0-4 Attributes of the javax.annotation.security.RolesAllowed Annotation Name
value
Description
List of security roles that are allowed to access methods of the Java EE container.
Data Type
String[]
Required?
Yes
javax.annotation.security.RunAs
Description
Target: Class Specifies the security role which actually executes the Java EE container. The security role must exist in the WebLogic Server security realm and map to a user or group. For details, see Manage Security Roles.
Attributes
Table 0-5 Attributes of the javax.annotation.security.RunAs Annotation Name
value
Description
Specifies the security role that the Java EE container should run as.
Data Type
String
Required?
Yes
7-11
7-12
CHAPTER
The following sections provide an overview of Java classloaders, followed by details about WebLogic Server Java EE application classloading. Java Classloading on page 8-1 WebLogic Server Application Classloading on page 8-4 Resolving Class References Between Modules and Applications on page 8-17 Sharing Applications and Modules By Using Java EE Libraries on page 8-19 Adding JARs to the System Classpath on page 8-19
Java Classloading
Classloaders are a fundamental module of the Java language. A classloader is a part of the Java virtual machine (JVM) that loads classes into memory; a classloader is responsible for finding and loading class files at run time. Every successful Java programmer needs to understand classloaders and their behavior. This section provides an overview of Java classloaders.
8-1
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
(JDK) internal classes and java.* packages included in the JVM. (For example, the bootstrap classloader loads java.lang.String.) The extensions classloader is a child of the bootstrap classloader. The extensions classloader loads any JAR files placed in the extensions directory of the JDK. This is a convenient means to extending the JDK without adding entries to the classpath. However, anything in the extensions directory must be self-contained and can only refer to classes in the extensions directory or JDK classes. The system classpath classloader extends the JDK extensions classloader. The system classpath classloader loads the classes from the classpath of the JVM. Application-specific classloaders (including WebLogic Server classloaders) are children of the system classpath classloader. Note: What BEA refers to as a system classpath classloader is often referred to as the application classloader in contexts outside of WebLogic Server. When discussing classloaders in WebLogic Server, BEA uses the term system to differentiate from classloaders related to Java EE applications or libraries (which BEA refers to as application classloaders).
Loading a Class
Classloaders use a delegation model when loading a class. The classloader implementation first checks its cache to see if the requested class has already been loaded. This class verification improves performance in that its cached memory copy is used instead of repeated loading of a class from disk. If the class is not found in its cache, the current classloader asks its parent for the class. Only if the parent cannot load the class does the classloader attempt to load the class. If a class exists in both the parent and child classloaders, the parent version is loaded. This delegation model is followed to avoid multiple copies of the same form being loaded. Multiple copies of the same class can lead to a ClassCastException. Classloaders ask their parent classloader to load a class before attempting to load the class themselves. Classloaders in WebLogic Server that are associated with Web applications can be configured to check locally first before asking their parent for the class. This allows Web applications to use their own versions of third-party classes, which might also be used as part of the WebLogic Server product. The prefer-web-inf-classes Element on page 8-2 section discusses this in more detail.
prefer-web-inf-classes Element
The weblogic.xml Web application deployment descriptor contains a <prefer-web-inf-classes> element (a sub-element of the <container-descriptor>
8-2 Developing Applications with WebLogic Server
element). By default, this element is set to False. Setting this element to True subverts the classloader delegation model so that class definitions from the Web application are loaded in preference to class definitions in higher-level classloaders. This allows a Web application to use its own version of a third-party class, which might also be part of WebLogic Server. See weblogic.xml Deployment Descriptor Elements. When using this feature, you must be careful not to mix instances created from the Web applications class definition with issuances created from the servers definition. If such instances are mixed, a ClassCastException results. Listing 8-1 illustrates the prefer-web-inf-classes element, its description and default value. Listing 8-1 prefer-web-inf-classes Element
/** * If true, classes located in the WEB-INF directory of a web-app will be * loaded in preference to classes loaded in the application or system * classloader. * @default false */ boolean isPreferWebInfClasses(); void setPreferWebInfClasses(boolean b);
8-3
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
In WebLogic Server, each application has a hierarchy of classloaders that are offspring of the system classloader. These hierarchies allow applications or parts of applications to be individually reloaded without affecting the rest of the system. WebLogic Server Application Classloading on page 8-4 discusses this topic.
Application code only has visibility to classes loaded by the classloader associated with the application (or module) and classes that are loaded by classloaders that are ancestors of the application (or module) classloader. This allows WebLogic Server to host multiple isolated applications within the same JVM.
WebApp 1
WebApp 2
WebApp 3
8-5
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
If your application includes servlets and JSPs that use EJBs: Package the servlets and JSPs in a WAR file Package the Enterprise JavaBeans in an EJB JAR file Package the WAR and JAR files in an EAR file Deploy the EAR file Although you could deploy the WAR and JAR files separately, deploying them together in an EAR file produces a classloader arrangement that allows the servlets and JSPs to find the EJB classes. If you deploy the WAR and JAR files separately, WebLogic Server creates sibling classloaders for them. This means that you must include the EJB home and remote interfaces in the WAR file, and WebLogic Server must use the RMI stub and skeleton classes for EJB calls, just as it does when EJB clients and implementation classes are in different JVMs. This concept is discussed in more detail in the next section Application Classloading and Pass-by-Value or Reference on page 8-14. Note: The Web application classloader contains all classes for the Web application except for the JSP class. The JSP class obtains its own classloader, which is a child of the Web application classloader. This allows JSPs to be individually reloaded.
8-6
This hierarchy is optimal for most applications, because it allows call-by-reference semantics when you invoke EJBs. It also allows Web modules to be independently reloaded without affecting other modules. Further, it allows code running in one of the Web modules to load classes from any of the EJB modules. This is convenient, as it can prevent a Web module from including the interfaces for EJBs that is uses. Note that some of those benefits are not strictly Java EE-compliant. The ability to create custom module classloaders provides a mechanism to declare alternate classloader organizations that allow the following: Reloading individual EJB modules independently Reloading groups of modules to be reloaded together Reversing the parent child relationship between specific Web modules and EJB modules Namespace separation between EJB modules
8-7
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
The top-level element in weblogic-application.xml includes an optional classloader-structure element. If you do not specify this element, then the standard classloader is used. Also, if you do not include a particular module in the definition, it is assigned a classloader, as in the standard hierarchy. That is, EJB modules are associated with the application Root classloader, and Web application modules have their own classloaders. The classloader-structure element allows for the nesting of classloader-structure stanzas, so that you can describe an arbitrary hierarchy of classloaders. There is currently a limitation of three levels. The outermost entry indicates the application classloader. For any modules not listed, the standard hierarchy is assumed. Note: JSP classloaders are not included in this definition scheme. JSPs are always loaded into a classloader that is a child of the classloader associated with the Web module to which it belongs. For more information on the DTD elements, refer to Appendix A, Enterprise Application Deployment Descriptor Elements. The following is an example of a classloader declaration (defined in the classloader-structure element in weblogic-application.xml): Listing 8-3 Example Classloader Declaration
<classloader-structure> <module-ref> <module-uri>ejb1.jar</module-uri> </module-ref> <module-ref> <module-uri>web3.war</module-uri>
8-8
</module-ref>
<classloader-structure> <module-ref> <module-uri>ejb3.jar</module-uri> </module-ref> <module-ref> <module-uri>web2.war</module-uri> </module-ref> <classloader-structure> <module-ref> <module-uri>web4.war</module-uri> </module-ref> </classloader-structure> <classloader-structure> <module-ref> <module-uri>ejb2.jar</module-uri> </module-ref> </classloader-structure> </classloader-structure> </classloader-structure>
8-9
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
The organization of the nesting indicates the classloader hierarchy. The above stanza leads to a hierarchy shown in the following diagram. Figure 8-3 Example Classloader Hierarchy
8-10
that if you use a custom hierarchy, you might end up with stale references. Therefore, if you reload an EJB module, you should also reload calling modules. There are some restrictions to creating user-defined module classloader hierarchies; these are discussed in the following sections.
Nesting Depth
Nesting is limited to three levels (including the application classloader). Deeper nestings lead to a deployment exception.
Module Types
Custom classloader hierarchies are currently restricted to Web and EJB modules.
Duplicate Entries
Duplicate entries lead to a deployment exception.
Interfaces
The standard WebLogic Server classloader hierarchy makes EJB interfaces available to all modules in the application. Thus other modules can invoke an EJB, even though they do not include the interface classes in their own module. This is possible because EJBs are always loaded into the root classloader and all other modules either share that classloader or have a classloader that is a child of that classloader. With the custom classloader feature, you can configure a classloader hierarchy so that a callees classes are not visible to the caller. In this case, the calling module must include the interface classes. This is the same requirement that exists when invoking on modules in a separate application.
Call-by-Value Semantics
The standard classloader hierarchy provided with WebLogic Server allows for calls between modules within an application to use call-by-reference semantics. This is because the caller is always using the same classloader or a child classloader of the callee. With this feature, it is
8-11
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
possible to configure the classloader hierarchy so that two modules are in separate branches of the classloader tree. In this case, call-by-value semantics are used.
In-Flight Work
Be aware that the classloader switch required for reloading is not atomic across modules. In fact, updates to applications in general are not atomic. For this reason, it is possible that different in-flight operations (operations that are occurring while a change is being made) might end up accessing different versions of classes depending on timing.
8-12
To perform a partial update of files relative to the root of the exploded application, use the following command line: Listing 8-4 Performing a Partial File Update
java weblogic.Deployer -adminurl url -user user -password password -name myapp -redeploy myejb/foo.class
After the -redeploy command, you provide a list of files relative to the root of the exploded application that you want to update. This might be the path to a specific element (as above) or a module (or any set of elements and modules). For example: Listing 8-5 Providing a List of Relative Files for Update
java weblogic.Deployer -adminurl url -user user -password password -name myapp -redeploy mywar myejb/foo.class anotherejb
8-13
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
Given a set of files to be updated, the system tries to figure out the minimum set of things it needs to redeploy. Redeploying only an EJB impl class causes only that class to be redeployed. If you specify the whole EJB (in the above example, anotherejb) or if you change and update the EJB home interface, the entire EJB module must be redeployed. Depending on the classloader hierarchy, this redeployment may lead to other modules being redeployed. Specifically, if other modules share the EJB classloader or are loaded into a classloader that is a child to the EJB's classloader (as in the WebLogic Server standard classloader module) then those modules are also reloaded.
8-14
already present in the system classloader. Every child classloader asks the parent (the system classloader) for a particular class and cannot load classes which are seen by the parent. For example, if a class called com.foo.Baz exists in both $CLASSPATH as well as the application EAR, then the class from the $CLASSPATH is loaded and not the one from the EAR. Since weblogic.jar is in the $CLASSPATH, applications can not override any WebLogic Server classes. The following sections define and describe how to use a filtering classloader: What is a Filtering ClassLoader on page 8-15 Configuring a FilteringClassLoader on page 8-15 Resource Loading Order on page 8-16
Configuring a FilteringClassLoader
To configure the FilteringClassLoader to specify a certain package is loaded from an application, add a prefer-application-packages descriptor element to the weblogic-application.xml which details the list of packages to be loaded from the application. The following example specifies that org.apache.log4j.* and antlr.* packages are loaded from the application, not the system classloader:
<prefer-application-packages> <package-name>org.apache.log4j.*</package-name> <package-name>antlr.*</package-name>
8-15
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
</prefer-application-packages>
Figure 8-5 Using the System Classloader System (3) | App (2) | Web (1)
To be more explicit, given a resource /META-INF/foo.xml which exists in all the classloaders, would return the following list of URLs:
META-INF/foo.xml - from the System ClassLoader (3) META-INF/foo.xml - from the App ClassLoader (2) META-INF/foo.xml - from the Web ClassLoader (1)
When filtering is enabled, the resources from the child of the FilteringClassLoader (an application classloader) down to the calling classloader are returned before the ones from the system classloader. In Figure 8-6, if the same resource existed in all the classloaders (D), (B) and (A) one would get them in the following order if requested by the Web classloader:
META-INF/foo.xml - from the App ClassLoader (B) META-INF/foo.xml - from the Web ClassLoader (A) META-INF/foo.xml - from the System ClassLoader (D)
8-16
Re solv ing Cla ss Ref ere nce s Bet we en Mod ul es an d A pp lic at ion s
Note: The resources are returned in the default Java EE delegation model beneath the FilteringClassLoader. Only the resources from the parent of the FilteringClassLoader are appended to the end of the enumeration being returned. Figure 8-6 Using a Filtering Classloading Implementation System (D) | FilteringClassLoader (filterList := x.y.*) (C) | App (B) | Web (A)
If the application classloader requested the same resource, the following order would be obtained.
META-INF/foo.xml - from the App ClassLoader (B) META-INF/foo.xml - from the System ClassLoader (D)
For getResource(), only the first descriptor is returned and getResourceAsStream() returns the inputStream of the first resource.
8-17
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
Manifest Class-Path
The Java EE specification provides the manifest Class-Path entry as a means for a module to specify that it requires an auxiliary JAR of classes. You only need to use this manifest Class-Path entry if you have additional supporting JAR files as part of your EJB JAR or WAR file. In such cases, when you create the JAR or WAR file, you must include a manifest file with a Class-Path element that references the required JAR files. The following is a simple manifest file that references a utility.jar file:
Manifest-Version: 1.0 [CRLF] Class-Path: utility.jar [CRLF]
8-18
In the first line of the manifest file, you must always include the Manifest-Version attribute, followed by a new line (CR | LF |CRLF) and then the Class-Path attribute. More information about the manifest format can be found at:
http://java.sun.com/j2se/1.4/docs/guide/jar/jar.html#JAR
The manifest Class-Path entries refer to other archives relative to the current archive in which these entries are defined. This structure allows multiple WAR files and EJB JAR files to share a common library JAR. For example, if a WAR file contains a manifest entry of y.jar, this entry should be next to the WAR file (not within it) as follows:
/<directory>/x.war /<directory>/y.jars
The manifest file itself should be located in the archive at META-INF/MANIFEST.MF. For more information, see
http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html.
8-19
Und er st an din g Web Log ic Ser ve r Ap pli cat io n Cla ss loa din g
among several applications, use the Java EE libraries feature described in Creating Shared Java EE Libraries and Optional Packages on page 9-1. To share JARs using the lib directory: 1. Shutdown all servers in the domain. 2. Copy the JAR file(s) to share into a lib subdirectory of the domain directory. For example:
mkdir c:\bea\wlserver_10.0\samples\domains\wl_server\lib cp c:\3rdpartyjars\utility.jar c:\bea\wlserver_10.0\samples\domains\wl_server\lib
Note: WebLogic Server must have read access to the lib directory during startup. Note: The Administration Server does not automatically copy files in the lib directory to Managed Servers on remote machines. If you have Managed Servers that do not share the same physical domain directory as the Administration Server, you must manually copy JAR file(s) to the domain_name/lib directory on the Managed Server machines. 3. Start the Administration Server and all Managed Servers in the domain. WebLogic Server appends JAR files found in the lib directory to the system classpath. Multiple files are added in alphabetical order.
8-20
CHAPTER
The following sections describe how to share components and classes among applications using shared Java EE libraries and optional packages: Overview of Shared Java EE Libraries and Optional Packages on page 9-2 Creating Shared Java EE Libraries on page 9-6 Referencing Shared Java EE Libraries in an Enterprise Application on page 9-11 Referencing Optional Packages from a Java EE Application or Module on page 9-15 Using weblogic.appmerge to Merge Libraries on page 9-18 Integrating Shared Java EE Libraries with the Split Development Directory Environment on page 9-20 Deploying Shared Java EE Libraries and Dependent Applications on page 9-20 Web Application Shared Java EE Library Information on page 9-21 Using WebApp Libraries With Web Applications on page 9-21 Accessing Registered Shared Java EE Library Information with LibraryRuntimeMBean on page 9-22 Order of Precedence of Modules When Referencing Shared Java EE Libraries on page 9-23 Best Practices for Using Shared Java EE Libraries on page 9-24
9-1
9-2
Optional Packages
WebLogic Server supports optional packages as described in the Java EE 5.0 Specification, Section 8.2 Optional Package Support, with versioning described in Optional Package Versioning. Optional packages provide similar functionality to Java EE libraries, allowing you to easily share a single JAR file among multiple applications. As with Java EE libraries, optional packages must first be registered with WebLogic Server by deploy the associated JAR file as an optional package. After registering the package, you can deploy Java EE modules that reference the package in their manifest files. Optional packages differ from Java EE libraries because optional packages can be referenced from any Java EE module (EAR, JAR, WAR, or RAR archive) or exploded archive directory. Java EE libraries can be referenced only from a valid Enterprise Application. For example, third-party Web Application Framework classes needed by multiple Web Applications can be packaged and deployed in a single JAR file, and referenced by multiple Web Application modules in the domain. Optional packages, rather than Java EE libraries, are used in this case, because the individual Web Application modules must reference the shared JAR file. (With Java EE libraries, only a complete Enterprise Application can reference the library). Note: BEA documentation and WebLogic Server utilities use the term library to refer to both Java EE libraries and optional packages. Optional packages are called out only when necessary.
Library Directories
The Java EE platform provides several mechanisms for applications to use optional packages and shared libraries. Libraries can be bundled with an application or may be installed separately for use by any application. An EAR file may contain a directory that contains libraries packaged in JAR files. The library-directory element of the EAR files deployment descriptor contains the name of this directory. If a library-directory element isnt specified, or if the EAR file does not contain a deployment descriptor, the directory named lib is used. An empty library-directory element may be used to specify that there is no library directory. All files in this directory (but not in subdirectories) with a .jar extension must be made available to all components packaged in the EAR file, including application clients. These libraries may reference other libraries, either bundled with the application or installed separately. This feature is similar to the APP-INF/lib feature supported in WebLogic Server. If both APP-INF/lib and library-directory exist, then the jars in the library-directory would take precedence; that is, they would be placed before the APP-INF/lib jar files in the classpath. For more information on APP-INF/lib, see Resolving Class References Between Modules and
Developing Applications with WebLogic Server 9-3
Applications on page 8-17 and Organizing Shared Classes in a Split Development Directory on page 3-11.
Applications that reference shared Java EE libraries and optional packages can specify required versions for the shared files. Optional packages can reference other optional packages, and shared Java EE libraries can reference other shared Java EE libraries. Optional packages differ from shared Java EE Libraries in the following basic ways: Optional packages are plain JAR files, whereas shared Java EE libraries can be plain JAR files, Java EE Enterprise Applications, or standalone Java EE modules (EJB and Web applications). This means that libraries can have valid Java EE and WebLogic Server deployment descriptors. Any deployment descriptors in an optional package JAR file are ignored. Any Java EE application or module can reference an optional package (using META-INF/MANIFEST.MF), whereas only Enterprise Applications and Web applications can reference a shared Java EE library (using weblogic-application.xml or weblogic.xml) In general, use shared Java EE libraries when you need to share one or more EJB, Web Application or Enterprise Application modules among different Enterprise Applications. Use optional packages when you need to share one or more classes (packaged in a JAR file) among different Java EE modules. Plain JAR files can be shared either as libraries or optional packages. Use optional packages if you want to: Share a plain JAR file among multiple Java EE modules Reference shared JAR files from other shared JARs Share plain JARs as described by the Java EE 5.0 specification Use shared Java EE libraries to share a plain JAR file if you only need to reference the JAR file from one or more Enterprise Applications, and you do not need to maintain strict compliance with the Java EE specification. Note: BEA documentation and WebLogic Server utilities use the term shared Java EE library to refer to both libraries and optional packages. Optional packages are called out only when necessary.
9-5
Additional Information
For information about deploying and managing shared Java EE libraries, optional packages, and referencing applications from the Administrators perspective, see Deploying Shared Java EE Libraries and Dependent Applications in Deploying Applications to WebLogic Server.
9-6
Cr ea ti ng Sh ar ed J ava E E L ibr a ri es
You must ensure that context roots in Web application modules of the shared Java EE library do not conflict with context roots in the referencing Enterprise Application. If necessary, you can configure referencing applications to override a librarys context root. See Referencing Shared Java EE Libraries in an Enterprise Application on page 9-11. Shared Java EE libraries cannot be nested. For example, if you are deploying an EAR as a shared Java EE library, the entire EAR must be designated as the library. You cannot designate individual Java EE modules within the EAR as separate, named libraries. As with any other Java EE module or Enterprise Application, a shared Java EE library must be configured for deployment to the target servers or clusters in your domain. This means that a library requires valid Java EE deployment descriptors as well as WebLogic Server-specific deployment descriptors and an optional deployment plan. See Deploying Applications to WebLogic Server. BEA recommends packaging shared Java EE libraries as Enterprise Applications, rather than as standalone Java EE modules. This is because the URI of a standalone module is derived from the deployment name, which can change depending on how the module is deployed. By default, WebLogic Server uses the deployment archive filename or exploded archive directory name as the deployment name. If you redeploy a standalone shared Java EE library from a different file or location, the deployment name and URI also change, and referencing applications that use the wrong URI cannot access the deployed library. If you choose to deploy a shared Java EE library as a standalone Java EE module, always specify a known deployment name during deployment and use that name as the URI in referencing applications.
2. Copy the compiled class files into the working directory, creating the appropriate package sudirectories as necessary. For example:
mkdir -p /apps/myOptPkg/org/myorg/myProduct cp /build/classes/myOptPkg/org/myOrg/myProduct/*.class /apps/myOptPkg/org/myOrg/myProduct
9-7
3. If you already have a JAR file that you want to use as an optional package, extract its contents into the working directory so that you can edit the manifest file:
cd /apps/myOptPkg jar xvf /build/libraries/myLib.jar
Description
An optional string value that identifies the name of the shared Java EE library. Referencing applications must use the exact Extension-Name value to use the library. As a best practice, always specify an Extension-Name value for each library. If you do not specify an extension name, one is derived from the deployment name of the library. Default deployment names are different for archive and exploded archive deployments, and they can be set to arbitrary values in the deployment command.
9-8
Cr ea ti ng Sh ar ed J ava E E L ibr a ri es
Description
An optional String value that defines the specification version of the shared Java EE library. Referencing applications can optionally specify a required Specification-Version for a library; if the exact specification version is not available, deployment of the referencing application fails. The Specification-Version uses the following format: Major/minor version format, with version and revision numbers separated by periods (such as 9.0.1.1) Referencing applications can be configured to require either an exact version of the shared Java EE library, a minimum version, or the latest available version. The specification version for a shared Java EE library can also be set at the command-line when deploying the library, with some restrictions. See Deploying Shared Java EE Libraries and Dependent Applications on page 9-20.
Implementation-Version
An optional String value that defines the code implementation version of the shared Java EE library. You can provide an Implementation-Version only if you have also defined a Specification-Version.
Implementation-Version uses the following formats:
Major/minor version format, with version and revision numbers separated by periods (such as 9.0.1.1) Text format, with named versions (such as 9011Beta or 9.0.1.1.B)
If you use the major/minor version format, referencing applications can be configured to require either an exact version of the shared Java EE library, a minimum version, or the latest available version. If you use the text format, referencing applications must specify the exact version of the library. The implementation version for a shared Java EE library can also be set at the command-line when deploying the library, with some restrictions. See Deploying Shared Java EE Libraries and Dependent Applications on page 9-20.
9-9
1. Open (or create) the manifest file using a text editor. For the example shared Java EE library, you would use the commands:
cd /apps/myLibrary mkdir META-INF emacs META-INF/MANIFEST.MF
2. In the text editor, add a string value to specify the name of the shared Java EE library. For example:
Extension-Name: myExtension
Applications that reference the library must specify the exact Extension-Name in order to use the shared files. 3. As a best practice, enter the optional version information for the shared Java EE library. For example:
Extension-Name: myExtension Specification-Version: 2.0 Implementation-Version: 9.0.0
Using the major/minor format for the version identifiers provides the most flexibility when referencing the library from another application (see Table ) Note: Although you can optionally specify the Specification-Version and Implementation-Version at the command-line during deployment, BEA recommends that you include these strings in the MANIFEST.MF file. Including version strings in the manifest ensures that you can deploy new versions of the library alongside older versions. See Deploying Shared Java EE Libraries and Dependent Applications on page 9-20.
9-10
Because a shared Java EE library is packaged as a standard Java EE application or standalone module, you may also choose to export a librarys deployment configuration to a deployment plan, as described in Deploying Applications to WebLogic Server. Optional package .JAR files contain no deployment descriptors and cannot be exported. For development purposes, you may choose to deploy libraries as exploded archive directories to facilitate repeated updates and redeployments.
Description
library-ref is the parent element in which you define a reference to a shared Java EE library. Enclose all other elements within library-ref.
library-name
A required string value that specifies the name of the shared Java EE library to use. library-name must exactly match the value of the Extension-Name attribute in the librarys manifest file. (See Table 9-4.) An optional String value that defines the required specification version of the shared Java EE library. If this element is not set, the application uses a matching library with the highest specification version. If you specify a string value using major/minor version format, the application uses a matching library with the highest specification version that is not below the configured value. If all available libraries are below the configured specification-version, the application cannot be deployed. The required version can be further constrained by using the exact-match element, described below. If you specify a String value that does not use major/minor versioning conventions (for example, 9.2BETA) the application requires a shared Java EE library having the exact same string value in the Specification-Version attribute in the librarys manifest file. (See Table 9-4.)
specification-version
9-11
Table 9-2 weblogic-application.xml Elements for Referencing a Shared Java EE Library Element
implementation-version
Description
An optional String value that specifies the required implementation version of the shared Java EE library. If this element is not set, the application uses a matching library with the highest implementation version. If you specify a string value using major/minor version format, the application uses a matching library with the highest implementation version that is not below the configured value. If all available libraries are below the configured implementation-version, the application cannot be deployed. The required implementation version can be further constrained by using the exact-match element, described below. If you specify a String value that does not use major/minor versioning conventions (for example, 9.2BETA) the application requires a shared Java EE library having the exact same string value in the Implementation-Version attribute in the librarys manifest file. (See Table 9-4.)
exact-match
An optional boolean value that determines whether the application should use a shared Java EE library with a higher specification or implementation version than the configured value, if one is available. By default this element is false, which means that WebLogic Server uses higher-versioned libraries if they are available. Set this element to true to require the exact matching version as specified in the specification-version and implementation-version elements. An optional String value that provides an alternate context root to use for a Web application shared Java EE library. Use this element if the context root of a library conflicts with the context root of a Web Application in the referencing Java EE application. Web application shared Java EE library refers to special kind of library: a Web application that is referenced by another Web application. See Web Application Shared Java EE Library Information on page 9-21.
context-root
For example, this simple entry in the weblogic-application.xml descriptor references a shared Java EE library, myLibrary:
<library-ref> <library-name>myLibrary</library-name> </library-ref>
9-12
In the above example, WebLogic Server attempts to find a library name myLibrary when deploying the dependent application. If more than one copy of myLibrary is registered, WebLogic Server selects the library with the highest specification version. If multiple copies of the library use the selected specification version, WebLogic Server selects the copy having the highest implementation version. This example references a shared Java EE library with a requirement for the specification version:
<library-ref> <library-name>myLibrary</library-name> <specification-version>2.0</specification-version> </library-ref>
In the above example, WebLogic Server looks for matching libraries having a specification version of 2.0 or higher. If multiple libraries are at or above version 2.0, WebLogic Server examines the selected libraries that use Float values for their implementation version and selects the one with the highest version. Note that WebLogic Server ignores any selected libraries that have a non-Float value for the implementation version. This example references a shared Java EE library with both a specification version and a non-Float value implementation version:
<library-ref> <library-name>myLibrary</library-name> <specification-version>2.0</specification-version> <implementation-version>81Beta</implementation-version> </library-ref>
In the above example, WebLogic Server searches for a library having a specification version of 2.0 or higher, and having an exact match of 81Beta for the implementation version. The following example requires an exact match for both the specification and implementation versions:
<library-ref> <library-name>myLibrary</library-name> <specification-version>2.0</specification-version> <implementation-version>8.1</implementation-version> <exact-match>true</exact-match> </library-ref>
9-13
The following example specifies a context-root-override, which in turn, refers to the old context-root specified in one of its libraries and the new context-root that should be used instead. (override):
<library-ref> <library-name>myLibrary</library-name> <library-context-root-override> <library-context-root>webapp</library-context-root> <override-value>mywebapp</override-value> </library-context-root-override> </library-ref>
Enterprise Library
A Java EE application can override context-roots within a referenced EAR library using entries in the applications weblogic-application.xml deployment descriptor. Table 9-3 describes the XML elements that override context-roots in a library reference. Table 9-3 weblogic-application.xml Elements for Overriding a Shared Java EE Library Element
library-context-root
Description
An optional String value that overrides the context-root elements declared in libraries. In the absence of this element, the librarys context-root is used. Only a referencing application (i.e., a user application) can override the context-root elements declared in its libraries.
override-value
An optional String value that specifies the value of the library-context-root-override element when overriding the context-root elements declared in libraries. In the absence of these elements, the librarys context-root is used.
The following example specifies a context-root-override, which in turn, refers to the old context-root specified in one of its libraries and the new context-root that should be used instead. (override):
<library-ref> <library-name>myLibrary</library-name>
9-14
In the above example, the current application refers to myLibrary, which contains a Web application with a context-root of webapp. The only way to override this reference is to declare a library-context-root-override that maps webapp to mywebapp.
9-15
Description
A required String value that defines a logical name for an optional package dependency. You can use multiple values in the Extension-List attribute to designate multiple optional package dependencies. For example:
Extension-List: dependency1 dependency2
[logical_name-]Extension -Name
A required string value that identifies the name of an optional package dependency. This value must match the Extension-Name attribute defined in the optional packages manifest file. If you are referencing multiple optional packages from a single archive, prepend the appropriate logical name to the Extension-Name attribute. For example:
dependency1-Extension-Name: myOptPkg
9-16
Description
An optional String value that defines the required specification version of an optional package. If this element is not set, the archive uses a matching package with the highest specification version. If you include a specification-version value using the major/minor version format, the archive uses a matching package with the highest specification version that is not below the configured value. If all available package are below the configured specification-version, the archive cannot be deployed. If you specify a String value that does not use major/minor versioning conventions (for example, 9.2BETA) the archive requires a matching optional package having the exact same string value in the Specification-Version attribute in the packages manifest file. (See Table on page 8.) If you are referencing multiple optional packages from a single archive, prepend the appropriate logical name to the Specification-Version attribute.
[logical_name-]Implement ation-Version
An optional String value that specifies the required implementation version of an optional package. If this element is not set, the archive uses a matching package with the highest implementation version. If you specify a string value using the major/minor version format, the archive uses a matching package with the highest implementation version that is not below the configured value. If all available libraries are below the configured implementation-version, the application cannot be deployed. If you specify a String value that does not use major/minor versioning conventions (for example, 9.2BETA) the archive requires a matching optional package having the exact same string value in the Implementation-Version attribute in the packages manifest file. (See Table on page 8.) If you are referencing multiple optional packages from a single archive, prepend the appropriate logical name to the Implementation-Version attribute.
For example, this simple entry in the manifest file for a dependent archive references two optional packages, myAppPkg and my3rdPartyPkg:
9-17
This example requires a specification version of 2.0 or higher for myAppPkg, and an exact match for the implementation version of my3rdPartyPkg:
Extension-List: internal 3rdparty internal-Extension-Name: myAppPkg 3rdparty-Extension-Name: my3rdPartyPkg internal-Specification-Version: 2.0 3rdparty-Implementation-Version: 8.1GA
By default, when WebLogic Server deploys an application or module and it cannot resolve a reference in the applications manifest file to an optional package, WebLogic Server prints a warning, but continues with the deployment anyway. You can change this behavior by setting the system property weblogic.application.RequireOptionalPackages to true when you start WebLogic Server, either at the command line or in the command script file from which you start the server. Setting this system property to true means that WebLogic Server does not attempt to deploy an application or module if it cannot resolve an optional package reference in its manifest file.
Using weblogic.appmerge from the CLI on page 9-19 Using weblogic.appmerge as an Ant Task on page 9-19
9-18
where valid options are shown in Table 9-5: Table 9-5 weblogic.appmerge Options Option
-help -version -output <file>
Comment
Print the standard usage message. Print version information. Specifies an alternate output archive or directory. If not set, output is placed in the source archive or directory. Specifies an optional deployment plan. Provide more verbose output. Comma-separated list of libraries. Each library may optionally set its name and versions, if not already set in its manifest, using the following syntax:
<file> [@name=<string>@libspecver=<version> @libimplver=<version|string>].
Registers all files in specified directory as libraries. Specifies that the application or module contains deployment descriptors with annotation information.
Example:
$ java weblogic.appmerge -output CompleteSportsApp.ear -library Weather .war,Calendar.ear SportsApp.ear
9-19
<taskdef name="appmerge" classname="weblogic.ant.taskdefs.j2ee.AppMergeTas k"/> <appmerge source="SportsApp.ear" output="CompleteSportsApp.ear"> <library file="Weather.war"/> <library file="Calendar.ear"/> </appmerge>
Integrating Shared Java EE Libraries with the Split Development Directory Environment
The BuildXMLGen includes a -librarydir option to generate build targets that include one or more shared Java EE library directories. See Generating a Basic build.xml File Using weblogic.BuildXMLGen on page 3-13. The wlcompile and wlappc Ant tasks include a librarydir attribute and library element to specify one or more shared Java EE library directories to include in the classpath for application builds. See Building Applications in a Split Development Directory on page 4-1.
9-20
We b A pp l i c at i o n S ha re d J av a E E L i b ra r y I nf o r m at i o n
After registering a shared Java EE library, you can deploy applications and archives that depend on the library. Dependent applications can be deployed only if the target servers have registered all required libraries, and the registered deployments meet the version requirements of the application or archive. See Deploying Applications that Reference Libraries in Deploying Applications to WebLogic Server for more information.
different Web applications, so that you dont have to bundle them with each Web application. When you include a webapp-library in your Web application, at deployment time the container merges all the static resources, classes, and JAR files into your Web application. The first step in using a WebApp library is to register a Web application as a webapp-library. This can be accomplished by deploying a Web application using either the Administration Console or the weblogic.Deployer tool as a library. To make other Web applications refer to this library, their weblogic.xml file must have a library-ref element pointing to the webapp-library, as follows:
<library-ref> <library-name>BaseWebApp</library-name> <specification-version>2.0</specification-version> <implementation-version>8.1beta</implementation-version> <exact-match>false</exact-match> </library-ref>
When multiple libraries are present, the CLASSPATH/resource path precedence order follows the order in which the library-refs elements appear in the weblogic.xml file.
manifest file. For more information, see the WebLogic Server 10.0 API Reference.
9-22
9-23
9-24
Package shared Java EE libraries as archive files for delivery to Administrators or deployers in your organization. Deploy libraries from exploded archive directories during development to allow for easy updates and repeated redeployments. Deploy shared Java EE libraries to all WebLogic Server instances on which you want to deploy dependent applications and archives. If a library is not registered with a server instance on which you want to deploy a referencing application, deployment of the referencing application fails.
9-25
9-26
C H A P T E R 10
The following sections describe how to create applications that respond to WebLogic Server application lifecycle events: Understanding Application Lifecycle Events on page 10-1 Registering Events in weblogic-application.xml on page 10-2 Programming Basic Lifecycle Listener Functionality on page 10-3 Examples of Configuring Lifecycle Events with and without the URI Parameter on page 10-6 Understanding Application Lifecycle Event Behavior During Re-deployment on page 10-7 Programming Application Version Lifecycle Events on page 10-8 WARNING: Application-scoped startup and shutdown classes have been deprecated as of release 9.0 of WebLogic Server. The information in this chapter about startup and shutdown classes is provided only for backwards compatibility. Instead, you should use lifecycle listener events in your applications.
10-1
Four application lifecycle events are provided with WebLogic Server, which can be used to extend listener, shutdown, and startup classes. These include: Listenersattachable to any event. Possible methods for Listeners are:
public void preStart(ApplicationLifecycleEvent evt) {}
The preStart event is the beginning of the prepare phase, or the start of the application deployment process.)
public void postStart(ApplicationLifecycleEvent evt) {}
The postStart event is the end of the activate phase, or the end of the application deployment process. The application is deployed.
public void preStop(ApplicationLifecycleEvent evt) {}
The preStop event is the beginning of the deactivate phase, or the start of the application removal or undeployment process.
public void postStop(ApplicationLifecycleEvent evt) {}
The postStop event is the end of the remove phase, or the end of the application removal or undeployment process. Shutdown classes only get postStop events. WARNING: Application-scoped shutdown classes have been deprecated as of release 9.0 of WebLogic Server. Use lifecycle listeners instead. Startup classes only get preStart events. WARNING: Application-scoped shutdown classes have been deprecated as of release 9.0 of WebLogic Server. Use lifecycle listeners instead. Note: For Startup and Shutdown classes, you only implement a main{} method. If you implement any of the methods provided for Listeners, they are ignored. No remove{} method is provided in the ApplicationLifecycleListener, because the events are only fired at startup time during deployment (prestart and poststart) and shutdown during undeployment (prestop and poststop).
10-2
listenerUsed to register user defined application lifecycle listeners. These are classes that extend the abstract base class weblogic.application.ApplicationLifecycleListener. shutdownUsed to register user-defined shutdown classes. startupUsed to register user-defined startup classes.
required functionality: preStart{} postStart{} preStop{} postStop{} Listing 10-1 illustrates how you override the ApplicationLifecycleListener. In this example, the public class MyListener extends ApplicationLifecycleListener. Listing 10-1 MyListener
import weblogic.application.ApplicationLifecycleListener; import weblogic.application.ApplicationLifecycleEvent; public class MyListener extends ApplicationLifecycleListener { public void preStart(ApplicationLifecycleEvent evt) { System.out.println ("MyListener(preStart) -- we should always see you.."); } // preStart public void postStart(ApplicationLifecycleEvent evt) {
10-3
System.out.println ("MyListener(postStart) -- we should always see you.."); } // postStart public void preStop(ApplicationLifecycleEvent evt) { System.out.println ("MyListener(preStop) -- we should always see you.."); } // preStop public void postStop(ApplicationLifecycleEvent evt) { System.out.println ("MyListener(postStop) -- we should always see you.."); } // postStop public static void main(String[] args) { System.out.println ("MyListener(main): in main .. we should never see you.."); } // main }
Listing 10-2 illustrates how you implement the shutdown class. The shutdown class is attachable to preStop and postStop events. In this example, the public class MyShutdown does not extend ApplicationLifecycleListener because a shutdown class declared in the weblogic-application.xml deployment descriptor does not need to depend on any WebLogic Server-specific interfaces. Listing 10-2 MyShutdown
import weblogic.application.ApplicationLifecycleListener; import weblogic.application.ApplicationLifecycleEvent; public class MyShutdown { public static void main(String[] args) {
10-4
Listing 10-3 illustrates how you implement the startup class. The startup class is attachable to preStart and postStart events. In this example, the public class MyStartup does not extend ApplicationLifecycleListener because a startup class declared in the weblogic-application.xml deployment descriptor does not need to depend on any WebLogic Server-specific interfaces. Listing 10-3 MyStartup
import weblogic.application.ApplicationLifecycleListener; import weblogic.application.ApplicationLifecycleEvent; public class MyStartup { public static void main(String[] args) { System.out.println ("MyStartup(main): in main .. should be for pre-start"); } // main }
10-5
1. Follow the basic programming steps outlined in Programming Basic Lifecycle Listener Functionality on page 10-3. 2. Within the listener element add the run-as-principal-name element to specify the user who has privileges to startup and/or shutdown the event. For example:
<listener> <listener-class>myApp.MySessionAttributeListenerClass</listener-class > <run-as-principal-name>javajoe</run-as-principal-name> </listener>
The identity specified here should be a valid user name in the system. If run-as-principal-name is not specified, the deployment initiator user identity will be used as the run-as identity for the execution of the application lifecycle listener.
Examples of Configuring Lifecycle Events with and without the URI Parameter
The following examples illustrate how you configure application lifecycle events in the weblogic-application.xml deployment descriptor file. The URI parameter is not required. You can place classes anywhere in the application $CLASSPATH. However, you must ensure that the class locations are defined in the $CLASSPATH. You can place listeners in APP-INF/classes or APP-INF/lib, if these directories are present in the EAR. In this case, they are automatically included in the $CLASSPATH. The following example illustrates how you configure application lifecycle events using the URI parameter. In this case, the archive foo.jar contains the classes and exists at the top level of the EAR file. For example: myEar/foo.jar Listing 10-4 Configuring Application Lifecycle Events Using the URI Parameter
<listener> <listener-class>MyListener</listener-class> <listener-uri>foo.jar</listener-uri> </listener> <startup> <startup-class>MyStartup</startup-class>
10-6
The following example illustrates how you configure application lifecycle events without using the URI parameter. Listing 10-5 Configuring Application Lifecycle Events without Using the URI Parameter
<listener> <listener-class>MyListener</listener-class> </listener> <startup> <startup-class>MyStartup</startup-class> </startup> <shutdown> <shutdown-class>MyShutdown</shutdown-class> </shutdown>
10-7
been registeredthe application lifecycle first commences the shutdown sequence, next re-initializes its classes, and then performs the startup sequence. For example, if your listener is registered for the full application lifecycle set of events (preStart, postStart, preStop, postStop), during a full re-deployment, you see the following sequence of events:
1. preStop{} 2. postStop{}
3. Initialization takes place. (Unless you have set debug flags, you do not see the initialization.)
4. preStart{} 5. postStart{}
for all application versions, including the version that registers the listener. Use the ApplicationVersionLifecycleEvent.isOwnVersion method to determine if an event belongs to a particular version. See the ApplicationVersionLifecycleEvent class for more information on types of version lifecycle events.
The preDeloy event is invoked when an application version deploy or redeploy operation is initiated.
public void postDeploy(ApplicationVersionLifecycleEvent evt)
The postDeloy event is invoked when an application version is deployed or redeployed successfully.
public void preUndeploy(ApplicationVersionLifecycleEvent evt)
The preUndeloy event is invoked when an application version undeploy operation is initiated
public void postDelete(ApplicationVersionLifecycleEvent evt)
The postDelete event is invoked when an application version is deleted. Note: A postDelete event is only be fired after the entire application version is completely removed. It does not include a partial undeploy, such as undeploying a module or from a subset of targets.
Example of Production Deployment Sequence When Using Application Version Lifecycle Events
The following table provides an example of a deployment (V1), production redeployment (V2), and an undeploy (V2).
10-9
Table 10-1 Sequence of Deployment Actions and Application Version Lifecycle Events Deployment action
Deployment of Version V1
Time
T0 T1 T2
Version V1
preDeploy(V1) invoked.
Version V2
Deployment starts. Application lifecycle listeners for V1 are registered. V1 is active version, Deployment is complete.
postDeploy(V1) invoked.
T3
T4 T5
10-10
Table 10-1 Sequence of Deployment Actions and Application Version Lifecycle Events Deployment action
Production Redeployment of Version V2
Time
T6 T7
Version V1
Version V2
preDeploy(V2) invoked.
Application version listener receives preDeploy(V1). Deployment starts. Application lifecycle listeners for V2 are registered. If deploy(V2) succeeds, V1 ceases to be active version. If deploy(V2) succeeds, V2 replaces V1 as active version. Deployment is complete.
T8 T9
T10
T11
postDeploy(V2) invoked.
Note:
T12
Application version listener gets postDeploy(V2). If deploy(V2) fails, V1 remains active. Application listeners gets postDeploy(V2). If deploy(V2) succeeds, V1 begins retirement. Application listeners for V1 are unregistered. V1 is retired.
T13
T14
T15
T16
10-11
Table 10-1 Sequence of Deployment Actions and Application Version Lifecycle Events Deployment action
Undeployment of V2
Time
T17 T18
Version V1
Version V2
preUndeploy(v2) invoked.
Application listeners gets preUndeploy(v2) invoked. Undeployment begins. V2 is no longer active version. Application version listeners for V2 are unregistered. Undeployment is complete. If the entire application is undeployed, postDelete(V2) is invoked. Note: This event occurs even if the undeployment fails.
T22 T23
10-12
C H A P T E R 11
The following sections describe how to use the context propagation APIs in your applications: Understanding Context Propagation on page 11-1 Programming Context Propagation: Main Steps on page 11-3 Programming Context Propagation in a Client on page 11-3 Programming Context Propagation in an Application on page 11-5
11-1
any type: EJB, Web Service, servlet, JMS topic or queue, and so on. See Programming Context Propagation: Main Steps on page 11-3 for details. The WebLogic context propagation APIs are in the weblogic.workarea package. The following table describes the main interfaces and classes.
Table 11-1 Interfaces and classes of the WebLogic Context Propagation API Interface or Class
WorkContext Map Interface
Description
Main context propagation interface used to tag applications with data and propagate that information via application requests. WorkContextMaps is part of the client or applications JNDI environment and can be accessed through JNDI by looking up the name java:comp/WorkContextMap. Interface used for marshaling and unmarshaling the user data that is passed along with an application. This interface has four implementing classes for marshaling and unmarshaling the following types of data: simple 8-bit ASCII contexts (AsciiWorkContext), long contexts (LongWorkContext), Serializable context (SerializableWorkContext), and String contexts (StringWorkContext).
WorkContext has one subinterface, PrimitiveWorkContext, used to specifically marshal and unmarshal a single primitive data item.
WorkContext Interface
Interfaces representing primitive streams used for marshaling and unmarshaling, respectively, WorkContext implementations. Defines the propagation properties of WorkContexts. Specifies whether the WorkContext is propagated locally, across threads, across RMI invocations, across JMS queues and topics, or across SOAP messages. If not specified, default is to propagate data across remote and local calls in the same thread. Convenience class for creating WorkContexts that contain only primitive data.
11-2
P r o gr am m i ng C o nt e x t P ro pa ga ti o n: Ma i n St e p s
For the complete API documentation about context propagation, see the weblogic.workarea Javadocs.
11-3
import javax.xml.rpc.ServiceException; import javax.xml.rpc.Stub; import javax.naming.InitialContext; import javax.naming.NamingException; import import import import import weblogic.workarea.WorkContextMap; weblogic.workarea.WorkContext; weblogic.workarea.PrimitiveContextFactory; weblogic.workarea.PropagationMode; weblogic.workarea.PropertyReadOnlyException;
/** * This is a simple standalone client application that invokes the * the <code>sayHello</code> operation of the WorkArea Web service. * * @author Copyright (c) 2004 by BEA Systems. All Rights Reserved. */ public class Main { public final static String SESSION_ID= "session_id_key"; public static void main(String[] args) throws ServiceException, RemoteException, NamingException, PropertyReadOnlyException{ WorkAreaService service = new WorkAreaService_Impl(args[0] + "?WSDL"); WorkAreaPortType port = service.getWorkAreaPort(); WorkContextMap map = (WorkContextMap)new InitialContext().lookup("java:comp/WorkContextMap"); WorkContext stringContext = PrimitiveContextFactory.create("A String Context"); // Put a string context map.put(SESSION_ID, stringContext, PropagationMode.SOAP); try { String result = null; result = port.sayHello("Hi there!"); System.out.println( "Got result: " + result ); } catch (RemoteException e) { throw e; } } }
11-4
The following code shows how to import the needed weblogic.workarea.* classes, interfaces, and exceptions:
import import import import import weblogic.workarea.WorkContextMap; weblogic.workarea.WorkContext; weblogic.workarea.PrimitiveContextFactory; weblogic.workarea.PropagationMode; weblogic.workarea.PropertyReadOnlyException;
The following code shows how to create a WorkContextMap by doing a JNDI lookup of the context propagation-specific JNDI name java:comp/WorkContextMap:
WorkContextMap map = (WorkContextMap) new InitialContext().lookup("java:comp/WorkContextMap");
The following code shows how to create a WorkContext by using the PrimitiveContextFactory. In this example, the WorkContext consists of the simple String value A String Context. This String value is the user data that is passed to the invoked Web Service.
WorkContext stringContext = PrimitiveContextFactory.create("A String Context");
Finally, the following code shows how to add the context data, along with the key SESSION_ID, to the WorkContextMap and associate it with the current thread. The PropagationMode.SOAP constant specifies that the propagation happens over SOAP messages; this is because the client is invoking a Web Service.
map.put(SESSION_ID, stringContext, PropagationMode.SOAP);
11-5
// Import the Context Propagation classes import weblogic.workarea.WorkContextMap; import weblogic.workarea.WorkContext; import javax.jws.WebMethod; import javax.jws.WebService; import weblogic.jws.WLHttpTransport; @WebService(name="WorkAreaPortType", serviceName="WorkAreaService", targetNamespace="http://example.org") @WLHttpTransport(contextPath="workarea", serviceUri="WorkAreaService", portName="WorkAreaPort") /** * This JWS file forms the basis of simple WebLogic * Web Service with a single operation: sayHello * */ public class WorkAreaImpl { public final static String SESSION_ID = "session_id_key"; @WebMethod() public String sayHello(String message) { try { WorkContextMap map = (WorkContextMap) new InitialContext().lookup("java:comp/WorkContextMap"); WorkContext localwc = map.get(SESSION_ID); System.out.println("local context: " + localwc); System.out.println("sayHello: " + message); return "Here is the message: '" + message + "'"; } catch (Throwable t) { return "error"; } } }
11-6
In the preceding example: The following code shows how to import the needed context propagation APIs; in this case, only the WorkContextMap and WorkContext interfaces are needed:
import weblogic.workarea.WorkContextMap; import weblogic.workarea.WorkContext;
The following code shows how to create a WorkContextMap by doing a JNDI lookup of the context propagation-specific JNDI name java:comp/WorkContextMap:
WorkContextMap map = (WorkContextMap) new InitialContext().lookup("java:comp/WorkContextMap");
The following code shows how to get contexts user data from the current WorkContextMap using a key; in this case, the key is the same one that the client application set when it invoked the Web Service: SESSION_ID:
WorkContext localwc = map.get(SESSION_ID);
11-7
11-8
C H A P T E R 12
The following sections contains information on additional WebLogic Server programming topics: Overview of Using JavaMail with WebLogic Server Applications on page 12-1 Configuring JavaMail for WebLogic Server on page 12-2 Sending Messages with JavaMail on page 12-3 Reading Messages with JavaMail on page 12-4
12-1
The weblogic.jar also contains the Java Activation Framework (JAF) package, which JavaMail requires. The javax.mail package includes providers for Internet Message Access protocol (IMAP) and Simple Mail Transfer Protocol (SMTP) mail servers. Sun has a separate POP3 provider for JavaMail, which is not included in weblogic.jar. You can download the POP3 provider from Sun and add it to the WebLogic Server classpath if you want to use it.
12-2
Messages with JavaMail on page 12-3. Then, after you look up the mail session object in JNDI, call the Session.getInstance() method with your Properties object to get a customized Session.
3. If you need to override the properties you set for the Session in the Administration Console, create a java.util.Properties object and add the properties you want to override. Then call getInstance() to get a new Session object with the new properties.
Properties props = new Properties(); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.host", "mailhost"); // use mail address from HTML form for from address props.put("mail.from", emailAddress); Session session2 = session.getInstance(props);
4. Construct a MimeMessage. In the following example, to, subject, and messageTxt are String variables containing input from the user.
Message msg = new MimeMessage(session2); msg.setFrom(); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false)); msg.setSubject(subject); msg.setSentDate(new Date()); // Content is stored in a MIME multi-part message // with one body part MimeBodyPart mbp = new MimeBodyPart(); mbp.setText(messageTxt);
12-3
The JNDI lookup can throw a NamingException on failure. JavaMail can throw a MessagingException if there are problems locating transport classes or if communications with the mail host fails. Be sure to put your code in a try block and catch these exceptions.
12-4
3. If you need to override the properties you set for the Session in the Administration Console, create a Properties object and add the properties you want to override. Then call getInstance() to get a new Session object with the new properties:
Properties props = new Properties(); props.put("mail.store.protocol", "pop3"); props.put("mail.pop3.host", "mailhost"); Session session2 = session.getInstance(props);
4. Get a Store object from the Session and call its connect() method to connect to the mail server. To authenticate the connection, you need to supply the mailhost, username, and password in the connect method:
Store store = session.getStore(); store.connect(mailhost, username, password);
5. Get the default folder, then use it to get the INBOX folder:
Folder folder = store.getDefaultFolder(); folder = folder.getFolder("INBOX");
7. Operate on messages in the Message array. The Message class has methods that allow you to access the different parts of a message, including headers, flags, and message contents. Reading messages from an IMAP server is similar to reading messages from a POP3 server. With IMAP, however, the JavaMail API provides methods to create and manipulate folders and transfer messages between them. If you use an IMAP server, you can implement a full-featured, Web-based mail client with much less code than if you use a POP3 server. With POP3, you must provide code to manage a message store via WebLogic Server, possibly using a database or file system to represent folders.
12-5
12-6
C H A P T E R 13
The following sections contain information on additional WebLogic Server programming topics: Using Threads in WebLogic Server on page 13-1 Using the Work Manager API for Lower-Level Threading on page 13-2 Programming Applications for WebLogic Server Clusters on page 13-3
13-1
T h rea di ng a nd C l us te ri ng T o p i c s
results sooner if the searches are done asynchronously using a new thread for each repository instead of synchronously using the main client thread. If you must use threads in your application code, create a pool of threads so that you can control the number of threads your application creates. Like a JDBC connection pool, you allocate a given number of threads to a pool, and then obtain an available thread from the pool for your runnable class. If all threads in the pool are in use, wait until one is returned. A thread pool helps avoid performance issues and allows you to optimize the allocation of threads between WebLogic Server execution threads and your application. Be sure you understand where your threads can deadlock and handle the deadlocks when they occur. Review your design carefully to ensure that your threads do not compromise the security system. To avoid undesirable interactions with WebLogic Server threads, do not let your threads call into WebLogic Server modules. For example, do not use enterprise beans or servlets from threads that you create. Application threads are best used for independent, isolated tasks, such as conversing with an external service with a TCP/IP connection or, with proper locking, reading or writing to files. A short-lived thread that accomplishes a single purpose and ends (or returns to the thread pool) is less likely to interfere with other threads. Avoid creating daemon threads in modules that are packaged in applications deployed on WebLogic Server. When you create a daemon thread in an application module such as a Servlet, you will not be able to redeploy the application because the daemon thread created in the original deployment will remain running. Be sure to test multithreaded code under increasingly heavy loads, adding clients even to the point of failure. Observe the application performance and WebLogic Server behavior and then add checks to prevent failures from occurring in production.
For more information, see Timer and Work Manager for Application Servers and Using Work Managers to Optimize Scheduled Work.
13-3
T h rea di ng a nd C l us te ri ng T o p i c s
13-4
APPENDIX
The following sections describe Enterprise application deployment descriptors: application.xml (a Java EE standard deployment descriptor) and weblogic-application.xml (a WebLogic-specific application deployment descriptor). With Java EE annotations, the standard application.xml deployment descriptor is optional. Annotations simplify the application development process by allowing developers to specify within the Java class itself how the application component behaves in the container, requests for dependency injection, and so on. Annotations are an alternative to deployment descriptors that were required by older versions of Enterprise applications (J2EE 1.4 and earlier). See Chapter 7, Using Java EE Annotations and Dependency Injection. The weblogic-application.xml file is also optional if you are not using any WebLogic Server extensions. weblogic-application.xml Deployment Descriptor Elements on page A-1 weblogic-application.xml Schema on page A-45 application.xml Schema on page A-45
A-1
deployment descriptor from Sun Microsystems. This is where you configure features such as shared Java EE libraries referenced in the application and EJB caching. The file is located in the META-INF subdirectory of the application archive. The following sections describe elements that can appear in the file.
weblogic-application
The weblogic-application element is the root element of the application deployment descriptor. The following table describes the elements you can define within a weblogic-application element. Table A-1 weblogic-application Elements Element Required? Maximum Number In File
1
Description
<ejb>
Optional
Contains information that is specific to the EJB modules that are part of a WebLogic application. Currently, one can use the ejb element to specify one or more application level caches that can be used by the applications entity beans. For more information on the elements you can define within the ejb element, refer to ejb on page A-11.
<xml>
Optional
Contains information about parsers and entity mappings for XML processing that is specific to this application. For more information on the elements you can define within the xml element, refer to xml on page A-16.
<jdbc-conne ction-pool>
Optional
Unbounde d
Zero or more. Specifies an application-scoped JDBC connection pool. For more information on the elements you can define within the jdbc-connection-pool element, refer to jdbc-connection-pool on page A-18.
<security>
Optional
Specifies security information for the application. For more information on the elements you can define within the security element, refer to security on page A-33.
A-2
Description
<applicatio n-param>
Optional
Zero or more. Used to specify un-typed parameters that affect the behavior of container instances related to the application. The parameters listed here are currently supported. Also, these parameters in weblogic-application.xml can determine the default encoding to be used for requests and for responses. webapp.encoding.defaultCan be set to a string representing an encoding supported by the JDK. If set, this defines the default encoding used to process servlet requests and servlet responses. This setting is ignored if webapp.encoding.usevmdefault is set to true. This value is also overridden for request streams by the input-charset element of weblogic.xml. webapp.encoding.usevmdefaultCan be set to true or false. If true, the system property file.encoding is used to define the default encoding.
The following parameter is used to affect the behavior of Web applications that are contained in this application. webapp.getrealpath.accept_context_pa thThis is a compatibility switch that may be set to true or false. If set to true, the context path of Web applications is allowed in calls to the servlet API getRealPath.
Example:
<application-param> <param-name>webapp.encoding.default </param-name> <param-value>UTF8</param-value> </application-param>
For more information on the elements you can define within the application-param element, refer to application-param on page A-33. Developing Applications with WebLogic Server A-3
Description
Optional
A classloader-structure element allows you to define the organization of classloaders for this application. The declaration represents a tree structure that represents the classloader hierarchy and associates specific modules with particular nodes. A module's classes are loaded by the classloader that its associated with this element. Example:
<classloader-structure>
For more information on the elements you can define within the classloader-structure element, refer to classloader-structure on page A-34.
<listener>
Optional
Unbounde d
Zero or more. Used to register user defined application lifecycle listeners. These are classes that extend the abstract base class weblogic.application.ApplicationLifec ycleListener. For more information on the elements you can define within the listener element, refer to listener on page A-34.
A-4
Description
<startup>
Optional
Zero or more. Used to register user-defined startup classes. For more information on the elements you can define within the startup element, refer to startup on page A-35. Note: Application-scoped startup and shutdown classes have been deprecated as of release 9.0 of WebLogic Server. Instead, you should use lifecycle listener events in your applications. For details, see Chapter 10, Programming Application Lifecycle Events.
<shutdown>
Optional
Unbounde d
Zero or more. Used to register user defined shutdown classes. For more information on the elements you can define within the shutdown element, refer to shutdown on page A-36. Note: Application-scoped startup and shutdown classes have been deprecated as of release 9.0 of WebLogic Server. Instead, you should use lifecycle listener events in your applications. For details, see Chapter 10, Programming Application Lifecycle Events.
A-5
Description
<module>
Optional
Represents a single WebLogic application module, such as a JMS or JDBC module. This element has the following child elements:
nameThe name of the module. typeThe type of module. Valid values are JMS, JDBC, or Interception. pathThe path of the XML file that fully describes the module, relative to the root of the Enterprise application.
The following example shows how to specify a JMS module called Workflows, fully described by the XML file jms/Workflows-jms.xml: <module> <name>Workflows</name> <type>JMS</type> <path>jms/Workflows-jms.xml</path> </module>
<library-re f>
Optional
Unbounde d
A reference to a shared Java EE library. For more information on the elements you can define within the library element, refer to library-ref on page A-43. Specifies a fair share request class, which is a type of Work Manager request class. In particular, a fair share request class specifies the average percentage of thread-use time required to process requests. The <fair-share-request> element can take the following child elements:
nameThe name of the fair share request class. fair-shareAn integer representing the average percentage of thread-use time.
<fair-share -request>
Optional
Unbounde d
A-6
Description
Optional
Specifies a response time request class, which is a a type of Work manager class. In particular, a response time request class specifies a response time goal in milliseconds. The <response-time-request> element can take the following child elements:
nameThe name of the response time request class. goal-msThe integer response time goal.
Optional
Unbounde d
Specifies a context request class, which is a a type of Work manager class. In particular, a context request class assigns request classes to requests based on context information, such as the current user or the current user's group. The <context-request> element can take the following child elements:
nameThe name of the context request class. context-caseAn element that describes the context.
The <context-case> element can itself take the following child elements:
user-name or group-nameThe user or group to which the context applies. request-class-nameThe name of the request class.
A-7
Description
Optional
Specifies a max-threads-constraint Work Manager constraint. A Work Manager constraint defines minimum and maximum numbers of threads allocated to execute requests and the total number of requests that can be queued or executing before WebLogic Server begins rejecting requests. The max-threads constraint limits the number of concurrent threads executing requests from the constrained work set. The <max-threads-constraint> element can take the following child elements:
nameThe name of the max-thread-constaint constraint.
Either count or pool-nameThe integer maximum number of concurrent threads, or the name of a connection pool which determines the maximum.
A-8
Description
Optional
Specifies a min-threads-constraint Work Manager constraint. A Work Manager constraint defines minimum and maximum numbers of threads allocated to execute requests and the total number of requests that can be queued or executing before WebLogic Server begins rejecting requests. The min-threads constraint guarantees a number of threads the server will allocate to affected requests to avoid deadlocks. The <min-threads-constraint> element can take the following child elements:
nameThe name of the min-thread-constaint constraint. countThe integer minimum number of threads.
Optional
Unbounde d
Specifies a capacity Work Manager constraint. A Work Manager constraint defines minimum and maximum numbers of threads allocated to execute requests and the total number of requests that can be queued or executing before WebLogic Server begins rejecting requests. The capacity constraint causes the server to reject requests only when it has reached its capacity. The <capacity> element can take the following child elements:
nameThe name of the capacity constraint. countThe integer thread capacity.
A-9
Description
<work-manag er>
Optional
Specifies the Work Manager that is associated with the application. For more information on the elements you can define within the work-manager element, refer to work-manager on page A-36. See Using Work Managers to Optimize Scheduled Work for detailed information on Work Managers.
Optional
Unbounde d
Specifies the number of stuck threads needed to bring the application into administration mode. You can specify the following child elements:
max-stuck-thread-timeThe maximum amount of time, in seconds, that a thread should remain stuck. stuck-thread-countNumber of stuck threads that triggers the stuck thread work manager.
<session-de scriptor>
Optional
Unbounde d
Specifies a list of configuration parameters for servlet sessions. For more information on the elements you can define within the <session-descriptor> element, refer to session-descriptor on page A-39.
A-10
ejb
The following table describes the elements you can define within an ejb element.
A-11
Description
<entity-cache>
Optional
Zero or more. The entity-cache element is used to define a named application level cache that is used to cache entity EJB instances at runtime. Individual entity beans refer to the application-level cache that they must use, referring to the cache name. There is no restriction on the number of different entity beans that may reference an individual cache. Application-level caching is used by default whenever an entity bean does not specify its own cache in the weblogic-ejb-jar.xml descriptor. Two default caches named ExclusiveCache and MultiVersionCache are used for this purpose. An application may explicitly define these default caches to specify non-default values for their settings. Note that the caching-strategy cannot be changed for the default caches. By default, a cache uses max-beans-in-cache with a value of 1000 to specify its maximum size. Example:
<entity-cache> <entity-cache-name>ExclusiveCache</enti ty-cache-name> <max-cache-size> <megabytes>50</megabytes> </max-cache-size>
</entity-cache> For more information on the elements you can define within the entity-cache element, refer to entity-cache on page A-13.
A-12
Description
Optional
Allows you to configure the EJB container to start Message Driven BeanS (MDBS) with the application. If set to true, the container starts MDBS as part of the application. If set to false, the container keeps MDBS in a queue and the server starts them as soon as it has started listening on the ports.
entity-cache
The following table describes the elements you can define within a entity-cache element. Table A-3 entity-cache Elements Element Required? Maximum Number in File
1
Description
<entity-cachename>
Required
Specifies a unique name for an entity bean cache. The name must be unique within an ear file and may not be the empty string. Example:
<entity-cache-name>ExclusiveCache</enti ty-cache-name>
<max-beans-incache>
Optional If you specify this element, you cannot also specify <max-cac he-size>.
Specifies the maximum number of entity beans that are allowed in the cache. If the limit is reached, beans may be passivated. This mechanism does not take into account the actual amount of memory that different entity beans require. This element can be set to a value of 1 or greater. Default Value: 1000
A-13
Description
<max-cache-siz e>
Optional If you specify this element, you cannot also specify <max-bea ns-in-ca che>.
Used to specify a limit on the size of an entity cache in terms of memory sizeexpressed either in terms of bytes or megabytes. A bean provider should provide an estimate of the average size of a bean in the weblogic-ejb-jar.xml descriptor if the bean uses a cache that specifies its maximum size using the max-cache-size element. By default, a bean is assumed to have an average size of 100 bytes. For more information on the elements you can define within the ejb element, refer to max-cache-size on page A-15.
Optional
Specifies the maximum SQL queries that can be present in the entity cache at a given moment. Specifies the general strategy that the EJB container uses to manage entity bean instances in a particular application level cache. A cache buffers entity bean instances in memory and associates them with their primary key value. The caching-strategy element can only have one of the following values: ExclusiveCaches a single bean instance in memory for each primary key value. This unique instance is typically locked using the EJB containers exclusive locking when it is in use, so that only one transaction can use the instance at a time. MultiVersionCaches multiple bean instances in memory for a given primary key value. Each instance can be used by a different transaction concurrently.
Optional
A-14
max-cache-size
The following table describes the elements you can define within a max-cache-size element. Table A-4 max-cache-size Elements Element Required? Maximum Number in File
1
Description
<bytes>
You must specify either <bytes> or <megabyt es> You must specify either <bytes> or <megabyt es>
<megabytes>
A-15
xml
The following table describes the elements you can define within an xml element. Table A-5 xml Elements Element Required? Maximum Number in File
1
Description
<parser-factor y>
Optional
The parent element used to specify a particular XML parser or transformer for an enterprise application. For more information on the elements you can define within the parser-factory element, refer to parser-factory on page A-17.
<entity-mappin g>
Optional
Unbounded
Zero or More. Specifies the entity mapping. This mapping determines the alternative entity URI for a given public or system ID. The default place to look for this entity URI is the lib/xml/registry directory. For more information on the elements you can define within the entity-mapping element, refer to entity-mapping on page A-18.
A-16
parser-factory
The following table describes the elements you can define within a parser-factory element. Table A-6 parser-factory Elements Element Required? Maximum Number in File
1
Description
<saxparser-fac tory>
Optional
Allows you to set the SAXParser Factory for the XML parsing required in this application only. This element determines the factory to be used for SAX style parsing. If you do not specify the saxparser-factory element setting, the configured SAXParser Factory style in the Server XML Registry is used. Default Value: Server XML Registry setting
<document-buil der-factory>
Optional
Allows you to set the Document Builder Factory for the XML parsing required in this application only. This element determines the factory to be used for DOM style parsing. If you do not specify the document-builder-factory element setting, the configured DOM style in the Server XML Registry is used. Default Value: Server XML Registry setting
<transformer-f actory>
Optional
Allows you to set the Transformer Engine for the style sheet processing required in this application only. If you do not specify a value for this element, the value configured in the Server XML Registry is used. Default value: Server XML Registry setting.
A-17
entity-mapping
The following table describes the elements you can define within an entity-mapping element. Table A-7 entity-mapping Elements Element Required? Maximum Number in File
1 1 1 1 1
Description
Specifies the name for this entity mapping. Specifies the public ID of the mapped entity. Specifies the system ID of the mapped entity. Specifies the entity URI for the mapped entity. Legal values are:
Optional
jdbc-connection-pool
Note: The jdbc-connection-pool element is deprecated. To define a data source in your Enterprise application, you can package a JDBC module with the application. For more information, see Configuring JDBC Application Modules for Deployment in Configuring and Managing WebLogic JDBC. The following table describes the elements you can define within a jdbc-connection-pool element.
A-18
Description
Required
Specifies the JNDI name in the application-specific JNDI tree. Specifies the connection parameters that define overrides for default connection factory settings. user-nameOptional. The user-name element is used to override UserName in the JDBCDataSourceFactoryMBean. urlOptional. The url element is used to override URL in the JDBCDataSourceFactoryMBean. driver-class-nameOptional. The driver-class-name element is used to override DriverName in the JDBCDataSourceFactoryMBean. connection-paramsZero or more. parameter+ (param-value, param-name)One or more
Required
For more information on the elements you can define within the connection-factory element, refer to connection-factory on page A-20.
<pool-params>
Optional
Defines parameters that affect the behavior of the pool. For more information on the elements you can define within the pool-params element, refer to pool-params on page A-21.
<driver-param s>
Optional
Sets behavior on WebLogic Server drivers. For more information on the elements you can define within the driver-params element, refer to driver-params on page A-29.
<acl-name>
Optional
DEPRECATED.
A-19
connection-factory
The following table describes the elements you can define within a connection-factory element. Table A-9 connection-factory Elements Element Required? Maximum Number in File
1
Description
<factory-name>
Optional
Specifies the name of a JDBCDataSourceFactoryMBean in the config.xml file. Specifies the connection properties for the connection factory. Elements that can be defined for the connection-properties element are: user-nameOptional. Used to override UserName in the JDBCDataSourceFactoryMBean. passwordOptional. Used to override Password in the JDBCDataSourceFactoryMBean. urlOptional. Used to override URL in the JDBCDataSourceFactoryMBean. driver-class-nameOptional. Used to override DriverName in the JDBCDataSourceFactoryMBean connection-paramsZero or more. Used to set parameters which will be passed to the driver when making a connection. Example:
<connection-params> <parameter> <description>Desc of param </description> <param-name>foo</param-name> <param-value>xyz</param-value> </parameter> </connection-params>
<connection-pr operties>
Optional
A-20
pool-params
The following table describes the elements you can define within a pool-params element.
A-21
Description
<size-params>
Optional
Defines parameters that affect the number of connections in the pool. initial-capacityOptional. The initial-capacity element defines the number of physical database connections to create when the pool is initialized. The default value is 1. max-capacityOptional. The max-capacity element defines the maximum number of physical database connections that this pool can contain. Note that the JDBC Driver may impose further limits on this value. The default value is 1. capacity-incrementOptional. The capacity-increment element defines the increment by which the pool capacity is expanded. When there are no more available physical connections to service requests, the pool creates this number of additional physical database connections and adds them to the pool. The pool ensures that it does not exceed the maximum number of physical connections as set by max-capacity. The default value is 1. shrinking-enabledOptional. The shrinking-enabled element indicates whether or not the pool can shrink back to its initial-capacity when connections are detected to not be in use. shrink-period-minutesOptional. The shrink-period-minutes element defines the number of minutes to wait before shrinking a connection pool that has incrementally increased to meet demand. The shrinking-enabled element must be set to true for shrinking to take place. shrink-frequency-secondsOptional. highest-num-waitersOptional. highest-num-unavailableOptional.
A-22
Description
<xa-params>
Optional
A-23
Description
<xa-params> Continued...
Optional
prepared-statement-cache-size Deprecated. Optional. Use the prepared-statement-cache-size element to set the size of the prepared statement cache. The size of the cache is a number of prepared statements created from a particular connection and stored in the cache for further use. Setting the size of the prepared statement cache to 0 turns it off. Prepared-statement-cache-size is deprecated. Use cache-size in driver-params/prepared-statement. See driver-params for more information.
Note:
keep-logical-conn-open-on-release Optional. Boolean. Set the keep-logical-conn-open-on-release element to true, to keep the logical JDBC connection open when the physical XA connection is returned to the XA connection pool. The default value is false. local-transaction-supportedOptional. Boolean. Set the local-transaction-supported to true if the XA driver supports SQL with no global transaction; otherwise, set it to false. The default value is false. resource-health-monitoring-enabledOp tional. Set the resource-health-monitoring-enabled element to true to enable JTA resource health monitoring for this connection pool.
A-24
Description
<xa-params> Continued...
Optional
xa-transaction-timeoutOptional. When the xa-set-transaction-timeout value is set to true, the transaction manager invokes setTransactionTimeout on the resource before calling XAResource.start. The Transaction Manager passes the global transaction timeout value. If this attribute is set to a value greater than 0, then this value is used in place of the global transaction timeout. Default value: 0 Used in: xa-params Example: <xa-transaction-timeout> 30 </xa-transaction-timeout>
rollback-localtx-upon-connclose Optional.
When the rollback-localtx-upon-connclose element is true, the connection pool calls rollback() on the connection before putting it back in the pool. Default value: false Used in: xa-params Example: <rollback-localtx-upon-connclose> true </rollback-localtx-upon-connclose>
A-25
Description
<login-delay-s econds>
Optional
Sets the number of seconds to delay before creating each physical database connection. Some database servers cannot handle multiple requests for connections in rapid succession. This property allows you to build in a small delay to let the database server catch up. This delay occurs both during initial pool creation and during the lifetime of the pool whenever a physical database connection is created. Enables JDBC connection leak profiling. A connection leak occurs when a connection from the pool is not closed explicitly by calling the close() method on that connection. When connection leak profiling is active, the pool stores the stack trace at the time the connection object is allocated from the pool and given to the client. When a connection leak is detected (when the connection object is garbage collected), this stack trace is reported. This element uses extra resources and will likely slowdown connection pool operations, so it is not recommended for production use.
<leak-profilin g-enabled>
Optional
A-26
Description
<connection-ch eck-params>
Optional
Defines whether, when, and how connections in a pool is checked to make sure they are still alive. table-nameOptional. The table-name element defines a table in the schema that can be queried.
check-on-reserve-enabledOptional. If the check-on-reserve-enabled element is set to true, then the connection will be tested each time before it is handed out to a user.
check-on-release-enabledOptional. If the check-on-release-enabled element is set to true, then the connection will be tested each time a user returns a connection to the pool. refresh-minutesOptional. If the refresh-minutes element is defined, a trigger is fired periodically (based on the number of minutes specified). This trigger checks each connection in the pool to make sure it is still valid. check-on-create-enabledOptional. If set to true, then the connection will be tested when it is created. connection-reserve-timeout-secondsOp tional. Number of seconds after which the call to reserve a connection from the pool will timeout. connection-creation-retry-frequency-s econdsOptional. The frequency of retry attempts by the pool to establish connections to the database. inactive-connection-timeout-seconds Optional. The number of seconds of inactivity after which reserved connections will forcibly be released back into the pool.
A-27
Description
<connection-ch eck-params>
Optional
Continued...
test-frequency-secondsOptional. The number of seconds between database connection tests. After every test-frequency-seconds interval, unused database connections are tested using table-name. Connections that do not pass the test will be closed and reopened to re-establish a valid physical database connection. If table-name is not set, the test will not be performed.
init-sqlOptional. Specifies a SQL query that automatically runs when a connection is created.
Optional Optional
1 1
This is an internal setting. Controls whether a connection is removed from the pool when the application asks for the underlying vendor connection object. Enabling this attribute has an impact on performance; it essentially disables the pooling of connections (as connections are removed from the pool and replaced with new connections).
A-28
driver-params
The following table describes the elements you can define within a driver-params element.
A-29
Description
<statement>
Optional
Defines the driver-params statement. Contains the following optional element: profiling-enabled. Example: <statement> <profiling-enabled>true </profiling-enabled> </statement>
A-30
Description
<prepared-stat ement
Optional
Enables the running of JDBC prepared statement cache profiling. When enabled, prepared statement cache profiles are stored in external storage for further analysis. This is a resource-consuming feature, so it is recommended that you turn it off on a production server. The default value is false. profiling-enabledOptional. cache-profiling-thresholdOptional. The cache-profiling-threshold element defines a number of statement requests after which the state of the prepared statement cache is logged. This element minimizes the output volume. This is a resource-consuming feature, so it is recommended that you turn it off on a production server. cache-sizeOptional. The cache-size element returns the size of the prepared statement cache. The size of the cache is a number of prepared statements created from a particular connection and stored in the cache for further use. parameter-logging-enabledOptional. During SQL roundtrip profiling it is possible to store values of prepared statement parameters. The parameter-logging-enabled element enables the storing of statement parameters. This is a resource-consuming feature, so it is recommended that you turn it off on a production server. max-parameter-lengthOptional. During SQL roundtrip profiling it is possible to store values of prepared statement parameters. The max-parameter-length element defines maximum length of the string passed as a parameter for JDBC SQL roundtrip profiling. This is a resource-consuming feature, so you should limit the length of data for a parameter to reduce the output volume. cache-typeOptional.
A-31
Description
<row-prefetchenabled>
Optional
Specifies whether to enable row prefetching between a client and WebLogic Server for each ResultSet. When an external client accesses a database using JDBC through Weblogic Server, row prefetching improves performance by fetching multiple rows from the server to the client in one server access. WebLogic Server ignores this setting and does not use row prefetching when the client and WebLogic Server are in the same JVM
<row-prefetchsize>
Optional
Specifies the number of result set rows to prefetch for a client. The optimal value depends on the particulars of the query. In general, increasing this number increases performance, until a particular value is reached. At that point further increases do not result in any significant increase in performance. Note: Typically you will not see any increase in performance after 100 rows. The default value should be adequate for most situations.
Valid values for this element are between 2 and 65536. The default value is 48.
<stream-chunksize>
Optional
Specifies the data chunk size for streaming data types, which are pulled from WebLogic Server to the client as needed.
A-32
security
The following table describes the elements you can define within a security element. Table A-12 security Elements Element Required? Maximum Number in File
1
Description
<realm-name>
Optional
Names a security realm to be used by the application. If none is specified, the system default realm is used Declares a mapping between an application-wide security role and one or more WebLogic Server principals. Example:
<security-role-assignment> <role-name> PayrollAdmin </role-name> <principal-name> Tanya </principal-name> <principal-name> Fred </principal-name> <principal-name> system </principal-name> </security-role-assignment>
<security-role -assignment>
Optional
Unbounded
application-param
The following table describes the elements you can define within a application-param element.
A-33
Description
Provides a description of the application parameter. Defines the name of the application parameter. Defines the value of the application parameter.
classloader-structure
The following table describes the elements you can define within a classloader-structure element. Table A-14 classloader-structure Elements Element Required? Maximum Number in File
Unbounde d
Description
<module-ref>
Optional
The following list describes the elements you can define within a module-ref element: module-uriZero or more. Defined within the module-ref element.
<classloaderstructure>
Optional
Unbounde d
Allows for arbitrary nesting of classloader structures for an application. However, for this version of WebLogic Server, the depth is restricted to three levels.
listener
The following table describes the elements you can define within a listener element.
A-34
Description
Required
Name of the users implementation of ApplicationLifecycleListener. A JAR file within the EAR that contains the implementation. If you do not specify the listener-uri, it is assumed that the class is visible to the application. Specific a user identity to startup and shutdown application lifecycle events. The identity specified here should be a valid user name in the system. If run-as-principal-name is not specified, the deployment initiator user identity will be used as the run-as identity for the execution of the application lifecycle listener. Note: If the run-as-principal-name identity defined for the application lifecycle listener is an administrator, the application deployer must have administrator privileges; otherwise, deployment will fail.
Optional
<run-as-princ ipal-name>
Optional
startup
The following table describes the elements you can define within a startup element. WARNING: Application-scoped startup and shutdown classes have been deprecated as of release 9.0 of WebLogic Server. Instead, you should use lifecycle listener events in your applications. For details, see Chapter 10, Programming Application Lifecycle Events.
A-35
Description
Required
Defines the name of the class to be run when the application is being deployed. Defines a JAR file within the EAR that contains the startup-class. If startup-uri is not defined, then its assumed that the class is visible to the application.
Optional
shutdown
The following table describes the elements you can define within a shutdown element. WARNING: Application-scoped startup and shutdown classes have been deprecated as of release 9.0 of WebLogic Server. Instead, you should use lifecycle listener events in your applications. For details, see Chapter 10, Programming Application Lifecycle Events. Table A-17 shutdown Elements Element Required Optional
Required
Description
Defines the name of the class to be run when the application is undeployed. Defines a JAR file within the EAR that contains the shutdown-class. If you do not define the shutdown-uri element, it is assumed that the class is visible to the application.
Optional
work-manager
The following table describes the elements you can define within a work-manager element.
A-36
See Using Work Managers to Optimize Scheduled Work for examples and information on Work Managers. Table A-18 work-manager Elements Element Required? Maximum Number in File
1 1
Description
Required Optional
The name of the Work Manager. See the description of the <response-time-request> element in weblogic-application on page A-2 for information on this child element of <work-manager>. If you specify this element, you cannot also specify <fair-share-request-class>, <context-request-class>, or <request-class-name>.
<fair-share-r equest-class>
Optional
See the description of the <fair-share-request> element in weblogic-application on page A-2 for information on this child element of <work-manager>. If you specify this element, you cannot also specify <response-time-request-class>, <context-request-class>, or <request-class-name>.
<context-requ est-class>
Optional
See the description of the <context-request> element in weblogic-application on page A-2 for information on this child element of <work-manager>. If you specify this element, you cannot also specify <fair-share-request-class>, <response-time-request-class>, or <request-class-name>.
A-37
Description
<request-clas s-name>
Optional
The name of the request class. If you specify this element, you cannot also specify <fair-share-request-class>, <context-request-class>, or <response-time-request-class>.
<min-threadsconstraint>
Optional
See the description of the <min-threads-constraint> element in weblogic-application on page A-2 for information on this child element of <work-manager>. If you specify this element, you cannot also specify <min-threads-constaint-name>.
Optional
The name of the min-threads constraint. If you specify this element, you cannot also specify <min-threads-constaint>.
Optional
See the description of the <max-threads-constraint> element in weblogic-application on page A-2 for information on this child element of <work-manager>. If you specify this element, you cannot also specify <max-threads-constaint-name>.
Optional
The name of the max-threads constraint. If you specify this element, you cannot also specify <max-threads-constaint>.
Optional
See the description of the <capacity> element in weblogic-application on page A-2 for information on this child element of <work-manager>. If you specify this element, you cannot also specify <capacity-name>.
A-38
Description
<capacity-nam e>
Optional
The name of the thread capacity constraint. If you specify this element, you cannot also specify <capacity>.
Optional
Used to specify a Stuck Thread Work Manager component that can shut down the Work Manager in response to stuck threads. You can specify the following child elements:
max-stuck-thread-timeThe maximum amount of time, in seconds, that a thread should remain stuck. stuck-thread-countNumber of stuck threads that triggers the stuck thread work manager.
Optional
Specifies whether the Work Manager should ignore stuck threads and never shut down even if threads become stuck. If you specify this element, you cannot also specify <work-manager-shutdown-trigger>.
session-descriptor
The following table describes the elements you can define within a session-descriptor element.
A-39
Description
<timeout-secs >
Optional
Specifies the number of seconds after which the session times out. Default value is 3600 seconds. Note: The value of the session-timeout element (defined in minutes) in web.xml overrides the value of timeout-secs defined in both weblogic.xml and weblogic-application.xml. The value of timeout-secs in weblogic.xml overrides the value defined in weblogic-application.xml.
Optional
Specifies the number of seconds of the invalidation trigger interval. Default value is 60 seconds.
Optional
Specifies whether debugging is enabled for HTTP sessions. Default value is false.
<id-length>
Optional
<tracking-ena bled>
Optional
Specifies whether session tracking is enabled between HTTP requests. Default value is true.
<cache-size>
Optional
Specifies the cache size for JDBC and file persistent sessions. Default value is 1028.
<max-in-memor y-sessions>
Optional
Specifies the maximum sessions limit for memory/replicated sessions. Default value is -1, or unlimited.
A-40
Description
<cookies-enab led>
Optional
Specifies the Web application container should set cookies in the response. Default value is true.
<cookie-name>
Optional
Specifies the name of the cookie that tracks sessions. Default name is JSESSIONID.
<cookie-path>
Optional
Optional
Optional
Optional
Specifies whether the session tracking cookie is marked secure. Default value is false.
<cookie-max-a ge-secs>
Optional
Specifies that maximum age of the session tracking cookie. Default value is -1, or unlimited.
<persistent-s tore-type>
Optional
Specifies the type of storage for session persistence. You can specify the following values:
memoryDefault value. replicatedRequires clustering. replicated_if_clusteredDefaults to memory in non-clustered case. file jdbc cookie
A-41
Description
Optional
Specifies the name of the cookie that holds the attribute name and values when using cookie-based session persistence. Default value is WLCOOKIE.
<persistent-s tore-dir>
Optional
Specifies the name of the directory when using file-based session persistence. The directory is relative to the temporary directory defined for the Web application. Default value is session_db.
Optional
Specifies the name of the JDBC connection pool when using jdbc-based session persistence. Specifies the name of the database table when using jdbc-based session persistence. Default value is wl_servlet_sessions.
Optional
Optional
Alternative name for the wl_max_inactive_interval column name when using jdbc-based session persistence. Required for certain databases that do not support long column names DEPRECATED
Optional
Optional
A-42
Description
Optional
Specifies whether WebLogic Server adds the following HTTP header to the response: Cache-control: no-cache=set-cookie This header specifies that proxy caches should not cache the cookies. Default value is true, which means that the header is NOT added. Set this element to false if you want the header added to the response.
Optional
Specifies whether WebLogic Server should encode the session ID in the path parameters. Default value is false.
Optional
Used to tag runtime information for different sessions. For example, set this element to username if you have a username attribute that is guaranteed to be unique. Specifies whether HTTP sessions are shared across multiple Web applications. Default value is false.
<sharing-enab led>
Optional
library-ref
The following table describes the elements you can define within a library-ref element. See Chapter 9, Creating Shared Java EE Libraries and Optional Packages, for additional information and examples.
A-43
Description
<library-name>
Required
Specifies the name of the referenced shared Java EE library. Specifies the minimum specification-version required. Specifies the minimum implementation-version required. Specifies whether there must be an exact match between the specification and implementation version that is specified and that of the referenced library. Default value is false.
1 1 1
<context-root>
Optional
Specifies the context-root of the references Web Applications shared Java EE library.
library-context-root-override
The following table describes the elements you can define within a library-context-root-override element to override context-root elements within a referenced EAR library. See library-ref on page A-43. See Chapter 9, Creating Shared Java EE Libraries and Optional Packages, for additional information and examples.
A-44
Description
<library-conte xt-root>
Optional
Overrides the context-root elements declared in libraries. In the absence of this element, the librarys context-root is used. Only a referencing application (i.e., a user application) can override the context-root elements declared in its libraries.
<override-valu e>
Optional
Specifies the value of the library-context-root-override element when overriding the context-root elements declared in libraries. In the absence of these elements, the librarys context-root is used.
weblogic-application.xml Schema
See http://www.bea.com/ns/weblogic/100/weblogic-application.xsd for the XML Schema of the weblogic-application.xml deployment descriptor file.
application.xml Schema
For more information about application.xml deployment descriptor elements, see the JEE 5 schema available at http://java.sun.com/xml/ns/javaee/application_5.xsd.
A-45
A-46
APPENDIX B
The following sections describe tools for deploying applications and standalone modules to WebLogic Server: Overview of the wldeploy Ant Task on page B-1 Basic Steps for Using wldeploy on page B-2 Sample build.xml Files for wldeploy on page B-2 wldeploy Ant Task Attribute Reference on page B-4
B-1
wld e p l o y A nt T a s k R e f e re nc e
See Using Ant Tasks to Configure and Use a WebLogic Server Domain on page 2-1 for more information about wlserver and wlconfig. See Building Applications in a Split Development Directory on page 4-1 for information about wlcompile.
3. If necessary, add task definitions and calls to the wlserver and wlconfig tasks in the build script to create and start a new WebLogic Server domain. See Using Ant Tasks to Configure and Use a WebLogic Server Domain on page 2-1 for information about wlserver and wlconfig. 4. Add a call to wldeploy to deploy your application to one or more WebLogic Server instances or clusters. See Sample build.xml Files for wldeploy on page B-2 and wldeploy Ant Task Attribute Reference on page B-4. 5. Execute the Ant task or tasks specified in the build.xml file by typing ant in the staging directory, optionally passing the command a target argument:
prompt> ant
B-2
<target name="deploy"> <wldeploy action="deploy" verbose="true" debug="true" name="DeployExample" source="output/redeployEAR" user="weblogic" password="weblogic" adminurl="t3://localhost:7001" targets="myserver" /> </target>
The following example shows a corresponding task to undeploy the application; the example shows that when you undeploy or redeploy an application, you do not specify the source archive file or exploded directory, but rather, just its deployed name.:
<target name="undeploy"> <wldeploy action="undeploy" verbose="true" debug="true" name="DeployExample" user="weblogic" password="weblogic" adminurl="t3://localhost:7001" targets="myserver" failonerror="false" /> </target>
The following example shows how to perform a partial redeploy of the application; in this case, just a single WAR file in the application is redeployed:
<target name="redeploy_partial"> <wldeploy action="redeploy" verbose="true" name="DeployExample" user="weblogic" password="weblogic" adminurl="t3://localhost:7001" targets="myserver" deltaFiles="examples/general/redeploy/SimpleImpl.war" /> </target>
The following example uses the nested <files> child element of wldeploy to specify a particular file in the application that should be undeployed:
<target name="undeploy_partial"> <wldeploy action="undeploy" verbose="true" debug="true" name="DeployExample" user="weblogic" password="weblogic"
B-3
wld e p l o y A nt T a s k R e f e re nc e
The following example shows how to deploy a Java EE library called myLibrary whose source files are located in the output/myLibrary directory:
<target name="deploy"> <wldeploy action="deploy" name="myLibrary" source="output/myLibrary" library="true" user="weblogic" password="weblogic" verbose="true" adminurl="t3://localhost:7001" targets="myserver" /> </target>
Main Attributes
The following table describes the main attributes of the wldeploy Ant task. These attributes mirror some of the arguments of the weblogic.Deployer command. BEA provides an Ant task version of the weblogic.Deployer command so that developers can easily deploy and test their applications as part of the iterative development process. Typically, however, administrators use the weblogic.Deployer command, and not the wldeploy Ant task, to deploy applications in a production environment. For that reason, see the weblogic.Deployer Command-Line Reference in Deploying Applications to WebLogic Server for
B-4
w l dep l o y An t T as k A tt r i bu te R e f e r e n c e
the full and complete definition of the attributes of the wldeploy Ant task. The table below is provided just as a quick summary. Table B-1 Attributes of the wldeploy Ant Task Attribute
action
Description
The deployment action to perform. Valid values are deploy, cancel, undeploy, redeploy, distribute, start, and stop.
Data Type
String
adminmode
Specifies that the deployment action puts the application into Administration mode. Administration mode restricts access to an application to a configured Administration channel. Valid values for this attribute are true and false. Default value is false, which means that by default the application is deployed in production mode so that all clients can access it immediately.
Boolean
adminurl
The URL of the Administration Server. The format of the value of this attribute is protocol://host:port, where protocol is either http or t3, host is the host on which the Administration Server is running, and port is the port which the Administration Server is listening. Note: In order to use the HTTP protocol, you must enable the http tunnelling option in the Administration Console.
String
allversions
Specifies that the action (redeploy, stop, and so on) applies to all versions of the application. Valid values for this attribute are true and false. The default value is false.
Boolean
altappdd
Specifies the name of an alternate Java EE deployment descriptor (application.xml) to use for deployment. If you do not specify this attribute, and you are deploying an Enterprise application, the default deployment descriptor is called application.xml and is located in the META-INF subdirectory of the main application directory or archive (specified by the source attribute.)
String
B-5
wld e p l o y A nt T a s k R e f e re nc e
Description
Specifies the name of an alternate WebLogic Server deployment descriptor (weblogic-application.xml) to use for deployment. If you do not specify this attribute, and you are deploying an Enterprise application, the default deployment descriptor is called weblogic-application.xml and is located in the META-INF subdirectory of the main application directory or archive (specified by the source attribute.)
Data Type
String
The version identifier of the deployed application. Enable wldeploy debugging messages. Specifies whether to remove static files from a server's staging directory. This attribute is valid only for unarchived deployments, and only for applications deployed using stage mode. You must specify target servers when using this attribute. Specifying the deleteFiles attributes indicates that WebLogic Server should remove only thos files that it copied to the staging area during deployment. This attribute can be used only in combination with action="redeploy". Because the deleteFiles attribute deletes all specified files, BEA recommends that you use caution when using the deleteFiles attribute and that you do not use it in production environments. Valid values for this attribute are true and false. Default value is false.
deltaFiles
Specifies a comma- or space-separated list of files, relative to the root directory of the application, which are to be redeployed. Use this attribute only in conjunction with action="redeploy" to perform a partial redeploy of an application.
String
enableSecurityValid ation
Specifies whether or not to enable validation of security data. Valid values for this attribute are true and false. Default value is false.
Boolean
B-6
w l dep l o y An t T as k A tt r i bu te R e f e r e n c e
Description
Specifies whether the deployment uses external_stage deployment mode. In this mode, the Ant task does not copy the deployment files to target servers; instead, you must ensure that deployment files have been copied to the correct subdirectory in the target servers' staging directories. You can specify only one of the following attributes: stage, nostage, or external_stage. If none is specified, the default deployment mode to Managed Servers is stage; the default mode to the Administration Server and in single-server cases is nostage. See Controlling Deployment File Copying with Staging Modes.
Data Type
Boolean
failonerror
This is a global attribute used by WebLogic Server Ant tasks. It specifies whether the task should fail if it encounters an error during the build. Valid values for this attribute are true and false. Default value is true.
Boolean
graceful
Stops the application after existing HTTP clients have completed their work. You can use this attribute only when stopping or undeploying an application, or in other words, you must also specify either the action="stop" or action="undeploy" attributes. Valid values for this attribute are true and false. Default value is false.
Boolean
id
Identification used for obtaining status or cancelling the deployment. You assign a unique ID to an application when you deploy it, and then subsequently use the ID when redeploying, undeploying, stopping, and so on. If you do not specify this attribute, the Ant task assigns a unique ID to the application.
String
ignoresessions
This option immediately places the application into Administration mode without waiting for current HTTP sessions to complete. You can use this attribute only when stopping or undeploying an application, or in other words, you must also specify either the action="stop" or action="undeploy" attributes. Valid values for this attribute are true and false. Default value is false.
Boolean
B-7
wld e p l o y A nt T a s k R e f e re nc e
Description
Specifies the implementation version of a Java EE library or optional package. This attribute can be used only if the library or package does not include a implementation version in its manifest file. You can specify this attribute only in combination with the library attribute. See Creating Shared Java EE Libraries and Optional Packages on page 9-1.
Data Type
String
library
Identifies the deployment as a shared Java EE library or optional package. You must specify the library attribute when deploying or distributing any Java EE library or optional package. Valid values for this attribute are true and false. Default value is false. See Creating Shared Java EE Libraries and Optional Packages on page 9-1.
Boolean
libSpecVer
Provides the specification version of a Java EE library or optional package. This attribute can be used only if the library or package does not include a specification version in its manifest file. You can specify this attribute only in combination with the library attribute. See Creating Shared Java EE Libraries and Optional Packages on page 9-1.
String
name
The deployment name for the deployed application. If you do not specify this attribute, WebLogic Server assigns a deployment name to the application, based on its archive file or exploded directory.
String
nostage
Specifies whether the deployment uses nostage deployment mode. In this mode, the Ant task does not copy the deployment files to target servers, but leaves them in a fixed location, specified by the source attribute. Target servers access the same copy of the deployment files. You can specify only one of the following attributes: stage, nostage, or external_stage. If none is specified, the default deployment mode to Managed Servers is stage; the default mode to the Administration Server and in single-server cases is nostage. See Controlling Deployment File Copying with Staging Modes.
Boolean
B-8
w l dep l o y An t T as k A tt r i bu te R e f e r e n c e
Description
Indicates that the wldeploy Ant task should ignore all version related code paths on the Administration Server. This behavior is useful when deployment source files are located on Managed Servers (not the Administration Server) and you want to use the external_stage staging mode. If you use this option, you cannot use versioned applications. Valid values for this attribute are true and false. Default value is false.
Data Type
Boolean
nowait
Specifies whether wldeploy returns immediately after making a deployment call (by deploying as a background task). The administrative password. To avoid having the plain text password appear in the build file or in process utilities such as ps, first store a valid username and encrypted password in a configuration file using the WebLogic Scripting Tool (WLST) storeUserConfig command. Then omit both the username and password attributes in your Ant build file. When the attributes are omitted, wldeploy attempts to login using values obtained from the default configuration file. If you want to obtain a username and password from a non-default configuration file and key file, use the userconfigfile and userkeyfile attributes with wldeploy. See the command reference for storeUserConfig in the WLST Command and Variable Reference for more information on storing and encrypting passwords.
Boolean
password
String
plan
Specifies a deployment plan to use when deploying the application or module. By default, wldeploy does not use an available deployment plan, even if you are deploying from an application root directory that contains a plan.
String
planversion remote
The version identifier of the deployment plan. Specifies whether the server is located on a different machine. This affects how filenames are transmitted. Valid values for this attribute are true and false. Default value is false, which means that the Ant task assumes that all source paths are valid paths on the local machine.
String Boolean
B-9
wld e p l o y A nt T a s k R e f e re nc e
Description
Specifies the number of seconds before WebLogic Server undeploys the currently-running version of this application or module so that clients can start using the new version. It is assumed, when you specify this attribute, that you are starting, deploying, or redeploying a new version of an already-running application. See Updating Applications in a Production Environment.
Data Type
int
securityModel
Specifies the security model to use for this deployment. Possible security models are: Deployment descriptors only Customize roles Customize roles and policies Security realm configuration (advanced model)
String
Valid actual values for this attribute are DDOnly, CustomRoles, CustomRolesAndPolicy, or Advanced. See Options for Securing Web Application and EJB Resources for more information on these security models source stage The archive file or exploded directory to deploy. Specifies whether the deployment uses stage deployment mode. In this mode, the Ant task copies deployment files to target servers' staging directories. You can specify only one of the following attributes: stage, nostage, or external_stage. If none is specified, the default deployment mode to Managed Servers is stage; the default mode to the Administration Server and in single-server cases is nostage. See Controlling Deployment File Copying with Staging Modes. submoduletargets Specifies JMS server targets for resources defined within a JMS application module. The value of this attribute is a comma-separated list of JMS server names. See the Using Sub-Module Targeting with JMS Application Modules. String File Boolean
B-10
w l dep l o y An t T as k A tt r i bu te R e f e r e n c e
Description
The list of target servers to which the application is deployed. The value of this attribute is a comma-separated list of the target servers, clusters, or virtual hosts. If you do not specify a target list when deploying an application, the target defaults to the Administration Server instance.
Data Type
String
timeout upload
The maximum number of seconds to wait for a deployment to succeed. Specifies whether the source file(s) are copied to the Administration Servers upload directory prior to deployment. Use this attribute when you are on a remote machine and you cannot copy the deployment files to the Administration Server by other means. Valid values for this attribute are true and false. Default value is false.
int Boolean
usenonexclusivelock
Specifies that the deployment action (deploy, redeploy, stop, and so on) uses the existing lock on the domain that has already been acquired by the same user performing the action. This attribute is particularly useful when the user is using multiple deployment tools (Ant task, command line, Administration console, and so on) simultaneously and one of the tools has already acquired a lock on the domain. Valid values for this attribute are true and false. Default value is false.
Boolean
user userconfigfile
The administrative username. Specifies the location of a user configuration file to use for obtaining the administrative username and password. Use this option, instead of the user and password attributes, in your build file when you do not want to have the plain text password shown in-line or in process-level utilities such as ps. Before specifying the userconfigfile attribute, you must first generate the file using using the WebLogic Scripting Tool (WLST) storeUserConfig command as described in the WLST Command and Variable Reference.
String String
B-11
wld e p l o y A nt T a s k R e f e re nc e
Description
Specifies the location of a user key file to use for encrypting and decrypting the username and password information stored in a user configuration file (the userconfigfile attribute). Before specifying the userkeyfile attribute, you must first generate the key file using the WebLogic Scripting Tool (WLST) storeUserConfig command as described in the WLST Command and Variable Reference.
Data Type
String
verbose
Boolean
B-12
APPENDIX C
The following sections describe developing and managing Spring Framework-based applications for WebLogic Server. In most cases, the information in these sections is described from the perspective of creating MedRec-Spring. About Spring on WebLogic Server on page C-1 Redesigning a J2EE-Based Application to a Spring-Based Application on page C-2 Spring Extension to the WebLogic Administration Console on page C-10
C-1
Documentation. For information about Spring on the BEA dev2dev Web site, see Spring Resource Page. For information on the Spring Framework in general, see http://www.springframework.org/.
C-2
</bean>
Then, in the application code, BEA defined setter methods for the corresponding bean. For example:
protected MedRecClientServiceFacade medRecClientServiceFacade; public void setMedRecClientServiceFacade( MedRecClientServiceFacade pMedRecClientServiceFacade){ this.medRecClientServiceFacade = pMedRecClientServiceFacade; }
C-3
</property> </bean> <> <!-- allows the jaxRpcService class to execute its constructor which loads in type mappings --> <bean id="generatedReliableService" class="com.bea.physician.webservices.client.PhysicianWebServices_Impl"> </bean>
In this code example, note that: The serviceInterface represents Web Services operations. The customProperties property allows for custom WebLogic Server Web Service stub properties. The jaxRpcService value is set to WebLogic Servers generated JAX-RPC implementation service.
C-4
<bean id="uploadJmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory"> <ref bean="jmsConnFactory"/> </property> <property name="defaultDestination"> <ref bean="uploadQueue"/> </property> </bean>
Configure JMX: Expose the WebLogic Server Runtime MBean Server Connection to Spring
You can expose WebLogic Servers MBean Server to Spring through Springs MBeanServerConnectionFactoryBean, which is a convenience factory that produces an MBeanServerConnection that is established and cached during application deployment and can later be operated on by referencing beans. The MBeanServerConnectionFactoryBean can be configured to return the WebLogic Server Runtime MBean Server, and to obtain a connection to the WebLogic Server Domain Runtime MBean Server and the WebLogic Server Edit MBean Server. Note: Because the WebLogic Server Domain Runtime MBean Server is not active during deployment, you must configure the MBeanServerConnectionFactoryBean to use Springs lazy instantiation. Lazy instantiation fetches the Spring Bean when it is invoked. Exposing the WebLogic Server Runtime MBean Server Connection to Spring is demonstrated in the following code example, which, in MedRec-Spring, BEA implemented in the Spring configuration file medrecEar/APP-INF/classes/applicationContext-jmx.xml.
<>
C-5
<property name="environment"> <props> <prop key="java.naming.security.principal">${WS_USERNAME}</prop> <prop key="java.naming.security.credentials">${WS_USERNAME}</prop> <prop key="jmx.remote.protocol.provider.pkgs">weblogic.management.remote</prop> </props> </property> </bean>
See also the following code examples, which, for MecRec-Spring, BEA implemented in the Spring configuration files src\medrecEar\APP-INF\classes\applicationContext-db.xml and src\medrecEar\APP-INF\classes\applicationContext-jdbc.xml, respectively.
applicationContext-db.xml code example: <!-- datasource pool --> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="jdbc/MedRecGlobalDataSourceXA"/> </bean> applicationContext-jdbc.xml code example: <bean id="patientDao" class="com.bea.medrec.dao.jdbc.JdbcPointBasePatientDao" autowire="byType"/>
C-6
Additionally, in MedRec-Spring, BEA replaced entity EJBs with POJOs and made use of Spring JDBC for persistence. For an example, see the MedRec-Spring class
\src\medrecEar\core\com\bea\medrec\domain\Address.java
C-7
<prop key="compose*">PROPAGATION_REQUIRED</prop> <prop key="deny*">PROPAGATION_REQUIRED</prop> <prop key="getRecord*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="getPatient*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="getLog*">PROPAGATION_NOT_SUPPORTED</prop> <prop key="process*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="send*">PROPAGATION_REQUIRED</prop> </props> </property> < /bean> <!-- single point of service for all medrec clients --> <bean id="medRecClientServiceFacade" parent="baseTransactionProxy"> <property name="target"> <bean class="com.bea.medrec.service.MedRecClientServiceFacadeImpl"> <property name="adminService"> <ref bean="adminService"/> </property> <property name="patientService"> <ref bean="patientService"/> </property> <property name="recordService"> <ref bean="recordService"/> </property> <property name="recordXmlProcessorService"> <ref bean="recordXmlProcessorService"/> </property> </bean> </property> </bean>
The transactionAttributes you specify define the way in which Spring begins and ends transactions. Because MedRec-Spring delegates transaction management to WebLogic JTA, management tasks such as transaction suspension and rollback are handled as specified by WebLogics transaction manager.
C-8
For more information on WebLogicJtaTransactionManager, see Implementing Transaction Suspension in Spring at http://dev2dev.bea.com/pub/a/2005/07/spring_transactions.html.
C-9
C-10