JBoss Community

Servlet calling EJB3 Session Bean without JNDI

modified by R Saravana Prasad in Beginner's Corner - View the full document


Hi,

 

This article is about a Servlet call to injected EJB3 Session Bean.

Note that JNDI calls are not required.
The application in attachment will work fine with JBoss-5.1.0.GA_JDK6/ JDK1.6.0_21.

 

The application can be reached at http://<IPAddress>:8080/servletejb3
welcome file is a jsp file, which submits a form with user input to the servlet.
The Servlet calls the session bean which returns a value in uppercase
which is reloaded into the textbox in the same JSP.

 

Schema of web.xml:

 

<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     

Schema of ejb-jar.xml:

 

<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
         version="3.0">

 

Schema of application.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
             version="5">

 

Extract the attachment and run ant deploy after modifying the script
to point to your environment's jboss home.

 

Fire up the JBoss and pull up the app.

 

Thanks

 


Saravana Prasad

Comment by going to Community

Create a new document in Beginner's Corner at Community