App Server Deploy

Embed Size (px)

Citation preview

  • 7/28/2019 App Server Deploy

    1/8

    Deploying to a Sun Java System Application Server

    May 2006[Revision number: V2.1-1]Copyright 2006 Sun Microsystems, Inc.

    This tutorial describes the process of deploying a web application that you developed in the Java Studio Creator integrated development

    environment (IDE) to a stand-alone Sun Java System Application Server (Enterprise Edition and Standard Edition platforms). You create a WARfile for your application using the IDE, configure settings in the application server, and then deploy the WAR file on the stand-alone instance of theSun Java System Application Server.

    Contents

    - Before You Begin

    - Exporting the WAR File

    - Integrating the JDBC Driver

    - Configuring the JDBC Connection Pool

    - Configuring a JDBC Resource

    -Creating a Web Deployment DescriptorFile

    - Deploying the WAR File

    Before You Begin

    To complete this tutorial, you must have access to a stand-alone Sun Java System Application Server and you need to be familiar with theapplication server technology. If you are unfamiliar with the Sun Java System Application Server, download it, install it, and read its documentationbefore proceeding with this tutorial. Make sure that you download and install the latest available version of the Sun Java System Application ServerEnterprise or Standard Edition platform, which is bundled with the Sun JDBC drivers. You need to use at least version 8.1_02 b12 for the Enterpriseor Standard Edition platform. You can get the latest patches for the Sun Java System Application Server from SunSolve. Click Patches and Updates,and search for the appropriate patch number:

    q Solaris Operating System for SPARC Platforms - 119169q Solaris Operating System for x86 Platforms - 119170q Linux - 119171q Microsoft Windows - 119172

    The documentation is installed atAppserver-install-dir/docs/about.html, whereAppserver-install-diris the location where you installed the

    stand-alone application server. This tutorial was developed using Sun Java System Application Server Enterprise Edition 8.1_02 b12.

    Before you deploy your application to a stand-alone Sun Java System Application Server instance, you must first ensure that the application deployssuccessfully to the deployment container, Sun Java Studio System Application Server Platform Edition, which is bundled with the IDE. If yourapplication uses JDBC data sources that are not included with your stand-alone Sun Java System Application Server installation, you need tointegrate the corresponding database drivers into the stand-alone application server before you can deploy your application.

    Exporting the WAR File

    After successfully deploying your web application in the IDE, create a web application archive (WAR) file of your application so that you candeploy it to a stand-alone Sun Java System Application Server. The WAR file contains the complete web application in compressed form.

    1. Open your project in the IDE.

    2. In the Projects window, right-click the project name and choose Export WAR file.

    3. In the Export WAR dialog box, select the J2EE 1.4 option.

    4. Enter the location to which to export the WAR file.

    5. Click OK.

    1

    http://www.sun.com/download/index.jsp?cat=Application%20%26%20Integration%20Services&tab=3&subcat=Application%20Servershttp://sunsolve.sun.com/http://sunsolve.sun.com/http://www.sun.com/download/index.jsp?cat=Application%20%26%20Integration%20Services&tab=3&subcat=Application%20Servers
  • 7/28/2019 App Server Deploy

    2/8

    The JAR files that support the database drivers used by your application need to be installed in your AppServer_install_dir/lib/jdbcdriversdirectory. If they are not already installed, use the following steps to integrate them with your stand-alone Sun Java System Application serverinstallation.

    1. If you want to use the same database connection properties that were used during the application's development in the IDE, copy thefollowing file from your Java Studio Creator installation directory into the AppServer_install_dir/lib/jdbcdrivers directory.

    r Creator_install_dir/rave2.0/startup/samples/driveradapter.jar

    The other files in the jdbcdrivers directory support the bundled Sun JDBC drivers and are also bundled with the IDE. These files areautomatically installed in theAppServer_install_dir/lib/jdbcdrivers directory when you install the Sun Java System ApplicationServer Enterprise Edition or Standard Edition platforms.

    2. If you are using a database driver other than a Sun JDBC driver (for example, an OEM-provided driver), copy your driver-specific files to theAppServer_install_dir/lib/jdbcdrivers directory.

    See the IDE's System Requirements page for information on supported database servers and JDBC drivers. You can also check the FAQentitled Will any JDBC driver work with Java Studio Creator? for more information.

    3. If you had to add any database driver files using the previous steps, restart your stand-alone server instance.

    Configuring the JDBC Connection Pool

    Next, create a JDBC connection pool and define the characteristics of your database connection.

    1. In the left pane of the Admin Console, expand Resources > JDBC and select Connection Pools.

    2. In the Connection Pools page, click New to create a new connection pool.

    3. In the Connection Pool wizard Name field, enter a name for the connection pool.

    Enter any name of your choosing. You will reference this name in the next section when you configure the JDBC resource.

    4. Select the appropriate Resource Type and Database Vendor for the database driver you are using.

    If you are using the IDE's driveradapter.jar file, select javax.sql.DataSource as the resource type and leave the DatabaseVendor field blank.

    5. Click Next.

    6. On the next page of the Create Connection Pool wizard, enter a name in the Datasource Classname field.

    If you are using the IDE's driveradapter.jar file, type in the class name as com.sun.sql.datasource.DriverAdapter. Ifyou are using a third-party datasource, then enter that driver name. Figure 1 shows the Classname for the MySQL driver.

    Figure 1: Second Page of Create Connection Pool Wizard

    7. Click Next.

    Integrating the JDBC Driver

    2

    http://developers.sun.com/prodtech/javatools/jscreator/features/sysreqs/dbservers_jdbcdrivers.htmlhttp://developers.sun.comhttp//developers.sun.com/prodtech/javatools/jscreator/reference/faqs/technical/depsrvs/http://developers.sun.comhttp//developers.sun.com/prodtech/javatools/jscreator/reference/faqs/technical/depsrvs/http://developers.sun.com/prodtech/javatools/jscreator/features/sysreqs/dbservers_jdbcdrivers.html
  • 7/28/2019 App Server Deploy

    3/8

    8. On the third page of the Create Connection Pool wizard, specify the properties for your connection pool in the Properties section.

    If you are using the IDE's driveradapter.jar file, specify the properties and values shown in the following table. Be sure to use thecapitalization as shown in this tutorial. If you are using a different driver, consult your driver's documentation for the correct properties andvalues.

    Property Value

    url

    Specify the URL for the connection pool, similar to the following.DB2: jdbc:sun:db2://#HOSTNAME:50000;DatabaseName=#DATABASEOracle: jdbc:sun:oracle://#HOSTNAME:1521;SID=#DATABASEMicrosoft SQL Server:jdbc:sun:sqlserver://#HOSTNAME:1433;

    DatabaseName=#DATABASE;SelectMethod=cursorSybase: jdbc:sun:sybase://#HOSTNAME:5000;

    DatabaseName=#DATABASE;SelectMethod=cursor

    Note: You can find the URL used by your web application in the IDE. Go to the Servers window, expand theDeployment Server > Resources node, and select the data source name used by your web application. TheURL is displayed in the property sheet under the DatabaseName property. You need to modify the#HOSTNAMEand #DATABASEname with values that your application will use once deployed in the stand-alone instance of the Sun Java System Application Server.

    Password Specify the password for the connection pool.

    driverClassName

    Specify the class name of your database server driver. The following list shows the class names for the JDBC

    drivers that are bundled with the IDE and the Sun Java System Application Server Standard Edition orEnterprise Edition platforms.

    DB2: com.sun.sql.jdbc.db2.DB2DriverSybase: com.sun.sql.jdbc.sybase.SybaseDriverMicrosoft SQL Server: com.sun.sql.jdbc.sqlserver.SQLServerDriverOracle: com.sun.sql.jdbc.oracle.OracleDriver

    Username Specify the user name for the connection pool.

    User Specify the user name for the connection pool.

    The following figure shows the Properties section on the third page of the Create Connection Pool wizard. In this example, the User propertywas added using the Add Property button.

    Figure 2: Third Page of Create Connection Pool Wizard

    9. Click Finish.

    Configuring a JDBC Resource

    You must create a JDBC resource to enable your application to connect to the database that it will use after it is deployed.

    1. In the left pane of the Admin Console, expand Resources > JDBC and then select JDBC Resources.

    The Resources > JDBC Resources page opens in the right pane.

    2. Click New.

    3

  • 7/28/2019 App Server Deploy

    4/8

    The page for creating a new JDBC resource appears in the right pane.

    3. Enter the Java Naming and Directory Interface (JNDI) name for the resource to be created.

    The name must be in the form jdbc/data_source_name . The data_source_name value must match the value used in the tag of the deployment descriptor file (sun-web.xml) you will create later in this tutorial.

    4. From the Pool Name drop-down list, select the pool name you created for the data source.

    5. In the Targets section, select the name for your server instance and click Add.

    The following figure shows a sample of the Create JDBC Resource page.

    Figure 3: Sample of Create JDBC Resource Page

    6. Click OK to register the new data source.

    Creating a Web Deployment Descriptor File

    You also need to create sun-web.xml, a container-specific deployment descriptor file for the Sun Java System Application Server, and packageit within the WAR file you just exported earlier in the tutorial. The sun-web.xml file includes the XML-based deployment descriptors thatspecify the web application configuration, including mappings, initialization parameters, and security constraints. In the following steps, you use theDeployment Tool that is bundled with the Sun Java System Application Server.

    1. Launch the Deployment Tool.

    In a Windows environment, choose Start > All Programs > Sun Microsystems > Application Server > Deploytool. On Solaris or Linux, runtheAppServer_install_dir/bin/deploytool script. Note that you can also use the Deploytool that is included with the Sun Java SystemApplication Server PE, which is bundled with the IDE.

    2. In the Deployment Tool window, select File > Add Server.

    3. In the Add Server dialog window, type the Server Name and Server Port of your stand-alone Sun Java System Application Server, asillustrated in the following figure.

    4

  • 7/28/2019 App Server Deploy

    5/8

    Figure 4: Deploytool Add Server DialogThe server that you have added now appears under the Servers node on the left panel of the Deployment Tool.

    4. Click File > Open to open the exported WAR file that you created earlier in the tutorial.

    You may use the file browser to navigate to where you saved the exported WAR file.

    5. In the panel on the right side, click the Resource Ref's tab.

    The resource factories referenced by your application are displayed.

    6. Select the resource you want to use and type the Sun-specific settings at the bottom of the pane.

    Figure 5 shows an example of Sun-specific settings.

    Figure 5: Resource References Tabbed Pane

    7. Click File > Save to save your changes.

    A file called sun-web.xml is created and added to the WAR file you exported earlier. The sun-web.xml code sample below showswhat is generated for the CorporateTravelCenter sample application that is bundled with the IDE.

    5

  • 7/28/2019 App Server Deploy

    6/8

    Notice the tag that was created in the previous steps in this section. The tag specifies the datasource value that is used by your application. You need to provide a tag for each of your application's data sources. The tag specifies the name of the JDBC resource that you created in a previous section of this tutorial. If your application doesnot use a data source, remove the tag. If your application uses the Enterprise JavaBeans (EJB) technology, you alsoneed to include the declaration in the sun-web.xml file.

    Code Sample 1: sun-web.xml Code

    /CorporateTravelCenter

    jdbc/MySQL_travel

    jdbc/MySQL_travel

    Enable debug info compilation in the generated

    servlet class

    Maintain a one-to-one correspondence between

    static content and the generated servlet class' java code

    Deploying the WAR File

    You can now deploy your modified WAR file to your stand-alone instance of the Sun Java System Application Server. The following steps use the

    Deployment Tool.

    1. In the Deployment Tool window, select the node for the WAR file you created earlier in the tutorial.

    2. Click Tools > Deploy.

    3. In the Deploy Module window, type the Username and Password necessary to connect to the stand-alone server instance to which you wantto deploy your application.

    4. Click OK to deploy the application.

    The Distribute Module window appears and gives status on the deployment of the application. If any error messages are displayed, resolvethe errors.

    5. Click Close on the Distribute Module window.

    6. Verify the deployed application with the URL http://hostname:portnumber/context_root.

    The hostname is the name of the system in which the stand-alone Sun Java System Application Server is installed. This could belocalhost, for example. Theportnumberis the Sun Java System Application Server HTTP listener. The context_root is the base path ofthe web application relative to the server base's URL. For example, if your server's base URL is http://localhost and the context rootis apps/myapp, then all components of the web application will be accessed relative to http://localhost/apps/myapp.

    See Also:

    q Deploying to Sun Java System Web Server 6.1q Deploying to a BEA WebLogic Serverq Deploying a Portlet to Sun Java Portal Server

    6

    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/webserverdeploy.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/weblogicdeploy.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/portletdeploy.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/portletdeploy.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/weblogicdeploy.htmlhttp://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/webserverdeploy.html
  • 7/28/2019 App Server Deploy

    7/8

    q Java Studio Creator technical articles on deployment

    More Developer Resources

    For more tutorials, articles, tips, forums, updates, and expert advice for developers, visit theJava Studio Creator developer resources on the SunDeveloper Network (SDN) at http://developers.sun.com/jscreator/.

    This page was last modified: May 12, 2006

    Sun and Third-party Trademarked Terminology

    The following Sun trademarked terms might be used in the Sun Java(tm) Studio Creator tutorials:

    q Sun Java Studio Creator integrated development environment (IDE)q Sun Java System Application Server version number(Application Server)q Java Platform, Standard Edition technology (Java SE(tm) platform)q JavaServer(tm) Faces technologyq JavaServer Pages(tm) technology (JSP(tm) technology)q Sun Java System Web Server version number(Web Server)q Java Database Connectivity software (JDBC software)q Enterprise JavaBeans(tm) specification (EJB(tm) specification)q Solaris(tm) Operating System software (Solaris OS software)

    The following third-party trademarked terms might be used in the Sun Java Studio Creator tutorials:

    q UNIX(R) softwareq SPARC(R) processor

    Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

    Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular,and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one ormore additional patents or pending patent applications in the U.S. and in other countries.

    U.S. Government Rights - Commercial software.

    Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use

    is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and the Java Coffee Cup logo are trademarks or registered trademarks of SunMicrosystems, Inc. in the U.S. and other countries.This product is covered and controlled by U.S. Export Control laws and may be subject to the exportor import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect,are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but notlimited to, the denied persons and specially designated nationals lists is strictly prohibited.

    Note: Sun is not responsible for the availability of third-party web sites mentioned in this document and does not endorse and is not responsible or liablefor any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable for anydamage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods, or services available on or throughany such sites or resources.

    Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, tats-Unis. Tous droits rservs.

    Sun Microsystems, Inc. dtient les droits de proprit intellectuels relatifs la technologie incorpore dans le produit qui est dcrit dans ce document.En particulier, et ce sans limitation, ces droits de proprit intellectuelle peuvent inclure un ou plus des brevets amricains lists l'adresse http://www.

    sun.com/patents et un ou les brevets supplmentaires ou les applications de brevet en attente aux tats-Unis et dans les autres pays. L'utilisation estsoumise aux termes de la Licence. Sun, Sun Microsystems, le logo Sun, Java et le logo Java Coffee Cup sont des marques de fabrique ou des marquesdposes de Sun Microsystems, Inc. aux tats-Unis et dans d'autres pays.Ce produit est soumis la lgislation amricaine en matire de contrle desexportations et peut tre soumis la rglementation en vigueur dans d'autres pays dans le domaine des exportations et importations. Les utilisations, ouutilisateurs finaux, pour des armes nuclaires,des missiles, des armes biologiques et chimiques ou du nuclaire maritime, directement ou indirectement,sont strictement interdites. Les exportations ou rexportations vers les pays sous embargo amricain, ou vers des entits figurant sur les listesd'exclusion d'exportation amricaines, y compris, mais de manire non exhaustive, la liste de personnes qui font objet d'un ordre de ne pas participer,d'une faon directe ou indirecte, aux exportations des produits ou des services qui sont rgis par la lgislation amricaine en matire de contrle desexportations et la liste de ressortissants spcifiquement dsigns, sont rigoureusement interdites.

    Sun Microsystems n'est pas responsable de la disponibilit de tiers emplacements d'enchanement mentionns dans ce document et n'approuve pas et

    7

    http://developers.sun.com/prodtech/javatools/jscreator/reference/index.jsp#Application_Deploymenthttp://developers.sun.com/jscreatorhttp://developers.sun.com/jscreatorhttp://developers.sun.com/jscreatorhttp://developers.sun.com/prodtech/javatools/jscreator/reference/index.jsp#Application_Deployment
  • 7/28/2019 App Server Deploy

    8/8

    n'est pas responsable ou iresponsable d'aucun contenu, de la publicit, de produits, ou d'autres matriaux dessus ou fournis par de tels emplacements ouressources. Sun ne sera pas responsable ou iresponsable d'aucuns dommages ou perte causs ou allgus pour tre caus par ou en liaison avecl'utilisation de ce produit ou la confiance dans des tels contenu, marchandises, ou services disponibles sur ou par des tels emplacements ou ressources.

    8