http://jaiswaltraining.com/ejb3/weblogic/ch1.php
Stateless Session Bean
EJB3 in Weblogic10.3 with client example in Eclipse
EjbSession Project creation

Ejb3 application deployment

WebClient

Setting build path for EJB3


ejb jar file Creation
Web Client will require ejb file for communication.
So we will put this jar file in the Web Application lib folder.



Running the Client


Stateless Session Bean
EJB3 in Weblogic10.3 with client example in Eclipse
EjbSession Project creation
- Take a new EJB project
- Now take a session bean
- Give it name Hello.
- It creates two files
- Hello.java(Remote interface)
- HelloBean.java(Stateless bean)
- Now modify the code for the remote interface
- Put the business logic in it as shown below.
- In this examplewe have added one method hello.
package example;
|
- Now implements the remote interface Hello.
- In the bean file override the method hello.
- You can add the following attributes of the Stateless bean
- name
- mappedName
- description
- But in our programm we will use only attribute mappedName
- Add the attribute value Hello .
- This mappedName value Hello will be used in the Client code.
package example;
|
Ejb3 application deployment
- Right click on the given project
- Select Run As-->Run On Server.
- Select Oracle Weblogic Server.
- Click on the finish button.
- It starts the server and deploy the given project
WebClient
- Now we will create a web client for the given Ejb program.
- Create a Dynamic Web project
- Put it name as ejb3webclient.
Setting build path for EJB3
- Right Click on the Web project as shwon below
- Select Build Path-->Configure Build Path.
- In the opening window navigate to the Projects tab.
- Now we can set the required project in its build path.
- Click on the Add button.
- Select the ejb3 project.
- Click on the Ok.
- Now create one file client.jsp.
- Add the following code in it.
- This jsp file is having two part
- One form part
- Businesss logic part
- Upon clicking on submit button the form will call the business code.
- This form is calling itself.
<%@ page import="example.* , javax.naming.* , java.text.*, java.util.Properties" %>
|
ejb jar file Creation
Web Client will require ejb file for communication.
So we will put this jar file in the Web Application lib folder.
- Right Click on the proejct ejb3.
- Select Export--->EJB JAR file.
- Select the location where you want to keep the jar file created.
- We have selected Desktop.
- Click on the finish button.
- Now copy the ejb3.jar file from Desktop.
- Expand the ejb3webclient that we have created
- Navigate to WebContent-->WEB-INF-->lib
- Right click and paste it here
Running the Client
- Right Click on the client.jsp
- Select Run As-->Run On Server
- This will deploy the web application on the server.
- After deployement it will start the browser.
- Now put the name
- Click on submit button
- It calls the ejb application.
- Then passes the value to it.
- After processing the result it gives the output.
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి