0 Replies Latest reply on Aug 11, 2007 3:48 PM by dan.j.allen

    embedding within a web application (jetty)

    dan.j.allen

      I am attempting to bootstrap the embedded jboss from within a web application that is running under Jetty. I realize that it may seem a little silly to want to do, but hear me out. The holy grail of maven 2 development is using the embedded jetty container. This worked nicely under Seam 1.2.1 when the ejb standalone was being used, but now that the embedded jboss has been put in place, this no longer works.

      I have two environments, a test case and the servlet listener. Both of them execute the exact same code. When I run the test case, I can lookup objects in JNDI and everything works just great. On the other hand, when I use the servlet listener, I cannot find objects in JNDI. Here is the code:


      public class EmbeddedListener implements ServletContextListener {

      private Bootstrap bootstrap;

      private boolean started = false;

      public void contextInitialized(ServletContextEvent event) {
      try {
      URLStreamHandlerFactory factory = new URLStreamHandlerFactory();
      URL.setURLStreamHandlerFactory(factory);
      bootstrap = Bootstrap.getInstance();
      bootstrap.bootstrap();
      started = true;
      Hashtable<String, String> props = new Hashtable<String, String>();
      props.put("java.naming.factory.initial", "org.jboss.naming.JBossRemotingContextFactory");
      props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      // This next line will fail
      System.out.println(new InitialContext(props).lookup("UserTransaction"));
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      public void contextDestroyed(ServletContextEvent event) {
      if (started) {
      bootstrap.shutdown();
      }
      }

      }


      Is it going to be possible to run the Bootstrap from within a servlet context?