2 Replies Latest reply on Jun 5, 2009 8:05 PM by Andy Gibson

    Manager in JNDI Context from Tomcat

    Alexander Bell Newbie

      Hi,


      I'm running on Tomcat 6.
      If I try to get the javax.inject.manager.Manager from JNDI Context I get a NameNotFoundException. I tried the following JNDI names: java:app/Manager and java:comp/Manager.
      Obviously it works with JBoss with JNDI name java:comp/Manager (http://seamframework.org/Community/HowToLookupTheDeployedManagerInAServlet) but that doesn't work within Tomcat.


      Is there a way to get the Manager via a programmatic call in a Tomcat environment.
      I browsed the JNDI Context but I didn't find a Manager reference in it.


      Alex

        • 1. Re: Manager in JNDI Context from Tomcat
          Mike Wilson Newbie

          Personally I use:



          Manager manager = CurrentManager.rootManager();




          which hard-wires your code to the JBoss RI, but lets you execute it in any servlet container...

          • 2. Re: Manager in JNDI Context from Tomcat
            Andy Gibson Novice

            Did you check out section 16.3.1 - Tomcat in the manual, specifically :



            Tomcat has a read-only JNDI, so Web Beans can't automatically bind the Manager. To bind the
            Manager into JNDI, you should add the following to your META-INF/context.xml:



            <Resource name="app/Manager"
                auth="Container"
                type="javax.inject.manager.Manager"
                factory="org.jboss.webbeans.resources.ManagerObjectFactory"/>



            and make it available to your deployment by adding this to web.xml:

            <resource-env-ref>
                <resource-env-ref-name>
                    app/Manager
                </resource-env-ref-name>
                <resource-env-ref-type>
                    javax.inject.manager.Manager
                </resource-env-ref-type>
            </resource-env-ref>



            Tomcat only allows you to bind entries to java:comp/env, so the Manager will be available at
            java:comp/env/app/Manager

            Web Beans also supports Servlet injection in Tomcat. To enable this, place the webbeanstomcat-support.jar in $TOMCAT_HOME/lib, and add the following to your META-INF/context.xml:



            Cheers,


            Andy Gibson