tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Re: Problems Instantiating JNDI LdapDirContext as resource.
Date Tue, 29 Jun 2004 12:19:32 GMT
Enrico,

Sure, my solution was to compile my own Factory for creating the 
InitialDirContext, something like the following and then place it into 
the tomcatX/common/lib directory.

public class MyDirContextFactory
     implements ObjectFactory, InitialContextFactory {

     public Object getObjectInstance(
         Object obj,
         Name name,
         Context nameCtx,
         Hashtable environment)
         throws NamingException {

         Hashtable env = new Hashtable();
         Reference ref = (Reference) obj;
         Enumeration addrs = ref.getAll();
         while (addrs.hasMoreElements()) {
             RefAddr addr = (RefAddr) addrs.nextElement();
             if(!addr.getType().equals("factory"))
                 env.put(addr.getType(), addr.getContent().toString());
         }

         return this.getInitialContext(env);
     }

     /* (non-Javadoc)
      * @see 
javax.naming.spi.InitialContextFactory#getInitialContext(java.util.Hashtable)
      */
     public Context getInitialContext(Hashtable environment)
         throws NamingException {
             return new InitialDirContext(environment);
     }
}

hope this helps,
Mark

Favretto Enrico wrote:

> Hello Mark
> 
> Please excuse me for sending you this unsolicited email. However, I'm having
> exactly the same problem and by searching the web for a possible solution I
> found your post on the tomcat-dev mailinglist
> (http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg51159.html).
> May I ask you if you managed to come up with a solution?
> 
> kind regards
> Enrico Favretto
> 
> --------------------------------------------
> Enrico Favretto
> Corporate Center & Common Applications
> e-Applications
> Phone +41-52-261-7730
> Fax +41-52-261-3148
> mailto:enrico.favretto@winterthur.ch
> --------------------------------------------
> Winterthur Insurance
> Gärtnerstrasse 4a, WICC 23
> CH-8401 Winterthur
> http://www.winterthur.com/
> --------------------------------------------

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message