5 Replies Latest reply on Dec 28, 2006 4:21 AM by priyavijayan1

    help required for JBOSS 4.0.4 GA and EJB 3.0 RC9

    priyavijayan1

      Hi,

      I am having a problem with EJB 3.0 . I am using
      EJB-3.0_RC9-FD
      jboss-4.0.4.GA
      jdk 1.5
      ant 1.6.5


      package com.EJB3.application;

      import com.EJB3.application.FacadeRemote;
      import javax.naming.InitialContext;
      import java.sql.Timestamp;

      CODE

      public class client
      {
      public static void main(String[] args)
      {
      try
      {
      InitialContext ctx = new InitialContext();

      ctx.addToEnvironment("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      ctx.addToEnvironment("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      ctx.addToEnvironment("java.naming.provider.url","jnp://localhost:1099");
      System.out.println("<------"+FacadeRemote.class.getName()+"------->");

      FacadeRemote lFacadeRemote = (FacadeRemote) ctx.lookup(FacadeRemote.class.getName());

      lFacadeRemote.createDepartment("Finance");
      lFacadeRemote.createDepartment("Administration");
      lFacadeRemote.createDepartment("Sales");

      lFacadeRemote.assignEmployeeToDepartment(new Long(1),"Brijesh",31,"M");
      lFacadeRemote.assignEmployeeToDepartment(new Long(1),"xxxx",31,"M");
      lFacadeRemote.assignEmployeeToDepartment(new Long(2),"yyyy",31,"M");

      }
      catch(Exception ex)
      {
      System.out.println(ex);
      }
      }
      }

      and the run time exception I am getting is

      Buildfile: C:\prototype\EJB3.0\application\build.xml
      [echo] -------------1-----------
      run:
      [echo] -------------2-----------
      [java] <------com.EJB3.application.FacadeRemote------->
      [java] javax.naming.NameNotFoundException: com.EJB3.application.FacadeRemote not bound
      prepare:
      [echo] C:\jboss-4.0.4.GA
      prepare:
      [echo] C:\jboss-4.0.4.GA
      compile:
      deploy:
      BUILD SUCCESSFUL
      Total time: 28 seconds

      Please help....

        • 1. Re: help required for JBOSS 4.0.4 GA and EJB 3.0 RC9
          abuayyub

          goto the jboss admin via the web browser and check the name that the bean has bean placed under in the jndi tree. if you have deployed a jar in an ear, then the name may be preceded by the ear name in jndi. so check http://localhost:8080 and view the jmx entries for you bean.

          • 2. Re: help required for JBOSS 4.0.4 GA and EJB 3.0 RC9
            priyavijayan1

            Thanks for your reply.. I have already done that, I went to the JNDI view and the bean is not there.When i checked the server log of jboss, it says ejb3 is not registered.
            One more thing I noticed is that before installing EJB3, when i start the jboss it runs fine and the console doesn't show any error, but after installing jboss-EJB-3.0_RC9-FD, when i start the jboss the console shows a lot of exceptions saying mbeans are already registered.Am i doing something wrong?? I am deploying it on the default server of jboss... is it something to do with jboss installation?? Please reply.

            • 3. Re: help required for JBOSS 4.0.4 GA and EJB 3.0 RC9
              abuayyub

              This does look like an instalation problem. did you install jboss using the installer. If not then i think you have to look at the jboss wiki on how to migrate from ejb3 RC8 to RC9. there are some differences you need to take into acount. I think ejb 3.0 RC9 is part of the 4.0.5 the latest jboss version.

              http://wiki.jboss.org/wiki/Wiki.jsp?page=FromRC8RC9
              http://docs.jboss.org/ejb3/

              regards abuayyub

              • 4. Re: help required for JBOSS 4.0.4 GA and EJB 3.0 RC9
                palam

                I am using 4.0.5 the latest jboss version but still facing same problem please help me out

                • 5. Re: help required for JBOSS 4.0.4 GA and EJB 3.0 RC9
                  priyavijayan1

                  I got it resolved. I am pasting the code over here

                  package com.infosys.EJB3.application;

                  import com.infosys.EJB3.application.FacadeRemote;
                  import com.infosys.EJB3.application.FacadeBean;

                  import javax.naming.InitialContext;
                  import java.sql.Timestamp;
                  import java.util.Properties;

                  public class client
                  {
                  public static void main(String[] args)
                  {
                  try
                  {
                  Properties p = new Properties();
                  p.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
                  p.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
                  p.setProperty("java.naming.provider.url","localhost:1099");
                  InitialContext ctx = new InitialContext(p);

                  System.out.println("Got initial COntext "+ctx.lookup("FacadeBean/remote"));
                  FacadeRemote lFacadeRemote = (FacadeRemote) ctx.lookup("FacadeBean/remote");
                  System.out.println("Got Facade Remote Bean");
                  // Added
                  lFacadeRemote.checkUserCredential("rama", "ramaxyz");
                  System.out.println("user checked");
                  // end
                  //lFacadeRemote.createDepartment("Marketing");
                  /*lFacadeRemote.createDepartment("Administration");
                  lFacadeRemote.createDepartment("Sales");*/

                  /*lFacadeRemote.assignEmployeeToDepartment(new Long(1),"Brijesh",31,"M");
                  lFacadeRemote.assignEmployeeToDepartment(new Long(1),"xxxx",31,"M");
                  lFacadeRemote.assignEmployeeToDepartment(new Long(2),"yyyy",31,"M");*/
                  System.out.println("DONE");
                  }
                  catch(Exception ex)
                  {
                  System.out.println(ex);
                  ex.printStackTrace();
                  }
                  }
                  }


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


                  The change that I have made is adding the properties instance. I have another file in my directory called jndi.properties, but I still had to put it inside my code. I am not sure why I need to do it since I already have jndi.properties.... anyways its working fine..

                  Thanks for the reply..