7 Replies Latest reply on Jun 2, 2015 2:22 PM by jboss234

    Batch job is not finding EJB by JNDI name

    jboss234

      Application is finding EJBs using below naming convention.

      context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + homeInterfaceName);

       

      While running batch job I am getting error : Can not find EJB by JNDI name:

       

      Application is running on wildfly 8.0.2 server and trying to run batch job.

       

      Any suggestions.

       

      Thanks,

        • 1. Re: Batch job is not finding EJB by JNDI name
          jboss234

          any suggestions,

           

          thanks

          • 2. Re: Batch job is not finding EJB by JNDI name
            wdfink

            Not sure whats wrong, what you mean by batch, the JEE7 batching API? Or a simple standalone client as batch?

            Could you elaborate on this?

            • 3. Re: Batch job is not finding EJB by JNDI name
              jboss234

              Simple standalone client as batch.

               

              Standalone java program trying to invoke EJB, its throwing exception while JNDI lookup: Can not find EJB by JNDI name:

              Same JNDI lookup works fine while accessing in Web application.

               

              Thanks,

              • 4. Re: Batch job is not finding EJB by JNDI name
                wdfink

                In the dass you should real the er documentation how to connect to the server. You Meer to usw a jboss-ejb-client.properties file.If you have questions onthat you should attach the Client code.

                • 5. Re: Batch job is not finding EJB by JNDI name
                  jboss234

                  Here is the code, its working fine when I call from struts action which is part of WAR file.

                  Application is deployed as EAR which has WAR and EJB Jar.

                   

                      String homeInterfaceName = AppointmentProcessHome.class.getName();
                        
                     Properties jndiProps = new Properties();
                    
                     jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
                      jndiProps.setProperty(Context.PROVIDER_URL,"remote://localhost:4447");
                      Context context = new InitialContext(jndiProps);
                          Object objref = context.lookup("ejb:PatientInfoEAR/PatientInfoEJB/AppointmentProcessEJB!"+homeInterfaceName);
                          AppointmentProcessHome home = (AppointmentProcessHome)PortableRemoteObject.narrow(objref, AppointmentProcessHome.class);   
                        
                         

                  AppointmentProcess aptProcess = home.create();

                   

                  when I use this code in standalone Java client (called inside main() method) it throws exception:  Can not find EJB by JNDI name:

                   

                  While calling from standalone java clinet, EAR is deployed on Wildfly server and its running.

                  I am trying to run standalone Java client from another command prompt.

                   

                  Thanks

                  • 6. Re: Batch job is not finding EJB by JNDI name
                    jboss234

                    Any suggestions?

                     

                    Thanks,

                    • 7. Re: Batch job is not finding EJB by JNDI name
                      jboss234

                      It worked after adding jboss-ejb-client.properties file in classpath.

                       

                      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

                      remote.connections=default

                      remote.connection.default.host=localhost

                      remote.connection.default.port=8080

                      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

                       

                      Thanks for help,