JaiswalTraining

Get the online training



Corejava Servlet Jsp  Php  Hibernate  Ajax Web Service   Ejb2.1 Ejb3.0 Struts Struts2  JPA Spring Ibatis   JSF    JSF2.0  CoreJavaDesignPattern    Jquery  Flex J2EE-Design-Patterns  Jboss7  Maven  Contact Me                                                                                                                                                                        
            IGNOU SMU PTU Project                                           Training                                                                                                                              
              

Contact Us  0091- 9210721663         jaiswaltraining@gmail.com




Corejava
Servlet
Jsp
Php
Hibernate
Ajax
Web Service
Ejb2.1
Ejb3.0
Struts  
Struts2
JPA
Spring
Ibatis
JSF
JSF2.0
CoreJavaDesignPattern
Jquery
Flex
J2EE-Design-Patterns
Jboss7
Maven









Ejb3 project on RAD
  • EJB3 can be created on the RAD7.5
  • We can create all types of ejb3 program such as
    • Session Bean
    • Entity Bean
    • Message Driven Bean
In this tutorial we will make the use of Session Bean
Session Bean is of two types
  • Stateful
  • Stateless
Both types can be created using the annotation

  • Take a new Enterprise Application Porject



  • Type the name of the project as CalculatorDemo
  • Select the Target Runtime as Websphere Application Server v7.0




  • Now right click on the CalculatorDemo
  • Select New-->EJB Project.



  • Type the name of the project as Calculator.
  • Select the Target Runtime as Websphere Application Server v7.0
  • Select the EJB Module version 3.0


  • Click on the Finish Button.
  • It creates the following two modules.
    • Calculator
    • CalculatorClient



  • Now create the Session Bean
  • Right Click on Session Beans
  • New--->Session Bean




  • Type Class name as Calc.
  • Type the package name as operation.
  • Select the Remote check Box
  • It will create Remote interface else it will create Local Interface.
  • Click on the next Button.



  • Select the transaction type as Container
  • Uncheck the
    • Inherited abstract methods
    • Constructors from the superclass
      Under Home and Components interface(EJB2.x)

    • This step will stop creation of home interface which is not required in ejb3.


  • Click on the Finish Button
  • This will create the following structure
  • Calc.java (stateless bean file) gets created in Calculator module
  • CalcRemote.java (stateless bean file) gets created in CalculatorClient module





  • Open the CalcRemote File.
  • Add the following methods in it.
package operation;
import javax.ejb.Remote;

@Remote
public interface CalcRemote {
public int add(int a,int b);
}


package operation;

import javax.ejb.Stateless;
@Stateless
public class Calc implements CalcRemote {

  public int add(int a,int b){
    return a+b;
  }
}





Download CalculatorDemo EAR code

Download Calculator code

Download CalculatorClient code