Discussions

General J2EE: javax.naming.NameNotFoundException: comp not bound

  1. I created a J2EE project named try4 in the Eclipse+Lomboz+JBoss4.0.1sp1, and try4 contains a EJB module named try4_ejb and a WEB module named try4_web. Now,try4_ejb is right.but When I start the JBoss up in the J2EE view, I deployed the try_web, and the following error appears:


    09:33:21,042 WARN [ServiceController] Problem starting service jboss.web.deployment:id=101224132,war=try4_web.war
    org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NameNotFoundException: comp not bound)
    at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:383)
    at org.jboss.web.WebModule.startModule(WebModule.java:62)
    at org.jboss.web.WebModule.startService(WebModule.java:40)

    What should I do to solve the problem??
  2. What name are you trying to bind, exactly, and where?
  3. the version of JBoss I used is 4.0.1sp1, the name of Stateless Bean is MyEJB,and its implementation class is MyEJBBean.java.Following the Lomboz Wizard,I complete the try_ejb module,and I also write a test class named TestFirstEJB.java. I tested the try_ejb module ,it runs well. So I try to write a jsp file to call it. The content of Hello.jsp as follows:
    <%@ page import="javax.naming.*,javax.rmi.PortableRemoteObject,p200506061.*"
    %>
    <%
       try
        {
          Context initial =new InitialContext();
          //use jndi-name
          Object objref=initial.lookup("SampleEjb");
          MyEJBHome home=
          (MyEJBHome)PortableRemoteObject.narrow(objref,MyEJBHome.class);
          
          MyEJB store=home.create();
          out.println(store.Hello());
        }
        catch(Exception e)
        {
          out.println(e);
        }
    %>

    // the jboss. xml is:

    ......
    <jboss>

       <unauthenticated-principal>nobody</unauthenticated-principal>

       <enterprise-beans>

          <session>
             <ejb-name>MyEJB</ejb-name>
             <jndi-name>SampleEjb</jndi-name>
             <local-jndi-name>MyEJBLocal</local-jndi-name>
             
             <ejb-local-ref>
    <ejb-ref-name>ejb/MyEJBLocal</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-jndi-name>MyEJBLocal</local-jndi-name>

    </ejb-local-ref>
          </session>

       </enterprise-beans>

       <resource-managers>
       </resource-managers>

    </jboss>

    //the ejb-jar.xml is :
    ...
    <ejb-jar >

       <description><![CDATA[No Description.]]></description>
       <display-name>Generated by XDoclet</display-name>

       <enterprise-beans>

          <!-- Session Beans -->
          <session >
             <description><![CDATA[<!-- begin-user-doc --> A generated session bean <!-- end-user-doc --> * <!-- lomboz.beginDefinition --> <?xml version="1.0" encoding="UTF-8"?> <lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz"> <lomboz:session> <lomboz:sessionEjb> <j2ee:display-name>MyEJB</j2ee:display-name> <j2ee:ejb-name>SampleEjb</j2ee:ejb-name> <j2ee:ejb-class>p200506061.MyEJBBean</j2ee:ejb-class> <j2ee:session-type>Stateless</j2ee:session-type> <j2ee:transaction-type>Container</j2ee:transaction-type> </lomboz:sessionEjb> </lomboz:session> </lomboz:EJB> <!-- lomboz.endDefinition --> <!-- begin-xdoclet-definition -->]]></description>

             <ejb-name>MyEJB</ejb-name>

             <home>p200506061.MyEJBHome</home>
             <remote>p200506061.MyEJB</remote>
             <local-home>p200506061.MyEJBLocalHome</local-home>
             <local>p200506061.MyEJBLocal</local>
             <ejb-class>p200506061.MyEJBSession</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
             
             <ejb-local-ref>
    <ejb-ref-name>ejb/MyEJBLocal</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>p200506061.MyEJBLocalHome</local-home>
    <local>p200506061.MyEJBLocal</local>
    <ejb-link>MyEJBBean</ejb-link>
    </ejb-local-ref>

          </session>
      </ejb-jar>

    //the web.xml is :

    <web-app>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
    <error-code>404</error-code>
    <location>/error.jsp</location>
    </error-page>

    <ejb-ref>
    <ejb-ref-name>ejb/MyEJBBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>p200506061.MyEJBHome</home>
    <remote>p200506061.MyEJB</remote>
    <!-- ejb-link>MyEJBBean</ejb-link -->
    </ejb-ref>

    </web-app>
  4. OOOS JBOSS known issues[ Go to top ]

    JBoss has a problem of deployment sequence.
    It is not as intelligent like weblogic where deployment dependency is taken care. If everything else is fine then your container seems to be deploying war first before the ejb gets deployed and you are in trouble try deploying like this rename your ejb jar to 1_ejb.jar
    and your webapplication as 2_webapp.war and use deployment sequencing policy.
    This problem gets complicated particularly using local beans.
  5. I have the same problem!![ Go to top ]

    How can I correct this problem?
    what fiels I need to edit?
    Please, help!! :-/