5 Replies Latest reply on Sep 17, 2008 4:00 AM by ajanz

    Error getting CommandServiceBean

    ajanz

      hi

      i got an error trying to find the CommandServiceBean

       String localCommandServiceJndiName
      = "java:comp/env/ejb/LocalCommandServiceBean";
       try {
       Context initial = new InitialContext();
       LocalCommandServiceHome localCommandServiceHome = (LocalCommandServiceHome) initial.lookup(localCommandServiceJndiName);
       LocalCommandService localCommandService = localCommandServiceHome.create()
      
      ;
      


      i copied the code from sources. but localCommandService is null


      when i look at web-console jndiView i see

      jndiName: ejb/CommandServiceBean

      what is my error?



        • 1. Re: Error getting CommandServiceBean
          kukeltje

          My first response would be:

          Your error is that you post to way to little relevant info...

          :-)

          • 2. Re: Error getting CommandServiceBean
            ajanz

            ok what information do you need?

            i generated the initial context with

             Hashtable p = new Hashtable();
             p.put(InitialContext.INITIAL_CONTEXT_FACTORY,
             "org.jnp.interfaces.NamingContextFactory");
             p.put(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
             p.put(InitialContext.URL_PKG_PREFIXES,
             "org.jboss.naming:org.jnp.interfaces");
             jndiContext = new InitialContext(p);
            
            


            i am using an jboss 4.2.2 GA with the jbpm-enterprise.ear deployed



            • 3. Re: Error getting CommandServiceBean
              ajanz

              sorry but still not getting it work

              iterate through the jndi gives me

              Name : java:ejb/CommandServiceBean
              Classe java:ejb/CommandServiceBeanHome

              and

              LocalCommandServiceHome localCommandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:ejb/CommandServiceBean");

              gives me a class cast exception.

              what am i doing wrong?

              • 4. Re: Error getting CommandServiceBean
                salaboy21

                Look.. here i made it thru injection.. but it's the same:

                 @EJB(mappedName="ejb/CommandServiceBean") RemoteCommandServiceHome cmdService;
                
                


                and then in one method:

                 try {
                 cmdService.create().execute(cmd);
                 } catch (CreateException e) {
                 e.printStackTrace();
                 } catch (RemoteException e) {
                 e.printStackTrace();
                 }
                


                You must use RemoteCommandServiceHome because it's EJB 2.1 compatible and then use the method create(), to call the real methods!

                I Hope it helps!

                • 5. Re: Error getting CommandServiceBean
                  ajanz

                  ok i changed it to

                   RemoteCommandServiceHome remoteCommandServiceHome = (RemoteCommandServiceHome) initialContext
                   .lookup("ejb/CommandServiceBean");
                   remoteCMDService = remoteCommandServiceHome.create();
                  


                  but now i got

                  Invalid invocation, check your deployment packaging, method=public abstract org.jbpm.ejb.RemoteCommandService org.jbpm.ejb.RemoteCommandServiceHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException

                  i deployed the jbpm-enterprise.ear on a jboss 4.2.2.