The following sections provide an overview of WebLogic Server® applications and basic concepts.
This document is written for application developers who want to build WebLogic Server e-commerce applications using the Java Platform, Enterprise Edition 5 from Sun Microsystems. It is assumed that readers know Web technologies, object-oriented programming techniques, and the Java programming language.
WebLogic Server applications are created by Java programmers, Web designers, and application assemblers. Programmers and designers create modules that implement the business and presentation logic for the application. Application assemblers assemble the modules into applications that are ready to deploy on WebLogic Server.
WebLogic Server implementstechnologies. Java EE is the standard platform for developing multi-tier Enterprise applications based on the Java programming language. The technologies that make up Java EE were developed collaboratively by Sun Microsystems and other software vendors, including BEA Systems.
An important aspect of the Java EE programming model is the introduction of metadata annotations. Annotations simplify the application development process by allowing a developer 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).
According to Sun, “the focus in Java EE 5 is ease of development. With Java EE 5, there is less code to write – much of the boilerplate code has been removed, defaults are used whenever possible, and annotations are used extensively to reduce the need for deployment descriptors.”
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 server—only 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:
A BEA WebLogic Server™ Java EE application consists of one of the following modules or applications running on WebLogic Server:
A WebLogic application can also include the following WebLogic-specific modules:
A Web application on WebLogic Server includes the following files:
web.xmldeployment descriptor, a Java EE standard XML document that describes the contents of a WAR file.
weblogic.xmldeployment descriptor, an XML document containing WebLogic Server-specific elements for Web applications.
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 (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.
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.
See the following documentation:
Enterprise JavaBeans (EJBs) beans are server-side Java modules that implement a business task or entity and are written according to the EJB specification. There are three types of EJBs: session beans, entity beans, and message-driven beans.
Enterprise JavaBeans (EJB) 3.0 is a Java EE 5 technology for the development and deployment of component-based business applications. Although EJB 2.X and previous is a powerful and useful technology, the programming model was complex and confusing, requiring the creation of multiple Java files and deployment descriptors for even the simplest of EJB. This complexity hindered the wide adoption of EJBs.
Therefore, one of the central goals of version 3.0 of the EJB specification is to make it easier to program an EJB, in particular by reducing the number of required programming artifacts and introducing a set of EJB-specific metadata annotations that make programming the bean file easier and more intuitive. Another goal of the EJB 3.0 specification was to standardize the persistence framework and reduce the complexity of the entity bean programming model and object-relational (O/R) mapping model.
For more information on Enterprise JavaBeans 3.0, see.
For more information on Enterprise JavaBeans 2.X, see.
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. Persistence—loading and saving data—can be bean-managed or container-managed. More than 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.
Java EE cleanly separates the development and deployment roles to ensure that modules are portable between EJB servers that support the EJB specification. Deploying an EJB in WebLogic Server requires running the WebLogic Server
appc compiler to generate classes that enforce the EJB security, transaction, and life cycle policies. See Building Modules and Applications Using wlappc.
The Java EE-specified deployment descriptor,
ejb-jar.xml, describes the enterprise beans packaged in an EJB application. It defines the beans’ types, names, and the names of their home and remote interfaces and implementation classes. The
ejb-jar.xml deployment descriptor defines security roles for the beans, and transactional behaviors for the beans’ methods.
Additional deployment descriptors provide WebLogic-specific deployment information. A
weblogic-cmp-rdbms-jar.xml deployment descriptor unique to container-managed entity beans maps a bean to tables in a database. The
weblogic-ejb-jar.xml deployment descriptor supplies additional information specific to the WebLogic Server environment, such as JNDI bind names, clustering, and cache configuration.
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 directory. Resource adapters can be deployed to WebLogic Server as stand-alone modules or as part of an Enterprise application. See Enterprise Applications.
For more information on connectors, see Programming WebLogic Resource Adapters.
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.
An important aspect of the Java EE programming model is the introduction of metadata annotations. Annotations simplify the application development process by allowing a developer to specify within the Java class itself how the application 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 (1.4 and earlier).
With Java EE annotations, the standard
web.xml deployment descriptors are optional. The Java EE programming model uses the feature for Web containers, such as EJBs, servlets, Web applications, and JSPs. See Using Java EE Annotations and Dependency Injection.
If the application includes WebLogic Server-specific extensions, the application is further defined by a weblogic-application.xml file. Enterprise Applications that include a client module will also have a client-application.xml deployment descriptor and a WebLogic run-time client application deployment descriptor. See Enterprise Application Deployment Descriptor Elements.
For both production and development purposes, BEA recommends that you package and deploy even stand-alone Web applications, EJBs, and resource adapters as part of an Enterprise application. Doing so allows you to take advantage of BEA’s new split development directory structure, which greatly facilities application development. See Creating a Split Development Directory Environment.
An Enterprise application consists of Web application modules, EJB modules, and resource adapters. It can be packaged as follows:
.earextension. 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.
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 Enterprise Application Deployment Descriptor Elements.
Web services can be shared by and used as modules of distributed Web-based applications. They commonly interface with existing back-end applications, such as customer relationship management systems, order-processing systems, and so on. Web services can reside on different computers and can be implemented by vastly different technologies, but they are packaged and transported using standard Web protocols, such as HTTP, thus making them easily accessible by any user on the Web. See Programming Web Services for WebLogic Server.
A Web service consists of the following modules:
JMS and JDBC configurations are stored as modules, defined by an XML file that conforms to the
weblogic-jdbc.xsd schema, respectively. These modules are similar to standard Java EE modules. An administrator can create and manage JMS and JDBC modules as global system resources, as modules packaged with a Java EE application (as a packaged resource), or as standalone modules that can be made globally available.
With modular deployment of JMS and JDBC resources, you can migrate your application and the required JMS or JDBC configuration from environment to environment, such as from a testing environment to a production environment, without opening an enterprise application file (such as an EAR file) or a JMS or JDBC standalone module, and without extensive manual JMS or JDBC reconfiguration.
Application developers create application modules in an enterprise-level IDE or another development tool that supports editing of XML files, then package the JMS or JDBC modules with an application and pass the application to a WebLogic Administrator to deploy.
For more information, see:
The WebLogic Diagnostic Framework (WLDF) provides features for generating, gathering, analyzing, and persisting diagnostic data from BEA WebLogic Server instances and from applications deployed to server instances. For server-scoped diagnostics, some WLDF features are configured as part of the configuration for the domain. Other features are configured as system resource descriptors that can be targeted to servers (or clusters). For application-scoped diagnostics, diagnostic features are configured as resource descriptors for the application.
Application-scoped instrumentation is configured and deployed as a diagnostic module, which is similar to a diagnostic system module. However, an application module is configured in an XML configuration file named
weblogic-diagnostics.xml which is packaged with the application archive.
For detailed instructions for configuring instrumentation for applications, see.
A deployment configuration refers to the process of defining the deployment descriptor values required to deploy an Enterprise application to a particular WebLogic Server domain. The deployment configuration for an application or module is stored in three types of XML document: Java EE deployment descriptors, WebLogic Server descriptors, and WebLogic Server deployment plans. This section describes the Java EE and WebLogic-specific deployment descriptors. See Deployment Plans for information on deployment plans.
The Java EE programming model uses thefeature for Web containers, such as EJBs, servlets, Web applications, and JSPs. Annotations simplify the application development process by allowing a developer to specify within the Java class itself how the 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 Web Applications (2.4 and earlier), Enterprise applications, and (1.4 and earlier), and Enterprise JavaBeans (2.x and earlier). See Using Java EE Annotations and Dependency Injection.
However, Enterprise applications fully support the use of deployment descriptors, even though the standard J2EE ones are not required. For example, you may prefer to use the old EJB 2.x programming model, or might want to allow further customizing of the EJB at a later development or deployment stage; in these cases you can create the standard deployment descriptors in addition to, or instead of, the metadata annotations.
Modules and applications have deployment descriptors—XML documents—that 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
schema, which describes common elements shared among all WebLogic-specific deployment descriptors.
When you package a module or application, you create a directory to hold the deployment descriptors—
META-INF—and then create the XML deployment descriptors in that directory.
WebLogic Server provides a variety of tools for automatically generating deployment descriptors. These are discussed in the sections that follow.
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 Programming WebLogic Enterprise JavaBeansin
WebLogic Server includes a set of Java-based command-line utilities that automatically generate both standard Java EE and WebLogic-specific deployment descriptors for Web applications and Enterprise Applications.
These command-line utilities examine the classes you have assembled in a staging directory and build the appropriate deployment descriptors based on the servlet classes, and so on. These utilities include:
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
weblogic.xml deployment descriptors. To automatically generate them, execute the following command:
prompt> java weblogic.marathon.ddinit.WebInit c:\stage
The utility generates the
weblogic.xml deployment descriptors and places them in the
WEB-INF directory, which
DDInit will create if it does not already exist.
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.
weblogic.DDConverter with the following command:
prompt> java weblogic.DDConverter [
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.
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
A deployment plan is an XML document that defines an application’s WebLogic Server deployment configuration for a specific WebLogic Server environment. A deployment plan resides outside of an application’s archive file, and can apply changes to deployment properties stored in the application’s existing WebLogic Server deployment descriptors. Administrators use deployment plans to easily change an application’s 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 application’s deployment configuration:
weblogic.PlanGeneratorcreates 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.
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:
This section reviews required and optional tools for developing WebLogic Server applications.
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
\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:|
|Note:||To view the documentation for a specific version of Ant, such as the version included with WebLogic Server, download the Ant zip file fromand 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
Also refer to the following WebLogic Server documentation on building examples using Ant:
You can use your own version of Ant if the one bundled with WebLogic Server is not adequate for your purposes. To determine the version of Ant that is bundled with WebLogic Server, run the following command after setting your WebLogic environment:
prompt> ant -version
If you plan to use a different version of Ant, you can replace the appropriate JAR file in the
\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.
By default the environment script allocates a heap size of 128 megabytes to Ant. You can increase or decrease this value for your own projects by setting the
-X option in your local
ANT_OPTS environment variable. For example:
prompt> setenv ANT_OPTS=-Xmx128m
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
/server/bin for examples of using the
You need a text editor to edit Java source files, configuration files, HTML or XML pages, and JavaServer Pages. An editor that gracefully handles Windows and UNIX line-ending differences is preferred, but there are no other special requirements for your editor. You can edit HTML or XML pages and JavaServer Pages with a plain text editor, or use a Web page editor such as DreamWeaver. For XML pages, you can also use an enterprise-level IDE with DTD validation or another development tool that supports editing of XML files.
Nearly all WebLogic Server applications require a database system. You can use any DBMS that you can access with a standard JDBC driver, but services such as WebLogic Java Message Service (JMS) require a supported JDBC driver for Oracle, Sybase, Informix, Microsoft SQL Server, IBM DB2, or PointBase. Refer to Supported Configurations to find out about supported database systems and JDBC drivers.
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.
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.
|Note:||Check with the software vendor to verify software compatibility with your platform and WebLogic Server version.|