javax.naming.NameNotFoundException

Joined
Oct 12, 2010
Messages
2
Reaction score
0
Hi
I am new to ejb. I tried to run the code from the link

I created a jar with greetBean.class greetHome.class and greetRemote.class and put the ejb-jar.xml and jboss.xml in META-INF folded and created a jar and deployed in JBOSS5.

********* code of ejb-jar.xml ********

<?xml version="1.0"?>

<ejb-jar>
<enterprise-beans>]
<session>
<ejb-name>greetBean</ejb-name>
<home>greetHome</home>
<remote>greetRemote</remote>
<ejb-class>greetBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>
Container </transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

************* code of jboss.xml ********************/

<?xml version='1.0' ?>


<jboss>
<enterprise-beans>
<entity>
<ejb-name>greetBean</ejb-name>
<jndi-name>greetJndi</jndi-name>
</entity>
</enterprise-beans>
</jboss>


Now from Tomcat I am tring to access this bean. For this I created a servlet whose code is given below.
But I am getting the following error in the tomcat server screen
"javax.naming.NameNotFoundException: greetJndi not bound"

I am not getting this is the configuration eror or the directory structure of jar that I deploied in JBoss is wrong.
Any one can help to resolve the problem?
Thanks
 
Joined
Oct 12, 2010
Messages
2
Reaction score
0
Code for the Servlet class is as follows:

public class greetServlet extends HttpServlet
{
public void doPost
(
HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
try
{
Properties props=new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:eek:rg.jnp.interfaces");
System.out.println("Properties ok");
Context ctx=new InitialContext(props);
System.out.println("context ok");
greetHome home = (greetHome)
ctx.lookup("greetJndi");
System.out.println("home ok");
greetRemote remote=home.create();
System.out.println("remote ok");
String a = req.getParameter("text1");
String s = remote.greetme(a);
System.out.println(s);
out.println(s);
}
catch(Exception e)
{
System.out.println(""+e);}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top