EJB 3.1 Servlet Web Application

EJB 3.1 Servlet Web Application

In this tutorial you will see how to develop Hello World web application using EJB 3.1 with servlet. Below is new feature of EJB 3.1:

  • Main feature of EJB 3.1 is no interfaces are needed. When you develop Stateful or Stateless bean just you need to annotate with @Stateless or @Stateful. This minimizes headache of creating interfaces every time and define all methods from the bean class.
  • Also if you are using this version you don’t need to package your application inside EAR file and you could include your EJB inside WAR file and deploy on the server. You will see in this demo we will deploy EJB as web application.

Below are needed:

  • JBoss Application Server 6.1 community version
  • Eclipse 3.3 or up (For this demo we have used Kepler)


  • Create Dynamic web project name: EJB. Below are steps:

2014-12-21_13092014-12-21_2203 2014-12-21_2203_001 2014-12-21_2204

  •  Final project structure:


  • EJBNoInterfaceBean.java

  • EJBHelloServlet.java

  • To run this project you will have to configure JBoss server to eclipse and if are not sure how to do it please use this tutorial. Now to run project on JBoss server –> Right click Project –> Run As –> Run on Server
  • Once server is started please enter below URL of servlet to get output from EJB:


  • For more information on EJB 3 please use this link

download Download Project: EJB

Leave a Reply

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

I am not Robot *