1 2 Previous Next 20 Replies Latest reply on Dec 20, 2012 2:54 AM by nickarls Go to original post
      • 15. Re: Jboss 7.1 error on new InitialContext();
        alisissa

        i tried this with single backslash:

        Object ref = context.lookup("ejb:myapp/MYbean!gss.myapp.sessions.MySecurityRemote?stateful");


        but i am getting this error :S ax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.myweb.war:main" from Service Module Loader

        • 16. Re: Jboss 7.1 error on new InitialContext();
          nickarls

          ejb:/

          • 17. Re: Jboss 7.1 error on new InitialContext();
            alisissa

            my code looks this now:

                        final Hashtable jndiProperties = new Hashtable();

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

                        jndiProperties.put("java.naming.factory.initial", "org.jboss.as.naming.InitialContextFactory");

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

                        final Context context = new InitialContext(jndiProperties);

                        Object ref = context.lookup("ejb:/myApp/myBean!gss.myapp.sessions.MySecurityRemote");

             

            The first error looks like it is fixed, now i am having this error:

             

            javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.TPGApp.jar:main" from Service Module Loader

            org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)

            javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)

            javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)

            javax.naming.InitialContext.init(InitialContext.java:240)

            javax.naming.InitialContext.<init>(InitialContext.java:192)

            tpg.tpgapp.controller.EntityControllerBase.lookupEntityControllerBean(EntityControllerBase.java:168)

            tpg.tpgapp.controller.EntityControllerBase.<init>(EntityControllerBase.java:19)

            tpg.tpgapp.db.ApplicationServices.<init>(ApplicationServices.java:28)

            tpg.tpgapp.sessions.CardValidatorBean.init(CardValidatorBean.java:65)

            Any help?

            • 18. Re: Jboss 7.1 error on new InitialContext();
              nickarls

              If @EJB injection works, is there a special reason you want to do the lookup yourself?

              • 19. Re: Jboss 7.1 error on new InitialContext();
                alisissa

                Sorry for that, but can you please explain more (with samples from mycode) on how to do what you are suggesting?

                I am no expert in Java and jboss.

                Any help would be appreciated.

                • 20. Re: Jboss 7.1 error on new InitialContext();
                  nickarls

                  If you have a WAR with a Servlet like

                   

                  @WebServlet(urlPatterns = "/test")
                  public class EJBTest extends HttpServlet
                  {
                     @EJB(lookup = "ejb:myapp/MYbean!gss.myapp.sessions.MySecurityRemote?stateful")
                     MySecurityRemote remote;
                  
                  
                     @Override
                     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
                     {
                        System.out.println(remote);
                     }
                  
                  
                  }
                  
                  

                   

                  And access the servlet you should see the output. Not that the remote interface must also be available to the WAR.

                  1 2 Previous Next