Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   javax.naming.NameNotFoundException (http://www.velocityreviews.com/forums/t735267-javax-naming-namenotfoundexception.html)

cheepu 10-12-2010 07:23 AM

javax.naming.NameNotFoundException
 
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

cheepu 10-12-2010 07:24 AM

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:org.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);}
}
}


All times are GMT. The time now is 12:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.