690 likes | 1.39k Views
Objectives. To install WebLogic Server 7.0.Deploy EJB using WebLogic.. Prerequisites. Familiarity with the Java programming language.An understanding of databases and transactions concepts is helpful but not required.Familiarity with J2EE terminology.. Implementation of Java Specifications. J2EE SpecificationWebLogic Server 7.0 is compliant with the J2EE 1.3 specification. EJB 2.0 SpecificationThe Enterprise JavaBeans 2.0 implementation in WebLogic Server is fully compliant and can be use31319
E N D
1. Install and Deploy EJB using WebLogic Presented by
Sailaja Neelam
2. Objectives To install WebLogic Server 7.0.
Deploy EJB using WebLogic.
3. Prerequisites Familiarity with the Java programming language.
An understanding of databases and transactions concepts is helpful but not required.
Familiarity with J2EE terminology.
4. Implementation of Java Specifications J2EE Specification
WebLogic Server 7.0 is compliant with the J2EE 1.3 specification.
EJB 2.0 Specification
The Enterprise JavaBeans 2.0 implementation in WebLogic Server is fully compliant and can be used in production
5. EJB-Background Enterprise JavaBeans is a specification that promises to greatly ease the creation of sophisticated transaction-based applications with minimal work.
The application programmer need only be concerned with solving the business problem at hand.
The resulting server application is not only portable to all platforms that confirm to EJB specifications but it also encourages reuse through its modular design.
6. Overview of EJB Enterprise JavaBeans are reusable Java components that implement business logic and enable you to develop component-based distributed business applications.
EJB component model simplifies the development of middleware applications by providing automatic support for services such as transactions, security, database connectivity, and more.
7. EJB Components Remote interface
This interface exposes business logic to the client.
Home interface
The EJB factory. Clients use this interface to create, find, and remove EJB instances.
Bean class
This interface implements business logic.
Primary key
An object that uniquely identifies an entity bean within its home.
8. Importing Enterprise JavaBeans From an EJB-JAR file
Deploy the jar file to the repository.
Install the package in the Installed Packages folder in the Adaptive Server plug-in.
From an EJB class file
Specify the package in which to install the component as follows:
Open the installed EJB Packages folder.
Double-click the package to which the component will be added.
9. Importing Enterprise JavaBeans (2) Double click the Add new component icon in the right window.The component wizard displays.
In the Type of component window, select Import an EJB Class File, and click Next.
10. Importing Enterprise JavaBeans (3) Enter the component name and EJB class and interface names as follows:
Component name
Component type
Remote Interface
Home Interface
Bean Class name
Primary key class
Click Next
11. Importing Enterprise JavaBeans (4) The Adaptive Server plug-in displays the Component Properties dialog box.
The Component’s type and java classes have been filled in by the importer.
Specify values for the remaining properties before running the Bean.
12. WebLogic Server 7.0 BEA WebLogic Server is a fully featured, standards-based application server providing the foundation on which an enterprise can build its applications.
WebLogic application server is the “workhorse” enterprise software that provides application infrastructure for modern business systems.
13. BEA WebLogic Server
14. WebLogic Server
15. WebLogic Server EJB 2.0 Support WebLogic Server supports an implementation of Sun Microsystems's EJB 2.0 specification and is compliant with the Sun Microsystem's EJB 1.1 specification.
The WebLogic Server EJB container supports both the EJB 1.1 and EJB 2.0 specifications including the EJB 1.1 and EJB 2.0 document type definitions (DTD).
16. Installing BEA WebLogic Server Download BEA WebLogic’s server from the BEA WebLogic web site:
http://www.weblogic.com/licbeta.html
Extract the distribution using jar or the unzip utility.
Download the latest version of the Java Development Kit from the Java Development Kit for Solaris web site:
http://www.sun.com/solaris/java
17. Installing BEA WebLogic Server (2) Set your CLASSPATH on the server host:
Add weblogic/classes and
weblogic/lib/weblogicaux.jar to your Java
CLASSPATH. Make sure you have "." or your
current directory in the CLASSPATH as well.
Add weblogic/lib/solaris to your LD_LIBRARY_PATH
18. Installing BEA WebLogic Server (3) Edit the BEA WebLogic properties file WebLogic.properties Set the system password property, weblogic.password.system
Start the WebLogic server using the startWebLogic.sh script.
19. Process for Developing WebLogic Enterprise EJB Applications
20. The WebLogic Server EJB Container and Supported Services EJB Container
The EJB container is a runtime container for deployed EJBs and is automatically created when the WebLogic is created.
The EJB container provides a standard set of services, including caching, concurrency, persistence, security, transaction management, locking, environment, memory replication, and clustering for the EJB objects that live in the container.
21. EJB lifecycle in WebLogic Server
22. Container-Managed Persistence Relationships The entity bean relies on container-managed persistence to generate the methods that perform persistent data access for the entity bean instances.
The generated methods transfer data between entity bean instances and the underlying resource manager.
Persistence is handled by the container at runtime
23. Container-Managed Persistence Relationships (2) The advantage of using container-managed persistence is that the entity bean can be logically independent of the data source in which the entity is stored.
The container manages the mapping between the logical and physical relationships at runtime and manages their referential integrity.
24. Relationships-CMP WebLogic Server supports three types of relationship mappings that are managed by WebLogic container-managed persistence (CMP):
One-to-one
A WebLogic Server one-to-one relationship involves the physical mapping from a foreign key in one bean to the primary key in another bean
25. Relationships-CMP (2) One-to-Many
A WebLogic Server one-to-many relationship involves the physical mapping from a foreign key in one bean to the primary key of another
Many-to-Many
A WebLogic Server many-to-many relationship involves the physical mapping of a join table.
26. One to One –Sample Code <weblogic-rdbms-relation> <relation-name>employee-manager</relation-name> <weblogic-relationship-role> <relationship-role-map> <column-map> <foreign-key- column>manager-id </foreign-key-column> <key-column>id</key-column> </column-map>
27. One to One –Sample Code (2) </relationship-role-map> <relationship-role-name>employee </relationship-role-name> </weblogic-relationship-role></weblogic-rdbms-relation>
28. One-to-Many- Sample Code <weblogic-rdbms-relation> <relation-name>employee- department</relation-name> <weblogic-relationship-role> <relationship-role-map> <column-map> <foreign-key-column>dept-id </foreign-key-column>
29. One-to-Many- Sample Code (2) key-column>id</key-column> </column-map> </relationship-role-map> <relationship-role-name>employee </relationship-role-name></weblogic-relationship-role></weblogic-rdbms-relation>
30. Many to Many – Sample Code <weblogic-rdbms-relation><relation-name>friends</relation-name> <table-name>FRIENDS</table-name> <weblogic-relationship-role> <relationship-role-name>friend </relationship-role-name> <relationship-role-name> <<column-map>
31. Many to Many – Sample Code (2) <foreign-key-column>first-friend-id </foreign-key-column> <key-column>id</key-column> </column-map </relationship-role-map> <weblogic-relationship-role> <weblogic-relationship-role> <relationship-role-name>second-friend </relationship-role-name> <relationship-role-map>
32. Many to Many – Sample Code (3) <column-map><foreign-key-column>second- friend-id</foreign-key-column> <key-column>id</key-column> </column-map> </relationship-role-map></weblogic-relationship-role></weblogic-rdbms-relation>
33. WebLogic Server Container-Managed Persistence Service fWebLogic Server's container is responsible for providing a uniform interface between the EJB and the server.
The container creates new instances of the EJBs, manages these bean resources, and provides persistent services such as, transactions, security, concurrency, and naming at runtime.
34. WebLogic Server Container-Managed Persistence Service (2) WebLogic Server's container-managed persistence (CMP) model handles persistence of CMP entity beans automatically at runtime by synchronizing the EJB's instance fields with the data in the database.
35. Supported Databases WebLogic Server supports container-managed persistence for the following databases:
Oracle
36. Using WebLogic Server RDBMS Persistence Create a dedicated XML deployment file.
Define the persistence elements for each EJB that will use container-managed persistence.
Creating deployment descriptor files.
37. Packaging EJBs for the WebLogic Server Container Review the EJB source file components.
Create the EJB deployment files.
Edit the EJB deployment descriptors.
Set the deployment mode.
Generate the EJB container classes.
Package the EJBs into a JAR or EAR file.
Load EJB classes into WebLogic Server
38. WebLogic Server EJB Deployment Files ejb-jar.xml
weblogic-ejb-jar.xml
weblogic-cmp-rdbms-jar.xml
39. WebLogic Server EJB Deployment Files (2) The deployment files become part of the EJB deployment when the bean is compiled.
The XML deployment descriptor files should contain the minimum deployment descriptor settings for the EJB.
The deployment descriptor files must conform to the correct version of the Document Type Definition (DTD) for each file you use.
40. ejb-jar.xml The ejb-jar.xml file contains the Sun Microsystem-specific EJB DTD
The deployment descriptors in this file describe the enterprise bean's structure and declares its internal dependences and the application assembly information.
These descriptors describe how the enterprise bean in the ejb-jar file is assembled into an application deployment unit.
41. weblogic-ejb-jar.xml The weblogic-ejb-jar.xml file contains the WebLogic Server-specific EJB DTD that defines the concurrency, caching, clustering, and behavior of EJBs.
The weblogic-ejb-jar.xml file contains descriptors that map available WebLogic Server resources to EJBs.
42. weblogic-cmp-rdbms.xml The weblogic-cmp-rdbms.xml file contains the WebLogic Server-specific EJB DTD that defines container-managed persistence services.
This file specifies how the container handles synchronizing the entity bean's instance fields with the data in the database.
43. Relationships Among the Deployment Files Descriptors in weblogic-ejb-jar.xml are linked to:
EJB names in ejb-jar.xml
resource names in a running WebLogic Server
persistence type data defined in weblogic-cmp-rdbms-jar.xml
44. Deploying EJBs to WebLogic Server There are two different ways to deploy EJBs to WebLogic Server:
static deployment
dynamic deployment.
45. Required Steps for Deploying EJBs Setting the EJB deployment descriptors
Generating EJB container classes
Loading EJB classes
Deploying EJBs at WebLogic Server startup or dynamically
46. Setting Deployment Properties The deployment process begins with a .jar file or a deployment directory that contains the compiled EJB interfaces and implementation classes created by the EJB provider.
The EJB provider should also supply an EJB compliant ejb-jar.xml file that describes the bundled EJB(s).
47. Setting Deployment Properties (2) The ejb-jar.xml file and any other required XML deployment file must reside in a top-level META-INF subdirectory of the .jar or deployment directory.
As is, the basic .jar or deployment directory cannot be deployed to WebLogic Server.
Create and configure WebLogic Server-specific deployment descriptions in the weblogic-ejb-jar.xml file, and add that file to the deployment.
48. Setting Deployment Properties (3)
49. Generating EJB Container Classes After compiling the EJB classes and adding the required WebLogic Server XML deployment files identified in Setting Deployment Properties to your deployment unit, you must generate the container classes that are used to access the EJB.
The ejbc compiler generates container classes according to the deployment properties you have specified in WebLogic Server-specific XML deployment files.
50. Loading EJB Classes into WebLogic Server Classloaders in WebLogic Server are hierarchical.
When WebLogic Server deploys an application, it creates two new classloaders:
one for EJBs
one for Web applications
The EJB classloader is a child of the Java system classloader and the Web application classloader is a child of the EJB classloader.
51. Deploying EJBs at WebLogic Server Startup Ensure that your deployable EJB .jar file or deployment directory contains the required WebLogic Server XML deployment files.
Use a text editor to edit the XML deployment properties.
Compile the container places the .jar file in the weblogic/config/examples/applications directory, where it is automatically deployed when WebLogic Server starts.
52. Deploying EJBs at WebLogic Server Startup (2) Start WebLogic Server
Launch the Administration Console.
In the right pane, click EJB Deployments
A list of the EJB deployments for the server displays in the right-hand pane.
53. Deploying EJBs in Different Applications When EJBs are not deployed in the same application, call by reference cannot be used to invoke on the EJBs,instead pass by value should be used.
By default, EJB methods called from within the same server pass arguments by reference which increases the performance of method invocation because parameters are not copied.
Pass by value is always necessary when the EJB is called remotely (not from within the server).
54. Dynamic Deployment Dynamic deployment is provided for situations where rebooting WebLogic Server is not feasible.
Using dynamic deployment features, you can:
Deploy a newly developed EJB to a running, production system
Remove a deployed EJB to restrict access to data
Update a deployed EJB implementation class to fix a bug or test a new feature
55. EJB Deployment Names When deploying an EJB .jar file or deployment directory, specify a name for the deployment unit.
When deploying an EJB, WebLogic Server implicitly assigns a deployment name that matches the path and filename of the .jar file or deployment directory.
56. Viewing Deployed EJBs Enter the following
% java weblogic.deploy list password
To list deployed EJBs on a remote server, specify the port and host options
% java weblogic.deploy -port port_number -host host_name list password
57. Viewing Deployed EJBs (2) From the WebLogic Server Administration Console
Choose EJB Deployments from J2EE node in the right-hand pane of the Console.
View a list of deployed EJBs.
58. Deploying New EJBs into a Running Environment To deploy an EJB .jar file or deployment directory that has not been deployed to WebLogic Server:
% java weblogic.deploy -port port_number -host host_name deploy password name source
For example
% java weblogic.deploy -port 7001 -host localhost deploy weblogicpwd CMP_examplec:\weblogic\myserver\unjarred\containerManaged\
59. Undeploying Deployed EJBs Undeploying an EJB effectively prohibits all clients from using the EJB.
When you undeploy the EJB, the specified EJB's implementation class is immediately marked as unavailable in the server.
WebLogic Server automatically removes the implementation class and propagates an UndeploymentException to all clients that were using the bean
60. Undeploying Deployed EJBs Undeployment does not automatically remove the specified EJB's public interface classes
Implementations of the home interface, remote interface, and any support classes referenced in the public interfaces, remain in the server until all references to those classes are released.
61. Undeploying Deployed EJBs Undeploying an EJB does not remove the deployment name associated with the EJB .jar file or deployment directory.
The deployment name remains in the server to allow for later updates of the EJB.
62. Steps to Undeploy EJBs From the command line reference the assigned deployment unit name, as in:
% java weblogic.deploy -port 7001 -host localhost undeployweblogicpwd CMP_example
From the WebLogic Server Administration Console:
Choose EJB Deployments from J2EE node in the right-hand pane of the Console.
63. Steps to Undeploy EJBs Click the EJB you want to undeploy from the list.
Choose the Target tab and undeploy the EJB by toggling the server to the Available column.
64. Updating Deployed EJBs Reboot the server (if the .jar or directory is to be automatically deployed),
Update the EJB deployment using the WebLogic Server Administration Console.
65. Updating the EJB From the command line update argument and specify the active EJB deployment name:
% java weblogic.deploy -port 7001 -host localhost updateweblogicpwd CMP_example
From the WebLogic Server Administration Console:
Choose EJB Deployments from J2EE node in the right-hand pane of the Console.
66. Updating the EJB Click the EJB you want to update from the list.
Choose the Target tab and update the EJB by toggling the server to the Chosen column.
67. EJB Enhancements in WebLogic Server 7.0 Dynamic Query Support
allow you to construct and execute queries programmatically in your application code
Message-Driven Bean Migratable Service Support
EJB CMP Multiple Table Mapping Support
EJB WebLogic QL Enhancements Support
EJB Links Support
68. References http://www.bea.com/content/news_events/white_papers/BEA_WL_Server_81_Overview_wp.pdf
http://edocs.bea.com/wls/docs60/adminguide/appman.html
http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-weblogic_p.html
69. References http://edocs.bea.com/wls/docs60/ejb/EJB_deployover.html
http://info.borland.com/techpubs/jbuilder/jbuilder8/websvcs/export_bean_weblogic/export_bean_weblogic_tutorial.html
http://www.javaworld.com/javaworld/jw-04-1999/jw-04-middleware_p.html