7 Replies Latest reply on Mar 21, 2013 5:09 PM by wdfink

    Cannot acquire InitialContext from a Servlet

    ila1905

      I have the following servlet wich arises a NamingException when calling the instruction InitialContext ctx = new InitialContext(jndiProps);

       

      package ejbfrompojoweb;

       

      import java.io.IOException;

      import java.util.Properties;

       

      import javax.naming.Context;

      import javax.naming.InitialContext;

      import javax.naming.NamingException;

      import javax.servlet.ServletException;

      import javax.servlet.annotation.WebServlet;

      import javax.servlet.http.HttpServlet;

      import javax.servlet.http.HttpServletRequest;

      import javax.servlet.http.HttpServletResponse;

       

      import ejbfrompojo.EjbInheritedFromPojoMath;

       

      @WebServlet("/EjbFromPojo")

      public class EjbInheritedFromPojoServlet extends HttpServlet {

          private static final long serialVersionUID = 1L;

          

          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

       

              EjbInheritedFromPojoMath ejbMath = null;

             

              try {           

                  Properties jndiProps = new Properties();

                  jndiProps.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");

                  jndiProps.put("java.naming.provider.url","remote://localhost:4447");

                  jndiProps.put("jboss.naming.client.ejb.context", true);

                  jndiProps.put(Context.SECURITY_PRINCIPAL,"userid");   

                  jndiProps.put(Context.SECURITY_CREDENTIALS, "password");  

                 

                  InitialContext ctx = new InitialContext(jndiProps);   

       

                  ejbMath = (EjbInheritedFromPojoMath)ctx.lookup(

                            "EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoMath");

              } catch (NamingException e) {

                  e.printStackTrace();

              }

             

              request.setAttribute("ejbMath", ejbMath);

             

              request.getRequestDispatcher("/EJBFunctionsResults.jsp").forward(request,response);

          }

      }

       

      This is the exeption log:

       

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.EJBInheritedFromPojoWEB_JB.war:main" from Service Module Loader

       

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.naming.InitialContext.init(InitialContext.java:242)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.naming.InitialContext.<init>(InitialContext.java:216)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at ejbfrompojoweb.EjbInheritedFromPojoServlet.doGet(EjbInheritedFromPojoServlet.java:43)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

      18:34:32,158 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

      18:34:32,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at java.lang.Thread.run(Thread.java:722)

       

      The same code executed from a standalone client works fine.

      I tried to see a lot of Internet sites to find a solution, but uselessly.

      I am working with JBoss AS 7 in Eclipse IDE.

       

      Can someone help me? Thank you very much

        • 1. Re: Cannot acquire InitialContext from a Servlet
          ctomc

          Hi,

           

          why dont you just inject ejb you need, instead of doing manual lookup.

           

          you can just do

           

          @EJB(lookup="name-in-jndi")

          EjbInheritedFromPojoMath ejbMath;

           

          and lookup is optional.

           

          unless you are trying to do remote lookup of ejb (as in, not in same jvm)

           

          in that take a look at https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance

           

           

          --

          tomaz

          • 2. Re: Cannot acquire InitialContext from a Servlet
            wdfink

            You can not use/modify the ejb-client inside the server.

            A new API is provided first in EAP6.1.Alpha.

             

            Have a look to this quickstart, there are examples how to configure a server-to-server ejb call.

            The documentation can be found here (https://docs.jboss.org/author/display/AS72/EJB+invocations+from+a+remote+server+instance)

            • 3. Re: Cannot acquire InitialContext from a Servlet
              ila1905

              Thank you for your reply.

              Your suggest is one of the things I already tried. I tried it again anyway and I get the following deployment log:

               

              11:26:47,156 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "EJBInheritedFromPojoWEB_JB.war"

              11:26:47,185 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.deployment.unit."EJBInheritedFromPojoWEB_JB.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."EJBInheritedFromPojoWEB_JB.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "EJBInheritedFromPojoWEB_JB.war"

                  at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                  at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0]

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0]

                  at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0]

              Caused by: java.lang.RuntimeException: Error getting reflective information for class ejbfrompojoweb.EjbInheritedFromPojoServlet with ClassLoader ModuleClassLoader for Module "deployment.EJBInheritedFromPojoWEB_JB.war:main" from Service Module Loader

                  at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                  at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58)

                  at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:85)

                  at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:70)

                  at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:55)

                  at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                  ... 5 more

              Caused by: java.lang.NoClassDefFoundError: Lejbfrompojo/EjbInheritedFromPojoMath;

                  at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.7.0]

                  at java.lang.Class.privateGetDeclaredFields(Class.java:2308) [rt.jar:1.7.0]

                  at java.lang.Class.getDeclaredFields(Class.java:1760) [rt.jar:1.7.0]

                  at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                  at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                  ... 10 more

              Caused by: java.lang.ClassNotFoundException: ejbfrompojo.EjbInheritedFromPojoMath from [Module "deployment.EJBInheritedFromPojoWEB_JB.war:main" from Service Module Loader]

                  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]

                  at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]

                  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]

                  at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]

                  at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]

                  ... 15 more

               

              11:26:47,206 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "EJBInheritedFromPojoWEB_JB.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"EJBInheritedFromPojoWEB_JB.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"EJBInheritedFromPojoWEB_JB.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"EJBInheritedFromPojoWEB_JB.war\""}}

              11:26:47,208 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment EJBInheritedFromPojoWEB_JB.war in 2ms

              11:26:47,211 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report

              JBAS014777:   Services which failed to start:      service jboss.deployment.unit."EJBInheritedFromPojoWEB_JB.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."EJBInheritedFromPojoWEB_JB.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "EJBInheritedFromPojoWEB_JB.war"

               

              11:26:47,214 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"EJBInheritedFromPojoWEB_JB.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"EJBInheritedFromPojoWEB_JB.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"EJBInheritedFromPojoWEB_JB.war\""}}}}

               

              Here is the new  code of the servlet:

               

              package ejbfrompojoweb;

               

              import java.io.IOException;

              import java.io.PrintWriter;

               

              import javax.ejb.EJB;

              import javax.servlet.ServletException;

              import javax.servlet.annotation.WebServlet;

              import javax.servlet.http.HttpServlet;

              import javax.servlet.http.HttpServletRequest;

              import javax.servlet.http.HttpServletResponse;

               

              import ejbfrompojo.EjbInheritedFromPojoMath;

               

              @WebServlet("/EjbFromPojo")

              public class EjbInheritedFromPojoServlet extends HttpServlet {

                  private static final long serialVersionUID = 1L;

               

                  @EJB(lookup="EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoMath")

                  EjbInheritedFromPojoMath ejbMath;

               

                  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

                     

                      request.setAttribute("ejbMath", ejbMath);

                     

                      request.getRequestDispatcher("/EJBFunctionsResults.jsp").forward(request,response);

                  }

              }

               

              I did modify the annotation of the interface from @Remote to @Local.

               

              where am I doing wrong?

               

              Thank you very much

              • 4. Re: Cannot acquire InitialContext from a Servlet
                ila1905

                I saw tens of examples on ejb  called by servlets through jndi on the Internet and the code to get the context and to lookup the bean interface was the same I used, as if that was the correct method.

                Why doesn't it work in my servlet?

                Thank you

                • 5. Re: Cannot acquire InitialContext from a Servlet
                  nickarls

                  Show all EJB code and the JNDI binding output you see from the deployment log

                  • 6. Re: Cannot acquire InitialContext from a Servlet
                    ila1905

                    Project name: EJBInheritedFromPOJO_JB

                     

                    BusinessLogicPojo.java

                     

                    package ejbfrompojo;

                     

                    import static java.lang.Math.sqrt;

                    import static java.lang.Math.pow;

                    import static java.lang.Math.log;

                     

                    public class BusinessLogicPojo {

                     

                        public double squareRoot(double val) {

                            return sqrt(val);

                        }

                           

                        public double power(double base, double exp) {

                            return pow(base, exp);

                        }

                           

                        public double logarithm(double base, double arg) {

                            return log(arg)/log(base);

                        }

                    }

                     

                     

                    EjbInheritedFromPojoMath.java

                     

                    package ejbfrompojo;

                     

                    import javax.ejb.Remote;

                     

                    @Remote

                    public interface EjbInheritedFromPojoMath {

                     

                        public double squareRoot(double val);

                       

                        public double power(double base, double exp);

                       

                        public double logarithm(double base, double arg);

                    }

                     

                     

                    EjbInheritedFromPojoBean.java

                     

                    package ejbfrompojo;

                     

                    import javax.ejb.Stateless;

                     

                    @Stateless

                    public class EjbInheritedFromPojoBean

                        extends BusinessLogicPojo implements EjbInheritedFromPojoMath {

                     

                        // System.out.println("The Business Logic of this Session Bean is defined in BusinessLogicPojo");

                    }

                     

                     

                    JBoss startup log

                     

                    10:22:26,236 INFO  [org.hornetq.core.server.impl.FileLockNodeManager] (MSC service thread 1-7) Waiting to obtain live lock

                    10:22:26,236 INFO  [org.hornetq.core.server.impl.FileLockNodeManager] (MSC service thread 1-7) Live Server Obtained live lock

                    10:22:26,689 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.2.GA

                    10:22:26,938 INFO  [org.jboss.as.remoting] (MSC service thread 1-6) JBAS017100: Listening on localhost/127.0.0.1:4447

                    10:22:26,938 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /127.0.0.1:9999

                    10:22:26,938 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) JBAS015012: Started FileSystemDeploymentService for directory C:\jboss-as-7.1.1\standalone\deployments

                    10:22:26,985 WARN  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015002: Deployment of 'RoadVehicles.jar' requested, but the deployment is not present

                    10:22:27,001 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found EJBInheritedFromPojoWEB_JB.war in deployment directory. To trigger deployment create a file called EJBInheritedFromPojoWEB_JB.war.dodeploy

                    10:22:27,001 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found EJBInheritedFromPOJO_JB.jar in deployment directory. To trigger deployment create a file called EJBInheritedFromPOJO_JB.jar.dodeploy

                    10:22:27,001 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found CalcEJBProjectJBoss.jar in deployment directory. To trigger deployment create a file called CalcEJBProjectJBoss.jar.dodeploy

                    10:22:27,172 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-7) Started Netty Acceptor version 3.2.5.Final-a96d88c localhost:5455 for CORE protocol

                    10:22:27,172 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-7) Started Netty Acceptor version 3.2.5.Final-a96d88c localhost:5445 for CORE protocol

                    10:22:27,172 Informazioni [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-7) Server is now live

                    10:22:27,172 Informazioni [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-7) HornetQ Server version 2.2.13.Final (HQ_2_2_13_FINAL_AS7, 122) [bb1bca84-69f9-11e2-aeb2-627c20524153]) started

                    10:22:27,188 Informazioni [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-5) trying to deploy queue jms.queue.jms/TestQueue

                    10:22:27,205 INFO  [org.jboss.as.messaging] (MSC service thread 1-5) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/TestQueue

                    10:22:27,205 INFO  [org.jboss.as.messaging] (MSC service thread 1-5) JBAS011601: Bound messaging object to jndi name java:/jms/TestQueue

                    10:22:27,220 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory

                    10:22:27,236 Informazioni [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-8) trying to deploy queue jms.topic.jms/TestTopic

                    10:22:27,283 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-2) JBAS010406: Registered connection factory java:/JmsXA

                    10:22:27,298 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-2) HornetQ resource adaptor started

                    10:22:27,298 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-2) IJ020002: Deployed: file://RaActivatorhornetq-ra

                    10:22:27,298 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-2) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

                    10:22:27,314 INFO  [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/TestTopic

                    10:22:27,314 INFO  [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:/jms/TestTopic

                    10:22:27,314 INFO  [org.jboss.as.messaging] (MSC service thread 1-6) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/ConnectionFactory

                    10:22:27,314 INFO  [org.jboss.as.messaging] (MSC service thread 1-6) JBAS011601: Bound messaging object to jndi name java:/jms/ConnectionFactory

                    10:22:27,361 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "EJBInheritedFromPOJO_JB.jar"

                    10:22:27,361 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "EJBInheritedFromPojoWEB_JB.war"

                    10:22:27,361 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "CalcEJBProjectJBoss.jar"

                    10:22:27,626 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named CalcBean in deployment unit deployment "CalcEJBProjectJBoss.jar" are as follows:

                     

                        java:global/CalcEJBProjectJBoss/CalcBean!calc.CalcBeanLocal

                        java:app/CalcEJBProjectJBoss/CalcBean!calc.CalcBeanLocal

                        java:module/CalcBean!calc.CalcBeanLocal

                        java:global/CalcEJBProjectJBoss/CalcBean!calc.CalcBeanRemote

                        java:app/CalcEJBProjectJBoss/CalcBean!calc.CalcBeanRemote

                        java:module/CalcBean!calc.CalcBeanRemote

                        java:jboss/exported/CalcEJBProjectJBoss/CalcBean!calc.CalcBeanRemote

                     

                    10:22:27,641 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named EjbInheritedFromPojoBean in deployment unit deployment "EJBInheritedFromPOJO_JB.jar" are as follows:

                     

                        java:global/EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoMath

                        java:app/EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoMath

                        java:module/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoMath

                        java:jboss/exported/EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoMath

                        java:global/EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoStr

                        java:app/EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoStr

                        java:module/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoStr

                        java:jboss/exported/EJBInheritedFromPOJO_JB/EjbInheritedFromPojoBean!ejbfrompojo.EjbInheritedFromPojoStr

                     

                    10:22:28,016 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /EJBInheritedFromPojoWEB_JB

                    10:22:28,016 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990

                    10:22:28,031 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 7180ms - Started 275 of 358 services (82 services are passive or on-demand)

                    10:22:28,281 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "EJBInheritedFromPOJO_JB.jar"

                    10:22:28,281 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "EJBInheritedFromPojoWEB_JB.war"

                    10:22:28,297 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "CalcEJBProjectJBoss.jar"

                     


                    • 7. Re: Cannot acquire InitialContext from a Servlet
                      wdfink

                      humm, I suppose the problem is the JNDI name

                      "EJBInheritedFromPOJO_JB" is the JAR name, right?

                      if yes the lookup should start with "/" as the jndi name is <app>/<module>/<bean>!<view>, app is the name of the ear in thi case.

                       

                      Also if the servlet is inside a JBoss you should not use the "remote://" approach.

                       

                      See ejb-multi-server quickstart, there is a web-app which invoke EJBs on a different server