5 Replies Latest reply on Sep 16, 2008 3:19 PM by lincoln__a

    JBOSS 4.0.2 and EJB 2.1 - simple application - not working

    lingareddy

      I am doing first ejb program on jboss 4.0.2. i deployed ejb module successfully. but client program (web application ) giving error. i am trying to call local ejb.


      Error

      javax.naming.NamingException: ejb-local-ref: 'ejb/ejb2', with web.xml ejb-link: 'HelloBean' failed to resolve to an ejb with a LocalHome)


      ejb-jar.xml

      <enterprise-beans>
       <session>
      
       <ejb-name>alr</ejb-name>
       <home>com.HelloHome</home>
       <remote>com.Hello</remote>
       <local-home>com.HelloLocalHome</local-home>
       <local>com.HelloLocal</local>
       <ejb-class>com.HelloBean</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
       </session>
       </enterprise-beans>
      </ejb-jar>



      jboss.xml

      <jboss>
       <enterprise-beans>
       <session>
       <ejb-name>alr</ejb-name>
       <jndi-name>jndi</jndi-name>
       <method-attributes></method-attributes>
       </session>
       </enterprise-beans>
       <assembly-descriptor></assembly-descriptor>
       <resource-managers>
      
       </resource-managers>
      </jboss>


      web.xml ejb related code

      <ejb-local-ref>
       <ejb-ref-name>ejb/alr</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <local-home>com.HelloLocalHome </local-home>
       <local>com.HelloLocal</local>
       <ejb-link>HelloBean</ejb-link>
       </ejb-local-ref>



      jboss-web.xml

      <ejb-ref>
       <ejb-ref-name>ejb/alr</ejb-ref-name>
       <local-jndi-name>jndi</local-jndi-name>
      
       </ejb-ref>
      


      client jsp page

      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY,
       "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.URL_PKG_PREFIXES,
      "org.jboss.naming:org.jnp.interfaces");
      props.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
      
      
       Context ctx = new InitialContext(props);
      
       System.out.println("It;s ok");
      
      
       HelloLocalHome home=(HelloLocalHome) ctx.lookup("java/env/ejb/alr");
       HelloLocal bean = home.create();
       String hello= bean.hello();
       bean.remove();
       ctx.close();



      What is the wrong in above code. Please tell me. I have been trying for this.

      some issues:

      1. If i don't write optional jboss.xml what is the optional jndi name for jboss4.0.2

      2. while calling local ejb on same machine, jndi properties are not required. can you confirm?


      Advanced thanks. Please give answer


        • 1. Re: JBOSS 4.0.2 and EJB 2.1 - simple application - not worki
          jaikiran

          From the web.xml, remove this:

          <ejb-link>HelloBean</ejb-link>



          • 2. Re: JBOSS 4.0.2 and EJB 2.1 - simple application - not worki
            lingareddy

             

            
             nested throwable: (javax.naming.NamingException: ejb-local-ref: 'ejb/alr', no ejb-link in web.xml and no local-jndi-name in jboss-web.xml)
            
            



            If i remove ejb-link i am getting above error. could you tell jndi configuration for local bean and remote bean. Advaced Thanks!

            • 3. Re: JBOSS 4.0.2 and EJB 2.1 - simple application - not worki
              jaikiran

              Just looked at your post again. Your jboss-web.xml contents is incorrect:

              <ejb-ref>
               <ejb-ref-name>ejb/alr</ejb-ref-name>
               <local-jndi-name>jndi</local-jndi-name>
              
               </ejb-ref>


              This should be a ejb-local-ref and not ejb-ref. Change it to:

              <ejb-local-ref>
               <ejb-ref-name>ejb/alr</ejb-ref-name>
               <local-jndi-name>jndi</local-jndi-name>
              
               </ejb-local-ref>


              • 4. Re: JBOSS 4.0.2 and EJB 2.1 - simple application - not worki
                lingareddy

                Thanks for your reply. nope. same error.


                can you tell jndi configuration settings for jboss 4.0.2.
                i am trying to call local ejb. jndi properties are required or not?


                I am getting same error-Reason?

                • 5. Re: JBOSS 4.0.2 and EJB 2.1 - simple application - not worki
                  lincoln__a



                  Hi Friends,

                  Still i have beeen strugging to find solution.


                  I am running the local ejb from command prompt in same JVM. For this no need jndi.properties file and jboss.xml. Pleae cinfirm it. Direct i am looking home interface in look up.

                  setting following jar files at command prompt.

                  set path=path%; c:...

                  set classpath=%classpath;
                  C:\jboss-4.0.2\jboss-4.0.2\server\default\lib\jboss-j2ee.jar;
                  C:\jboss-4.0.2\jboss-4.0.2\server\default\lib\jboss.jar;
                  C:\jboss-4.0.2\jboss-4.0.2\server\default\lib\jboss-transaction.jar;
                  C:\jboss-4.0.2\jboss-4.0.2\server\default\lib\jnpserver.jar;
                  C:\jboss-4.0.2\jboss-4.0.2\server\default\lib\jboss-common.jar;

                  Confirm these jars are enough or any jar is missed?



                  But it is not working.


                  Please kindly provide client jndi looku up code for local bean calling at command prompt and jar file required for jnoss 4.0.2 to rin ejb 2.1 at clinet?