3 Replies Latest reply on Mar 7, 2005 4:00 PM by rogerparkinson

    resource-ref tag used for env-entry?

    rogerparkinson

      Is there a way to use the resource-ref tag in the ejb-jar.xml to refer to an external block of env-entry tags? I have several stateless session beans that require the same env-entry tags. This is a maintenance headache for me. Putting them somewhere common would help.

      I would like to be able to get to them using a similar mechanism as I use to get to a jdbc datasource, including the ability to vary the JNDI name in jboss.xml

      I need the context.lookup() calls to be able to use java:comp/env to get to them so I don't have to change the existing code eg

      InitialContext iniCtx = new InitialContext();
      Context envCtx = (Context) iniCtx.lookup("java:comp/env");
      Integer maxExemptions = (Integer) envCtx.lookup("maxExemptions");
      

      However I don't mind putting some init code in each bean so that the InitialContext gets redirected before it is instantiated.

      Is this possible? Apologies if this is in the docs somewhere, I did look but didn't find it yet. By all means point me at a doc reference.

      Thanks for any help


        • 1. Re: resource-ref tag used for env-entry?
          rogerparkinson

          I have a workaround on this but I don't like it much.

          I can put some static code on each bean which loads properties from somewhere (eg a resource file in the same package) and passes them into the context using the bind() method.

          I need to check before I load that another bean has not already loaded the information.

          This seems clumsy.

          • 2. Re: resource-ref tag used for env-entry?
            dhill

            first a couple of questions, how are the ejb being deployed , If they are being deployed in a EAR all you have to do is place the entrys in the deployment plan jboss-app.xml, this is where you will be able to set up the actual value that is being returned from the lookup, it is done just like a datasource. The other solution would be global to the AS but you could bind to the jboss jndi tree a value but this is a kludge IMO, I think the only real solution is to include inan ear and bind them using the deployment plan.

            • 3. Re: resource-ref tag used for env-entry?
              rogerparkinson

              It sounds like I should be using an EAR, which is not a problem. This is a test app at present and the full app will definitely need an EAR.

              I looked for docs on jboss-app.xml and found lots of stuff, but not what you described. Is there a ref you can point me to? A simple example would do.

              Thanks