390 likes | 673 Views
Deploying Java EE Applications. Objectives. After completing this lesson, you should be able to do the following: Describe deployment archive files Develop deployment descriptors for Java EE components Describe Oracle Application Server Containers for Java EE (OC4J) architecture
E N D
Objectives • After completing this lesson, you should be able to do the following: • Describe deployment archive files • Develop deployment descriptors for Java EE components • Describe Oracle Application Server Containers for Java EE (OC4J) architecture • Deploy Java EE applications to Oracle Application Server 10g
Java EE Server • The Java EE server provides: • Containers for each component type of a Java EE application • System-level services to components: • Naming and directory services (JNDI) • Security services for Web components and Enterprise JavaBeans (JAAS) • Transaction architecture (JTA) • Remote client connectivity: • Enterprise beans (RMI/IIOP, ORMI) • Servlet/JSP (HTTP, HTTPS, FTP)
Java EE Application Assembly and Deployment • A Java EE application is packaged into one or more standard units for deployment to any Java EE platform–compliant system. Each unit contains: • A functional component or components (EJB, JSP, servlet, and so on) • An optional deployment descriptor that describes its content
Planning the Deployment Process • The deployment process includes: • Packaging code as Java EE applications or modules • Selecting a parent application • Binding the Web application to a Web site • Creating and applying a deployment plan • Deploying the application or module Deploy Parent 1 2 3 4 5 EAR file Select parentapplication Bind to URL Deploymentplan Deployedenvironment
Deployment Containers • A deployment module is a packaging structure for components that ultimately execute in a run-time container. • EJB • Web • Application Container
Packaging Java EE Application Components 1. webtier.war Java servlets, JSP files, HTML, GIF files, and a Web application deployment descriptor 2. JavaEEappClient.jar Java EE application client (Java class), andan application client deployment descriptor Java EE application.ear 3. Resource adapter (.rar)Java interfaces, classes, native librariesand other documentation, and the resource adapter deployment descriptor 4. ejb.jar Class files for enterprise beans and an EJB deployment descriptor
JARs • Java Archives (JARs): • Are simple Java archive files • Are used to package application files together (classes, images, and so on) • Can be included in Web Archives (WARs) and Enterprise Archives (EARs) • Can be included in library paths
WARs • Web Archives (WARs): • Are specialized archives for packagingJava EE–compliant Web applications • Have a fixed directory structure • Have a deployment descriptor for the Web application WEB-INF web.xml Contain servlet code and JavaBeans not in standard JAR files classes lib Contains required classes that are packaged in standard JAR files index.html welcome.jsp
EJB JARs • EJB JARs: • Are specialized JARs for packaging EJBs • Have a fixed directory structure • Have a deployment descriptor for the EJB components myEJB META-INF ejb-jar.xml Contain the class files for the EJBs, usually in a package directory structure EJB Classes Remote, Home, and Bean classes
The EJB Deployment Process Developer’sresponsibility Home interface Remote interface Bean class Other classes Component deployer’s responsibility Deployment descriptor EJB JAR Deployment tools/ commands JAR command/ tool Deployed EJB in the server JNDI
EARs • EAR files: • Are specialized archives for packaging Java EE-compliant enterprise applications for deployment • Have a deployment descriptor • May have Web modules • May have EJB modules • May have client modules
EAR File Structure for a Java EE Application: Example <appname> META-INF application.xml <ejb_module> EJB classes META-INF ejb-jar.xml <web_module> index.html JSPs WEB-INF web.xml classes Servlet classes <client_module> Client classes META-INF application-client.xml
Working with Deployment Descriptors • Deployment descriptors are: • Added to the application archive in the META-INF directory relative to the archive root • Used to customize application-specific configuration and specify deployment information • Merged with deployment plans, if provided
JSR-88 Deployment Plans • Deployment plans are: • Used to create a client-side grouping of application configuration data needed to deploy the application to a Java EE container • Implemented for support of the JSR-88 specification, which defines creation of deployment plans • Created when you deploy the application • Saved in files that can be retrieved, edited, and reused
Creating a JSR-88 Deployment Plan • Deployment plans are created: • By default (if none are supplied) • When the application is deployed by: • JDeveloperin the ConfigureApplication window • ApplicationServer Control
Working with JSR-88 Deployment Plans • The deployment plan provides many properties that enable the fine-tuning of application deployment to the target Java EE container. The deployment plan: • Includes properties • defaultDataSource to select the data source used by the application for management of data by EJB entities • prependDeploymentName to specify that the EAR file is prepended with an underscore(_) after deployment • Can be saved for reuse • Can be reloaded and edited when deploying an application
Oracle Application Server Containers for Java EE (OC4J) • OC4J is the Java EE server implementation in Oracle Application Server 10g. • Key features: • Implements Java EE 1.4 Specification • Runs on standard JVM • Provides high performance and scalability • Is productive for developers to use • Is simple to manage and deploy • Provides clustering for high availability and failover
OC4J Architecture Oracle HTTPServer AJP13 Webcontainer JNDI HTTP JMS AJP mod_oc4j JDBC JTA Client JAAS EJB container ORMI JCA JavaMail ORMI JAF EJB client OC4J server process
OC4J Server Configuration Files OC4J server XML files Server configuration server.xml Web site Web site Web site jazn.xml default-web-site.xml jazn-data.xml data-sources.xml rmi.xml jms.xml Oracle HTTP Server configuration files mod_oc4j.conf
Relation of Configuration Files <application name="lesson18" path="../applications/lesson18.ear" /> <application name="lesson18" path="../applications/lesson18.ear" /> <web-app application="lesson18" name="webapp1" root="/lesson18"/> <web><web-uri>webapp1.war</web-uri></web>
Application Logging • Application logging in Oracle Application Server 10g is configured by specifying the location of a log file in the orion-application.xml file: • To create a log file formatted in XML, use Oracle Diagnostic Logging (ODL): <log> <file path="practice18-oc4j-app.log"/> </log> <log> <odl path="practice18-oc4j-app.log"/> </log>
Data Sources • Data sources provide logical database mappings: • Developer uses the logical representation of a database. • Deployer maps to the physical data sources. • Java EE applications use published DataSource objects by: • Looking up the published name via Java Naming and Directory Interface (JNDI) • Using JDBC Connection methods to connect to the database • Data sources are published in the JNDI tree. • They come in different varieties. • They are referenced in orion-application.xml.
Data Source Definition • Global data sources are defined in the OC4J_HOME/config/data-sources.xml file. • You specify each data source by using an XML tag. • Attributes specify values for the data source. • Application-specific data sources: Use the <data-sources> tag in the orion-application.xml file. OC4J_HOME/applications myapp application.xml Points to data-sources.xml
data-sources.xml: Example <data-source class="com.evermind.sql.DriverManagerDataSource" connection-driver="oracle.jdbc.driver.OracleDriver" name="OracleDS" location="jdbc/OracleCoreDS" xa-location="jdbc/xa/OracleDS" ejb-location="jdbc/OracleDS" min-connections="5" max-connections="25" username="oe" password="oe" url="jdbc:oracle:thin:@<host>:<port>:<SID>" />
Deploying an Application: Web Tier • To deploy the Web-tier components of a Java Platform, Enterprise Edition (Java EE) application, perform the following steps: 1. Make sure that the ejb-ref or ejb-local-ref elements exist in the web.xml file. 2. Create a WAR deployment profile (.deploy) in JDeveloper. 3. Right-click the .deploy file and select either of the following: • Deploy to WAR file • Deploy to OracleAS10g (where OracleAS10g is the name of your application server connection)
Deploying an Application: EJB Tier 1. Make sure that the ejb-jar.xml file contains unique mappings for each EJB in the application. 2. Create a JAR deployment profile (.deploy) in JDeveloper. 3. Right-click the .deploy file and select either of the following: • Deploy to JAR file • Deploy to OracleAS 10g
Deploying an Application: EAR File 1. Create an EAR deployment profile in JDeveloper. 2. Specify the EJB JAR and WAR files that are to be included in this EAR file. 3. Right-click the .deploy file and select either of the following: • Deploy to EAR file • Deploy to OracleAS10g
Example: Creating the Application Deployment Profile 1 4 2 5 3 6
Example: Creating the Application Deployment Descriptor 1 2 3 4
Java EE Application Deployment to Oracle Application Server 10g • Deploying to OC4J can be done in multiple ways:
Deploying with JSR-88 Ant Tasks • Using JSR-88 Ant tasks, you can: • Deploy applications • Undeploy applications • Redeploy applications • Start and stop applications in OC4J containers (including those in a cluster)
Summary • In this lesson, you should have learned how to: • Describe the Java EE server environment and how Java EE applications are deployed as modules • Create an Enterprise Archive, containing JAR, WAR, and deployment descriptor files • Define the process for deploying all the components of a Java EE application • Describe OC4J as the container for your application • Use data sources to connect to the database
Practice Overview: Deploying Java EE Applications • This practice covers deploying the course application.