[jboss-user] [Beginner's Corner] - Servlet calling EJB3 Session Bean without JNDI

R Saravana Prasad do-not-reply at jboss.com
Mon Jul 2 03:07:13 EDT 2012


R Saravana Prasad [https://community.jboss.org/people/rsprasad] modified the document:

"Servlet calling EJB3 Session Bean without JNDI"

To view the document, visit: https://community.jboss.org/docs/DOC-16788

--------------------------------------------------------------
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 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 http://java.sun.com/xml/ns/javaee"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd 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 http://java.sun.com/xml/ns/javaee" 
         xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd 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 http://java.sun.com/xml/ns/javaee" 
             xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/application_5.xsd 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
[https://community.jboss.org/docs/DOC-16788]

Create a new document in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2075]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120702/fd0bb13e/attachment.html 


More information about the jboss-user mailing list