-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple datasources created when using Spring JNDI template #5
Comments
I am working on a new version, coming soon, that will address this problem. |
Done. See org.osjava.sj.jndi.ignoreClose |
@h-thurow Thanks for the change! |
Hello, Hashtable env = new InitialContext().getEnvironment();
env.remove("org.osjava.sj.jndi.ignoreClose");
env.put("java.naming.factory.initial", "org.osjava.sj.SimpleJndiContextFactory");
new InitialContext(env).close(); to actually close the context when the I don't have any elegant solution for the unchecked access problem. For the second one, instead, the solution I found is to set @SuppressWarnings("unchecked")
Hashtable<Object, Object> env = (Hashtable<Object, Object>) new InitialContext().getEnvironment();
env.put("org.osjava.sj.jndi.ignoreClose", "false");
env.put("java.naming.factory.initial", "org.osjava.sj.SimpleJndiContextFactory");
new InitialContext(env).close(); In this way I was finally able to actually invalidate my context in an "aftereach" method. |
I'm using Simple JNDI with a third party library that uses a Spring JndiTemplate to lookup objects from JNDI. The Spring JndiTemplate runs code like this for any JNDI operation (eg a lookup would
execute
aJndiCallback
that ran ctx.lookup) an object:This is problematic as I have ~5 lookups for what is supposed to be the same connection pool and Spring causes a new Database Connection Pool to be created each time a lookup is run.
Would you approve of adding another property to disable removing contexts on close?
The text was updated successfully, but these errors were encountered: