4 Replies Latest reply on May 22, 2013 11:53 PM by sonu1311

    Can access EJB from JSP but not from java class in ear/lib/myclasses.jar in AS 7.1.1

    sonu1311

      I am trying to migrate our existing EAR application to Jboss 7.1.1 and  faced couple of issues and paused at this one right now. we have an EAR/ MyEJB.jar and EAR/ MyWeb.war.

       

      We've few entity beans which seems to getting deployed and then I can sucessfully do a JNDI lookup to one of them through home and can acess the values from bean based on the jndi mapping names provided by the server at deployment time using 'java:global/' through a test.jsp in the war module but when a helper java class tries to do the same which is sitting in the EAR/Lib/Myclasses.jar it throws NameNotFound Exception.

       

      I've tried using the same exact jndi name in the java class and even tried putting the same in the bindings tag of <subsystem xmlns="urn:jboss:domain:naming:1.1"> but it works both ways in JSP only.

       

      Seems to me some sort of JNDI lookup boundary for classes in ear/lib trying to access ejbs?

       

       

      Thanks for any help

        • 1. Re: Can access EJB from JSP but not from java class in ear/lib/myclasses.jar in AS 7.1.1
          jaikiran

          Please post the entire exception stacktrace.

          • 2. Re: Can access EJB from JSP but not from java class in ear/lib/myclasses.jar in AS 7.1.1
            sonu1311

            Here it is

             

            javax.naming.NameNotFoundException: MyApp/MyAppEJB/SystemProfileEJB!sync.server.system.SystemProfileHome -- service jboss.naming.context.java.global.MyApp.MyAppEJB."SystemProfileEJB!sync.server.system.SystemProfileHome"

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

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

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

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

              at javax.naming.InitialContext.lookup(Unknown Source) [rt.jar:1.6.0_33]

              at sync.server.util.SyncConfig.init(SyncConfig.java:522) [MyAppClasses.jar:]

              at sync.server.util.SyncConfig.getDocumentRootPath(SyncConfig.java:685) [MyAppClasses.jar:]

              at sync.server.action.ui.FileTemplateLoader.init(FileTemplateLoader.java:40) [MyAppWeb.jar:]

              at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:147) [velocity-1.5.jar:1.5]

              at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:594) [velocity-1.5.jar:1.5]

              at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:241) [velocity-1.5.jar:1.5]

              at org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:113) [velocity-1.5.jar:1.5]

              at org.apache.velocity.app.Velocity.init(Velocity.java:83) [velocity-1.5.jar:1.5]

              at org.apache.velocity.tools.view.servlet.VelocityViewServlet.initVelocity(Unknown Source) [velocity-tools-1.1.jar:]

              at org.apache.velocity.tools.view.servlet.VelocityViewServlet.init(Unknown Source) [velocity-tools-1.1.jar:]

              at sync.server.action.ui.MyAppTemplateServlet.init(MyAppTemplateServlet.java:40) [MyAppWeb.jar:]

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

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

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

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

              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.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(Unknown Source) [rt.jar:1.6.0_33]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_33]

              at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_33]

             

            Thanks

            • 3. Re: Can access EJB from JSP but not from java class in ear/lib/myclasses.jar in AS 7.1.1
              jaikiran

              Like I thought, you are doing that lookup from a load-on-startup servlet in its inti method. The EJBs may not yet be bound at that point. You can instead use @EJB injection in that servlet to inject that bean instead of looking it up, so that the container automatically adds that dependency or you can use initialize-in-order in your application.xml and have the EJB module listed before the war module.

              • 4. Re: Can access EJB from JSP but not from java class in ear/lib/myclasses.jar in AS 7.1.1
                sonu1311

                Thanks for the quick help.