|
|
|
|
|
| | | |
Migrating WebLogic Server 4.5 and 5.1 Applications to 6.x
The weblogic.properties File and .xml Files
Earlier releases of WebLogic Server used a weblogic.properties file to configure applications. In WebLogic Server 6.0 and 6.1, configuration of applications is handled through XML descriptor files and the Administration Console. Converting a weblogic.properties file from an earlier version of WebLogic Server creates a new domain for your applications and adds .xml files that define how your applications are set up.
The config.xml file is an XML document that describes the configuration of an entire Weblogic Server domain. The config.xml file consists of a series of XML elements. The Domain element is the top-level element, and all elements in the Domain are children of the Domain element. The Domain element includes child elements, such as the Server, Cluster, and Application elements. These child elements may have children themselves. Each element has one or more configurable attributes. An attribute defined in config.dtd has a corresponding attribute in the configuration API.
The weblogic.xml file contains WebLogic-specific attributes for a Web application. You define the following attributes in this file: HTTP session parameters, HTTP cookie parameters, JSP parameters, resource references, security role assignments, character set mappings, and container attributes.
The deployment descriptor web.xml is defined by the servlet 2.3 specification from Sun Microsystems. This deployment descriptor can be used to deploy a Web Application on any J2EE-compliant application server.
WebLogic Server 6.x Application Types
Applications on J2EE-compliant servers such as WebLogic Server 6.0 and 6.1 are created and deployed as one of the following four types: Web Applications, Enterprise JavaBeans, Enterprise Archives, and Client Applications. To migrate your existing components to WebLogic Server 6.1, you create the appropriate J2EE deployment units. Web Applications are usually a collection of servlets, JSPs, and HTML files, packaged as .war files. Enterprise JavaBeans (packaged as.jar files) are server-side Java components written according to the EJB specification. Enterprise Archives (.ear files) can contain a combination of EJB components and Web Application components. Client Applications are Java classes that connect to WebLogic Server using Remote Method Invocation (RMI). Each of the aforementioned J2EE deployment units are discussed in greater detail in the following sections.
Migration Main Steps
The following steps outline the general migration procedure. Later sections describe these steps in more detail as they apply to particular types of applications. Also see the Migration Tutorial on BEA dev2dev.
Converting the weblogic.properties File to .xml files
Note: In order for the conversion to work properly, you need to specify the following in your weblogic.properties file:
weblogic.password.system=gumby1234
Convert your weblogic.properties file to the appropriate .xml files by following these steps:
The process of converting your weblogic.properties file creates the config.xml file in the wlserver6.1/config/domainName directory. This file contains configuration information specific to your domain. It creates the web application in the wlserver6.1/config/domainName/production_apps/DefaultWebApp_serverName/ directory. The web.xml and weblogic.xml files for the web application are placed inside the wlserver6.1/config/domainName/production_apps/DefaultWebApp_serverName/WEB-INF/ directory.
Note: The conversion utility described above specifies the Java home location in the weblogic.xml file. It reads this location using the System.getProperty(java.home), which means that it will specify the Java home location on which WebLogic Server was started for the conversion.
Throughout this document, the directory of the new domain that has been created is referred to as domainName. The default domain that is provided with the original installation of WebLogic Server 6.1 is called mydomain and is located in the wlserver6.1/config/ directory.
The startup scripts, which are generated when a weblogic.properties file is converted, are named startdomainName.cmd (for Windows users) and startdomainName.sh (for UNIX users) and exist under the WL6x_HOME/config/domainName directory in your WebLogic Server 6.x distribution. These scripts will start the server in the new domain.
See Starting and Stopping the WebLogic Server for more information on scripts and starting servers.
weblogic.properties Mapping Table
The weblogic.properties mapping table shows which config.xml, web.xml, or weblogic.xml attribute handles the function formerly performed by weblogic.properties properties. If the attribute can be configured in the Administration Console, the table shows the navigation path to the attribute.
In order to migrate applications into a Web Application deployed on WebLogic Server 6.0 or 6.1, the applications' files must be placed within a directory structure that follows a specific pattern. For development, these files can be left in an exploded directory format. However, for production situations, it is highly recommended that you bundle your applications into a .war file as a single Web Application. For more information on Web Applications see Understanding WebLogic Server Applications and Assembling and Configuring Web Applications.
The following sections provide information you need to know about migrating and deploying Web Applications, including a procedure for migrating a simple servlet from WebLogic Server 5.1 to WebLogic Server 6.1:
Web Applications Directory Structure
Web Applications are organized in a specified directory structure so that they can be archived and deployed on WebLogic Server. All servlets, classes, static files, and other resources belonging to a Web Application are organized under a directory hierarchy. The root of this hierarchy defines the document root of your Web Application. All files under this root directory can be served to the client, except for files under the special directories WEB-INF and META-INF located in the root directory. The root directory should be named with the name of your Web Application and placed inside the wlserver6.1/config/domainName/applications directory.
The following diagram illustrates the directory structure of any Web Application.
WebApplicationRoot/(Publically available files such as
| .jsp, .html, .jpg, .gif)
|
+WEB-INF/-+
|
+ classes/(directory containing
| Java classes including
| servlets used by the
| Web Application)
|
+ lib/(directory containing
| jar files used by the
| Web Application)
|
+ web.xml
|
+ weblogic.xml
When you convert your weblogic.properties file, the appropriate web.xml and weblogic.xml files are created for you under the directory wlserver6.1/config/domainName/applications/DefaultWebApp_myserver/WEB-INF. Follow the preceding directory structure and place the .xml files in the wlserver6.1/config/domainName/applications/webAppName/WEB-INF directory that you create. All applications must be placed inside a wlserver6.1/config/domainName/applications directory in order to be deployed. For more information, see Developing WebLogic Server Applications.
XML Deployment Descriptors
The Web Application Deployment Descriptor (web.xml) is a standard J2EE descriptor used to register your servlets, define servlet initialization parameters, register JSP tag libraries, define security constraints, and other Web Application parameters. For detailed instructions on creating the deployment descriptor, see Writing the Web Application Deployment Descriptor.
There is also a WebLogic-specific Deployment Descriptor (weblogic.xml). In this file you define JSP properties, JNDI mappings, security role mappings, and HTTP session parameters. The WebLogic-specific deployment descriptor also defines how named resources in the web.xml file are mapped to resources residing elsewhere in WebLogic Server. For detailed instructions on creating the WebLogic-specific deployment descriptor, see Writing the WebLogic-specific Deployment Descriptor. This file may not be required if you have no need for any of the above mentioned properties, mappings, or parameters.
Use the web.xml and weblogic.xml files, in conjunction with the console, to configure your applications. The .xml files can be viewed through any text editor. To edit them, simply make your changes and save the file as web.xml or weblogic.xml with the appropriate path as specified by the prescribed directory structure. See Assembling and Configuring Web Applications for more information. If you do not want to deploy your applications together as a single Web Application, you need to split up the .xml files that have been created for you, creating the appropriate .xml files specific to each Web Application.
WAR Files
A .war file is a Web Application archive. If you have correctly followed the prescribed directory structure of a Web Application and created the appropriate web.xml and weblogic.xml files, it is strongly recommended that in production environments your applications be bundled together in a Web Application deployed as a .war file. Once you have bundled your applications into a .war file, it is important to remove the previously existing directory structure so that WebLogic Server only has one instance of each application.
Use the following command line from the root directory containing your Web Application to create a .war file, replacing `webAppName' with the specific name you have chosen for your Web Application:
jar cvf webAppName.war *
You now have created a .war file that contains all the files and configuration information for your Web Application.
Deploying Web Applications
To deploy your bundled Web Applications properly, place the appropriate .war file in the c:/wlserver6.1/config/domainName/applications directory. You can also install the application through the Administration Console. To do so, go to the console home and choose Install Applications under the Getting Started menu. Select the correct .war file and it will be installed automatically. Note that it is necessary to have your applications reside in a c:/wlserver6.1/config/domainName/applications directory in order for them to work.
Web Applications should be deployed automatically after they have been installed. Check to see that they are deployed under the Deployments node in the left hand pane of the Administration Console.
You can configure certain deployment attributes for your Web Application using the Administration Console. Select the Web Applications node under the Deployments heading. Select your Web Application. Click on the appropriate tab to configure. For more information on setting attributes in the console, see the Web Application section of the Console Help.
Session Migration
WebLogic Server 6.0 and later does not recognize cookies from previous versions because cookie format changed with 6.0. WebLogic Server will ignore cookies with the old format, and create new sessions.
The default name for cookies has changed from 5.1, when it was WebLogicSession. Beginning in WebLogic 6.0, cookies are named JSESSIONID by default.
See weblogic.xml Deployment Descriptor Elements at http://e-docs.bea.com/wls/docs61/webapp/weblogic_xml.html for more information.
JavaServer Pages (JSPs) and Servlets
This section contains information specific to JSPs and servlets that may be pertinent to your applications.
Migrating a Simple Servlet from WebLogic Server 5.1 to WebLogic Server 6.1
The following procedure migrates the simple Hello World Servlet that was provided with WebLogic 5.1 Server to WebLogic Server 6.1.