All,
I had occasion to write some code to traverse the JNDI tree for JDBC
resources and list them. My code looks something like this:
InitialContext ictx = null;
Context ctx = null;
try {
ictx = new InitialContext();
ctx = ictx.lookup("java:comp/env/jdbc");
...
} finally {
if(null != ctx) try { ctx.close(); } catch () ...
if(null != ictx) try { ictx.close(); } catch () ...
}
This code is throwing an exception:
javax.naming.OperationNotSupportedException: Context is read only
at org.apache.naming.NamingContext.checkWritable(NamingContext.java:637)
at org.apache.naming.NamingContext.close(NamingContext.java:430)
at [... my code ...]
Examples online from Sun/Oracle seem to indicate that calling
Context.close() when code is finished with a Context resource is
appropriate.
Should this method be throwing an exception?
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]