EJB 2 JBoss 5_1 complete example

EJB 2 JBoss 5_1 complete example

If you are trying to understand how EJB 2 works and how to do EJB 2 configuration on Jboss application server. In this demo we will create sample EJB 2 application to add Person in the vector and finally print its value on the console. We are using JBoss 5.1 community edition to deploy our application with eclipse Kepler. Please follow steps below:

  • Create EJB project name: EJB2Project:

EJB 2 JBoss 5_1 complete example

 

EJB 2 JBoss 5_1 complete example

EJB 2 JBoss 5_1 complete example EJB 2 JBoss 5_1 complete example

  • Now you will see EJB2Project in eclipse and below is final project structure:

EJB 2 JBoss 5_1 complete example

  •  Person.java:

  • PersonBean.java:

  • PersonHome.java:

  • PersonClient.java:

  • Now to run this application in JBoss server you will have to first download JBoss 5.1 community version from here then configure JBoss to eclipse using this tutorial. Once you done with configuration right click server –> Add and Remove

EJB 2 JBoss 5_1 complete example

  • Add EJB2Project:

EJB 2 JBoss 5_1 complete example

  • Now right click JBoss server –> clean this will deploy EJB2Project.jar file on JBoss deploy folder. To verify go to jboss-5.1.0.GA\server\default\deploy folder and check if EJB2Project.jar is available or not.
  • Next start the server –> Right click server –> Start and check on console or log if below JNDI name are available:

EJB 2 JBoss 5_1 complete example

  • Finally we are ready to run the client. To run right click PersonClient.java –> Run As –> Java Application enter option 1 to add and 2 to exit you will see below output:

EJB 2 JBoss 5_1 complete example

download Download Project: EJB2Project

Leave a Reply

Your email address will not be published. Required fields are marked *