javax.naming.NameNotFoundException

Discussion in 'Java' started by cheepu, Oct 12, 2010.

  1. cheepu

    cheepu

    Joined:
    Oct 12, 2010
    Messages:
    2
    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, Oct 12, 2010
    #1
    1. Advertising

  2. cheepu

    cheepu

    Joined:
    Oct 12, 2010
    Messages:
    2
    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);}
    }
    }
     
    cheepu, Oct 12, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jef
    Replies:
    0
    Views:
    730
  2. jonck
    Replies:
    1
    Views:
    18,156
    gimme_this_gimme_that@yahoo.com
    Feb 3, 2005
  3. Harman
    Replies:
    1
    Views:
    2,525
    Moiristo
    Jul 28, 2006
  4. Akaketwa
    Replies:
    2
    Views:
    9,247
    Akaketwa
    Oct 4, 2006
  5. aalberani@gmail.com
    Replies:
    0
    Views:
    943
    aalberani@gmail.com
    Jun 28, 2008
Loading...

Share This Page