problems with java naming

Discussions

EJB programming & troubleshooting: problems with java naming

  1. problems with java naming (3 messages)

    Hi,

    I am trying to create a simple application using Stateless Session Beans, Struts and Hibernate. I use the JBoss Applications server. Everytime I perform a lookup, the program gives me the following error:

    Exception ---> javax.naming.NameNotFoundException: ejb not bound

    I tried many different xml configurations, but none of them seem to work. Here are details of various xml files.

    web.xml:
    ------------------------------
    <web-app>

    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
    <param-name>debug</param-name>
    <param-value>2</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    </web-app>

    --------------------
    jboss.xml
    --------------------

    <jboss>
    <enterprise-beans>
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>SchoolEJB</display-name>
    <ejb-name>SchoolEJB</ejb-name>
    <home>src.SchoolHome</home>
    <remote>src.School</remote>
    <ejb-class>src.SchoolEJB</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
    </session>
    </enterprise-beans>

    <ejb-ref>
    <ejb-ref-name>ejb/SchoolEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>src.SchoolHome</home>
    <remote>src.School</remote>
    <ejb-link>SchoolEJB</ejb-link>
    </ejb-ref>
    </jboss>

    ---------------
    ejb-jar.xml
    ---------------

    <ejb-jar >
    <enterprise-beans>
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>SchoolEJB</display-name>
    <ejb-name>SchoolEJB</ejb-name>
    <home>src.SchoolHome</home>
    <remote>src.School</remote>
    <ejb-class>src.SchoolEJB</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
    </session>
    </enterprise-beans>

    </ejb-jar>

    -------------------------
    The client program uses the following lookup options:
    ---------------------------

    Context ctx = getInitialContext();
    Object objref = ctx.lookup("ejb/SchoolEJB");
    mySchoolHome = (SchoolHome) PortableRemoteObject.narrow(objref, SchoolHome.class);

    private Context getInitialContext() throws NamingException
    {
    Properties properties = null;
    String error = "";
    properties = new Properties();
    properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
    properties.put("java.naming.provider.url", "jnp://localhost:1099");
    properties.put("java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces");
    try
    {
    return new InitialContext(properties);
    }
    catch (NamingException e)
    {
    System.out.println("ERROR_DTO " +
    e.getMessage());
    error = "error.servidor.general";
    throw new NamingException(error);
    }
    }

    --------------------------------------

    Please help me out if anyone knows the solution.

    Thanks.

    Threaded Messages (3)

  2. problems with java naming[ Go to top ]

    Try to use:

    Context ctx = getInitialContext();
    Object objref = ctx.lookup("java:comp/env/ejb/SchoolEJB");
  3. problems with java naming[ Go to top ]

    Hi Viktor,

    I already tried doing that, but such a configuration gives me errors.
  4. In case of the web client[ Go to top ]

    Try Placing jbossall-client.jar in the Lib of the web App
    you shall find this jar in the client folder of JBoss\<config-name>\