You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sebastian Gerdes <se...@informatik.uni-oldenburg.de> on 2007/12/12 16:32:16 UTC

JDNI Resource not reusable

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

in my context.xml/server.xml I setup a JDNI resource which I access via:

Context newCtx = new InitialContext();
Context envCtx = (Context) newCtx.lookup("java:comp/env");
DirContext ctx = (DirContext) envCtx.lookup("ldap/ox");

I use this context and then I close it via ctx.close().

The next time I want to access my LDAP I do a lookup again the
DirContext object is the same (i.e.
javax.naming.directory.InitialDirContext@1b27882, so it is one out of a
pool I guess). But the context cannot be used.

But when I do _not_ close() the context, I can use it several times,
until i am inactive for about 5 minutes. Then it seems it get closed
automatically and is not reusable anymore.

(Using com.sun.jndi.ldap.connect.pool="true" did not work and "true" did
not work either.)

If I hardcode my connection settings in my java class, everything works
fine. Every time I use the LDAP I do setup a new environment and I get a
new connection.

My problem only occurs when I use the resource via lookup from tomcat.

Anybody knows why? Atleast how do reuse the context or disable the pooling?

Thank you for an answer in advance

Kind regards,
Sebastian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHX/8ADven//UCaP8RAq5ZAJ0baxVzG3mp8nc8BW+NN83RUI87MgCgmMun
32gN0kk0ghgcjWxrBO5cKF0=
=Q0f8
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDNI Resource not reusable

Posted by Sebastian Gerdes <se...@informatik.uni-oldenburg.de>.
Hello,
to whom it may concern, I solved this problem in another way. In the
ContextFactory I only return an
InitialDirContext. The class which wants to connect to the LDAP uses
this InitialDirContext, looks up the environment and connects to the
LDAP.

You can find the source code at:
http://sourceforge.net/projects/drfox/

Unzip and go to /drfox-1.0/src/WEB-INF/src/drfox/logic/

DRFoxContextfactory.java
DRFoxAdministrator.java --> method searchUsers()

I don't know, if this is the best solution but it works like a charm.

Regards,
Sebastian

- --
*******************************************************
Universität Oldenburg - Department für Informatik

Sebastian Gerdes
PGP/GPG:  0xF50268FF
*******************************************************
-- 
View this message in context: http://www.nabble.com/JDNI-Resource-not-reusable-tp14297571p18889857.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JDNI Resource not reusable

Posted by David Delbecq <de...@oma.be>.
Hello,

ho did you create your ldap object (not ldap/ox) ? For ox to be pool,
the ldap object must be a pool, that return a new object each time a
child object is requested. envCtx.lookup("ldap/ox") actually request
object "ox" from object "ldap". It "ldap" is not a pool, it will return
a single object, always the same.


En l'instant précis du 12/12/07 16:32, Sebastian Gerdes s'exprimait en
ces termes:
> Hello,
>
> in my context.xml/server.xml I setup a JDNI resource which I access via:
>
> Context newCtx = new InitialContext();
> Context envCtx = (Context) newCtx.lookup("java:comp/env");
> DirContext ctx = (DirContext) envCtx.lookup("ldap/ox");
>
> I use this context and then I close it via ctx.close().
>
> The next time I want to access my LDAP I do a lookup again the
> DirContext object is the same (i.e.
> javax.naming.directory.InitialDirContext@1b27882, so it is one out of a
> pool I guess). But the context cannot be used.
>
> But when I do _not_ close() the context, I can use it several times,
> until i am inactive for about 5 minutes. Then it seems it get closed
> automatically and is not reusable anymore.
>
> (Using com.sun.jndi.ldap.connect.pool="true" did not work and "true" did
> not work either.)
>
> If I hardcode my connection settings in my java class, everything works
> fine. Every time I use the LDAP I do setup a new environment and I get a
> new connection.
>
> My problem only occurs when I use the resource via lookup from tomcat.
>
> Anybody knows why? Atleast how do reuse the context or disable the
> pooling?
>
> Thank you for an answer in advance
>
> Kind regards,
> Sebastian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


-- 
David Delbecq
Institut Royal Météorologique
Ext:557

-- 
http://www.devlog.be (a belgian developer's logs)




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org