1 2 Previous Next 26 Replies Latest reply on Mar 15, 2012 4:55 PM by thinksteep thinksteep Branched from an earlier discussion.

    NameNotFoundException for remote EJB lookup in AS7

    thinksteep thinksteep Novice

      Hi Prasad and Community,

       

      Now I need to some help with EJB lookup. Some of our code related to Remote EJB lookup is not working. I am getting NameNotFoundException.

       

      jboss.naming.context.java.ConfigRemote: javax.naming.NameNotFoundException: ConfigRemote -- service jboss.naming.context.java.ConfigRemote

          at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)

          at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:113)

          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)

          at javax.naming.InitialContext.lookup(InitialContext.java:392) [rt.jar:1.6.0_16]

       

      I check jaikiran tutorial on this, https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI. Only difference I see from his tutorial to my code is, I am using following code for InitialContext.

       

              p.put(Context.INITIAL_CONTEXT_FACTORY,

                    "org.jboss.as.naming.InitialContextFactory");

              p.put(Context.PROVIDER_URL, NamingProperties.getInstance().getBeanJNDIName("PROVIDER_URL"));

       

      PROVIDER_URL is "jnp://localhost:1099" in prop file.

       

      Any pointers?

       

      Attached complete server.log

       

       

      Thank you,

        • 1. Re: NameNotFoundException for remote EJB lookup in AS7
          Prasad Deshpande Expert

          I check jaikiran tutorial on this, https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI. Only difference I see from his tutorial to my code is, I am using following code for InitialContext.

           

                  p.put(Context.INITIAL_CONTEXT_FACTORY,

                        "org.jboss.as.naming.InitialContextFactory");

                  p.put(Context.PROVIDER_URL, NamingProperties.getInstance().getBeanJNDIName("PROVIDER_URL"));

           

          PROVIDER_URL is "jnp://localhost:1099" in prop file.

          Please follow documentation in that URL as it is.. remoting has changed from earlier versions of jboss. Please use the values from that same examples.

           

          JNDI names are strictly standardised as per EE6 naming.. so you can access ConfigRemote like:

           

          ctx.lookup("ejb:Name yyy/yyybusiness/ConfigBean!com.Name.yyy.beans.admin.config.ConfigRemote");

           

          please note that "ejb:" prefix in the begining.

          • 2. Re: NameNotFoundException for remote EJB lookup in AS7
            thinksteep thinksteep Novice

            Thanks for quick reply Prasad,

             

            One thing I am not clear is, do I need to change context creation also (or) just lookup?

             

            Second, I feel it doesn't make sense to hardcode moduleName in my code. Is there any other alternative to avoid hardcoding  appName, moduleName, distinctName?

             

            Thanks for your help and time.

            • 3. Re: NameNotFoundException for remote EJB lookup in AS7
              Wolf-Dieter Fink Master

              If you use "ejb:" you need to have a jboss-elb-client.propetties.

              ==> properties.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

               

              If you want to use it without "ejb:"

              ==> p.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                     p.put(InitialContext.PROVIDER_URL, "remote://localhost:4447");

               

               

              To 'hardcode' the appName.. I prefere a client-api class to hide the details of creating InitialContext and lookup.

              The class provide the (remote) interface and can be created with different IP/port and security constructor or static methods.

              • 4. Re: NameNotFoundException for remote EJB lookup in AS7
                Prasad Deshpande Expert
                One thing I am not clear is, do I need to change context creation also (or) just lookup?

                How are you creating context now?

                All you'd need to do is pass correct values to the corresponding properties. If you are not referring JMS Connection Factory in remote client, then you'll just need "java.naming.factory.url.pkgs=org.jboss.ejb.client.naming" property. but if you are using JMS connection factory in remote client, then following properties needed:

                java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

                java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory

                java.naming.provider.url=remote://localhost:4447

                jboss.naming.client.ejb.context=true

                 

                 

                Second, I feel it doesn't make sense to hardcode moduleName in my code. Is there any other alternative to avoid hardcoding  appName, moduleName, distinctName?

                distinctName is not complusary, you can ignore that, but appName & moduleName is required while doing ejb lookup.

                • 5. Re: NameNotFoundException for remote EJB lookup in AS7
                  thinksteep thinksteep Novice

                  I am creating context like this:

                   

                          Properties p = new Properties();

                          p.put(Context.INITIAL_CONTEXT_FACTORY,

                                "org.jboss.as.naming.InitialContextFactory");

                          p.put(Context.PROVIDER_URL, "PROVIDER_URL");

                          return new InitialContext(p);

                   

                  Using same context for Datasource lookup also. Based on your answers above, it seems I can't use this context for EJB lookup. I need to create new context with ejb specific properties and use it for lookup. Am I correct?

                   

                  Dieter,

                   

                  I didn't get "The class provide the (remote) interface and can be created with different IP/port and security constructor or static methods". If possible can you please elaborate?

                   

                  Thank you  for your time and help!

                  • 6. Re: NameNotFoundException for remote EJB lookup in AS7
                    Wolf-Dieter Fink Master

                    Create a simple class with different constructors and store the given properties inside:

                     

                    MyApi {

                      final InitialContext myICtx;

                     

                    MyAPi(String host) {

                      ... create myCtx with defaults and this host

                    }

                    MyAPI(String host, int port, String user, String passwd) {

                      ... create myCtx with host/post and the user redentials

                    }

                     

                    public MyRemoteEJB getRemoteEJB() {

                      return myCtx.lookup("ejb:MyApp/MyJAR//MyRemoteBean.....");

                    }

                    • 7. Re: NameNotFoundException for remote EJB lookup in AS7
                      thinksteep thinksteep Novice

                      Hi Dieter,

                       

                      I see what you mean. We have this code already in place (we are migrating app from 4.2.3 to 7.1). I was looking to completly avoid "ejb:MyApp/MyJAR//MyRemoteBean....." instead, I was looking for a way to get app name, module name etc., through some API (if any possible) based on Bean I am looking for and construct this lookup string. Any idea?

                       

                      Thanks for your help.

                      • 8. Re: NameNotFoundException for remote EJB lookup in AS7
                        Wolf-Dieter Fink Master

                        MyApi {

                          private final appName;

                          private final jarName;

                          private final distinctName;

                         

                          MyApp(String host, int port ..... String appName, String jarName, String distinctName) {

                           ...

                          }

                         

                          MyApp() {

                            this("localhost",4447, ... , "MyEAR", "MyJAR", "");

                          }

                         

                          public MyRemote getRemote() {

                            lookup("ejb:"+appName+"/"+jarName+"/"+distinctNmae+"/"+MyRemote.class.getSimpleName+"Bean!"+MyRemote.class.getName())

                          }

                         

                         

                        • 9. Re: NameNotFoundException for remote EJB lookup in AS7
                          thinksteep thinksteep Novice

                          Hi Dieter and Community,

                           

                          I am getting IllegalArgumentException when I changed my code according to your suggestions:

                          5:44:13,237 INFO  [org.jboss.ejb.client] (MSC service thread 1-2) JBoss EJB Client version 1.0.2.Final

                          15:44:13,243 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/yyy]] (MSC service thread 1-2) StandardWrapper.Throwable: java.lang.IllegalArgumentException: Could not find module app: Name yyy  module: yyybusiness distinct name:

                              at org.jboss.as.ejb3.remote.LocalEjbReceiver.findBean(LocalEjbReceiver.java:274) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                              at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:109) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:173) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:92) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at $Proxy22.getEnabled(Unknown Source)    at com.name.yyy.delegates.admin.ConfigDelegate.getEnabled(ConfigDelegate.java:59) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                              at com.name.yyy.delegates.schedule.AlertAutoDeleteSchedule.startAlertAutoDeleteSchedule(AlertAutoDeleteSchedule.java:41) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                              at com.name.yyy.webapp.servlets.InitServlet.init(InitServlet.java:180) [classes:]

                              at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]

                              at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.10.Final.jar:]

                              at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.10.Final.jar:]

                              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.10.Final.jar:]

                              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_16]

                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_16]

                              at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_16]

                           

                          15:44:13,262 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/yyy]] (MSC service thread 1-2) Servlet /yyy threw load() exception: java.lang.IllegalArgumentException: Could not find module app: Name yyy  module: yyybusiness distinct name:

                              at org.jboss.as.ejb3.remote.LocalEjbReceiver.findBean(LocalEjbReceiver.java:274) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                              at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:109) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:173) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:92) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                              at $Proxy22.getEnabled(Unknown Source)    at com.name.yyy.delegates.admin.ConfigDelegate.getEnabled(ConfigDelegate.java:59) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                              at com.name.yyy.delegates.schedule.AlertAutoDeleteSchedule.startAlertAutoDeleteSchedule(AlertAutoDeleteSchedule.java:41) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                              at com.name.yyy.webapp.servlets.InitServlet.init(InitServlet.java:180) [classes:]

                              at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]

                              at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.10.Final.jar:]

                              at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.10.Final.jar:]

                              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.10.Final.jar:]

                              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_16]

                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_16]

                              at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_16]

                           

                          15:44:13,288 INFO  [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /yyy

                          15:44:13,550 INFO  [stdout] (Finalizer) log4j: Finalizing appender named [CONSOLE_LOGGER].

                           

                           

                          My InitialContext and lookup code is:

                           

                          public ConfigRemote getConfigRemote() {

                                  try

                                  {

                                      Context initialContext =getInitialContext();

                                         Object ref = initialContext.lookup("ejb:Name yyy/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote");

                                  return (ConfigRemote) ref;

                                  }catch(Exception e)

                                  {

                                      System.out.println(e);

                                      return null;

                                  }

                           

                              }

                               private Context getInitialContext() throws NamingException {

                                  Properties p = new Properties();

                                  final Hashtable jndiProperties = new Hashtable();

                                  jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                                  final Context context = new InitialContext(jndiProperties);

                                  return context;

                              }

                           

                           

                          This context lookup code is deployed as JAR at EAR---Lib level.

                           

                          Could this be because of space in my app name? name yyy is my app name defined in application.xml.  Any help would be appreciated.

                           

                          Thanks for your help.

                          • 10. Re: NameNotFoundException for remote EJB lookup in AS7
                            jaikiran pai Master

                            You are trying to lookup a bean from one server to another?

                            • 11. Re: NameNotFoundException for remote EJB lookup in AS7
                              thinksteep thinksteep Novice

                              Hi Jaikiran,

                               

                              No. This on same instance. Same EAR file. EJBs are in yyybusiness.jar and client is (delegate) in a JAR which is inside EAR--Lib folder.

                               

                              Thank you,

                              • 12. Re: NameNotFoundException for remote EJB lookup in AS7
                                jaikiran pai Master

                                Then you don't need any of this EJB client configuration. All you have to do is lookup using the EJB3.1 spec provided JNDI names that you'll see logged in your server log. For example, the java:global one.

                                 

                                Just do:

                                 

                                Properties props = new Properties();

                                props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");

                                Context ctx = new InitialContext(props);

                                ctx.lookup("java:global/<the rest of the jndi name>");

                                • 13. Re: NameNotFoundException for remote EJB lookup in AS7
                                  thinksteep thinksteep Novice

                                  Hi Jaikiran,

                                   

                                  When I try as you suggested I am getting NameNotFoundException. Here is stack trace:

                                  09:28:13,223 INFO  [stdout] (MSC service thread 1-1) javax.naming.NameNotFoundException: name yyy/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote -- service jboss.naming.context.java.global."name yyy".yyybusiness."ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote"

                                   

                                  09:28:13,225 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/yyy]] (MSC service thread 1-1) StandardWrapper.Throwable: java.lang.NullPointerException

                                      at com.name.yyy.delegates.admin.ConfigDelegate.getEnabled(ConfigDelegate.java:60) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                      at com.name.yyy.delegates.schedule.AlertAutoDeleteSchedule.startAlertAutoDeleteSchedule(AlertAutoDeleteSchedule.java:41) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                      at com.name.yyy.webapp.servlets.InitServlet.init(InitServlet.java:180) [classes:]

                                      at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                                      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]

                                      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.10.Final.jar:]

                                      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.10.Final.jar:]

                                      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.10.Final.jar:]

                                      at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

                                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_16]

                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_16]

                                      at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_16]

                                   

                                  09:28:13,237 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/yyy]] (MSC service thread 1-1) Servlet /yyy threw load() exception: java.lang.NullPointerException

                                      at com.name.yyy.delegates.admin.ConfigDelegate.getEnabled(ConfigDelegate.java:60) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                      at com.name.yyy.delegates.schedule.AlertAutoDeleteSchedule.startAlertAutoDeleteSchedule(AlertAutoDeleteSchedule.java:41) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                      at com.name.yyy.webapp.servlets.InitServlet.init(InitServlet.java:180) [classes:]

                                      at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                                      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]

                                      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.10.Final.jar:]

                                      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.10.Final.jar:]

                                      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.10.Final.jar:]

                                      at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

                                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_16]

                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_16]

                                      at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_16]

                                   

                                  09:28:13,254 INFO  [org.jboss.web] (MSC service thread 1-1) JBAS018210: Registering web context: /yyy

                                  09:28:13,542 INFO  [stdout] (Finalizer) log4j: Finalizing appender named [CONSOLE_LOGGER].

                                   

                                   

                                  I could see in server.log that ConfigRemote is binded.  Here is log entry:

                                   

                                   

                                  09:28:11,128 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named ConfigBean in deployment unit subdeployment "yyybusiness.jar" of deployment "NameyyyAdmin.ear" are as follows:

                                   

                                      java:global/name yyy/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote

                                      java:app/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote

                                      java:module/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote

                                      java:jboss/exported/name yyy/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote

                                      java:global/name yyy/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigLocal

                                      java:app/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigLocal

                                      java:module/ConfigBean!com.name.yyy.beans.admin.config.ConfigLocal

                                   

                                  And here is my code for lookup:

                                   

                                  public ConfigRemote getConfigRemote() {

                                          try {

                                              Context initialContext = getInitialContext();

                                              Object ref = initialContext.lookup("java:global/Name yyy/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote");

                                              return (ConfigRemote) ref;

                                          } catch (Exception e) {

                                              System.out.println(e);

                                              return null;

                                          }

                                         

                                      }

                                   

                                      private Context getInitialContext() throws NamingException {

                                          Properties props = new Properties();

                                          props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");

                                          Context ctx = new InitialContext(props);

                                          return ctx;

                                      }

                                   

                                  Not sure what I am doing wrong. Please help.

                                  • 14. Re: NameNotFoundException for remote EJB lookup in AS7
                                    thinksteep thinksteep Novice

                                    Hi,

                                     

                                    I treid with app java:app namespace also because my EJB is inside same application, still NameNotFoundException. Here is stack trace:

                                    12:17:39,080 INFO  [stdout] (MSC service thread 1-3) Inside config delegate getInitialContext method

                                     

                                    12:17:39,081 INFO  [stdout] (MSC service thread 1-3) javax.naming.NameNotFoundException: yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote -- service jboss.naming.context.java.app.Nameyyy.yyybusiness."ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote"

                                     

                                    12:17:39,083 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/yyy]] (MSC service thread 1-3) StandardWrapper.Throwable: java.lang.NullPointerException

                                        at com.name.yyy.delegates.admin.ConfigDelegate.getEnabled(ConfigDelegate.java:59) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                        at com.name.yyy.delegates.schedule.AlertAutoDeleteSchedule.startAlertAutoDeleteSchedule(AlertAutoDeleteSchedule.java:41) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                        at com.name.yyy.webapp.servlets.InitServlet.init(InitServlet.java:180) [classes:]

                                        at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                                        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]

                                        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.10.Final.jar:]

                                        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.10.Final.jar:]

                                        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.10.Final.jar:]

                                        at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

                                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_16]

                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_16]

                                        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_16]

                                     

                                    12:17:39,094 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/yyy]] (MSC service thread 1-3) Servlet /yyy threw load() exception: java.lang.NullPointerException

                                        at com.name.yyy.delegates.admin.ConfigDelegate.getEnabled(ConfigDelegate.java:59) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                        at com.name.yyy.delegates.schedule.AlertAutoDeleteSchedule.startAlertAutoDeleteSchedule(AlertAutoDeleteSchedule.java:41) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                                        at com.name.yyy.webapp.servlets.InitServlet.init(InitServlet.java:180) [classes:]

                                        at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                                        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.10.Final.jar:]

                                        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.10.Final.jar:]

                                        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.10.Final.jar:]

                                        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.10.Final.jar:]

                                        at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]

                                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_16]

                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_16]

                                        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_16]

                                     

                                    12:17:39,112 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /yyy

                                    12:17:39,410 INFO  [stdout] (Finalizer) log4j: Finalizing appender named [CONSOLE_LOGGER].

                                     

                                    And my lookup code:

                                     

                                    public ConfigRemote getConfigRemote() {

                                            try {

                                                Context initialContext = getInitialContext();

                                                Object ref = initialContext.lookup("java:app/yyybusiness/ConfigBean!com.name.yyy.beans.admin.config.ConfigRemote");

                                                return (ConfigRemote) ref;

                                            } catch (Exception e) {

                                                System.out.println(e);

                                                return null;

                                            }

                                           

                                        }

                                     

                                        private Context getInitialContext() throws NamingException {

                                            System.out.println("Inside config delegate getInitialContext method");

                                            Properties props = new Properties();

                                            props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");

                                           // props.put(Context.PROVIDER_URL, "jnp://localhost:1099");

                                            Context ctx = new InitialContext(props);

                                            return ctx;

                                        }

                                     

                                    Any suggestions:

                                     

                                    Bean class is:

                                     

                                    /**

                                    *

                                    */

                                    @Stateless(name = "ConfigBean", mappedName = "ConfigBean")

                                    @Remote(ConfigRemote.class)

                                    public class ConfigBean implements ConfigLocal, ConfigRemote {

                                    ............................

                                    }

                                     

                                    Remote interface:

                                    @Remote

                                    public interface ConfigRemote extends ConfigDO {}

                                     

                                    Local interface:

                                    /**

                                    *

                                    */

                                    @Local

                                    public interface ConfigLocal extends ConfigDO {}

                                     

                                    Until now migration went sort of smooth except this. I treid most the suggestions available on web and forums, no luck. Please provide some guidance.

                                     

                                    Thanks for your time and help!

                                    1 2 Previous Next