2 Replies Latest reply on Feb 13, 2003 3:38 AM by Adrian Brock

    spi's jndi.properties not visible when deploying in a  .sar

    christophe Newbie

      Hi all,

      This topic is a summary of the issue encountered with Jboss 3.04, ( that doesn't exist in JB2.4.9) described in http://jboss.org/forums/thread.jsp?forum=61&thread=26456.

      When packaging a JNDI spi into a .sar, the jndi.properties (for instance java.naming.factory.url.pkgs=com.spi) is not accessible when doing

      new InitialContext().lookup("spiurl").

      (Of course the same test outside jboss with a single classloader works fine...)

      When adding to the previous code, env.put(Context.URL_PKG_PREFIXES,"com.spi");
      the spiurl is well resolved with the corresponding Context.

      However this workaround is not really satisfactory ... ;-)
      I tried when using the run.sh -P jndi.properties. Despite the spi environment properties are loaded (displayed in the boot.log) but remains without effect on the lookup ...

      Please, any help welcome ...


        • 1. Re: spi's jndi.properties not visible when deploying in a  .
          christophe Newbie

          After debugging, it seems the sun internal classes of JNDI uses the Thread.contextclassloader for finding "jndi.properties".
          The MBean that makes the jndi.lookup has a UnifiedClassLoader whose description is url=file:/opt/jboss-3.0.4_tomcat-4.1.12/server/jboss1/tmp/deploy/server/jboss1/deploy/spi-service.xml/101.spi-service.xml
          Note that the test is directly done is the MBean's constructor. and the MBean has no jboss specific interface (i.e not ServiceMBean...).

          the spi-service.xml is <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE server>


          However the mbean.class.getClassLoader() is relative to SpiLoader.jar. If i add jndi.properties in the SpiLoader.jar (instead of Spi.jar), classloader.getResources("jndi.properties") returns the url.

          Why doesn't the threadcontextclassloader.getResources("jndi.properties") find the resource ?


          • 2. Re: spi's jndi.properties not visible when deploying in a  .
            Adrian Brock Master

            Because there is a jndi.properties in server/jboss1/conf
            and this has already been loaded by the naming service.

            If you create a sar it will look locally in the
            sar before searching the UnifiedLoaderRepository.


            Is there a reason why you cannot add the config to
            jndi.properties in conf, other than you can't hot deploy
            the jars because they need to be in server/jboss1/lib?