Summary:
Calling Context.createSubcontext("foo") seems to
destroy the context previously bound to that name
instead of throwing a NameAlreadyBoundException.
(Reproducible in at least the jboss-2.2.2-tomcat-3.2.2
and jboss-2.4.0-tomcat-3.2.3 bundles)
Details:
The code I'm looking at has an MBean that registers a
bunch of entries at startup in the following manner:
Context ctx = new InitialContext();
Context fooCtx = ctx.createSubcontext("foo");
Context barCtx = fooCtx.createSubcontext("one");
barCtx.bind(string1, value1);
barCtx.bind(string2, value2);
...
There is also an EJB which binds an object in this way:
Context ctx = new InitialContext();
try {
ctx.createSubcontext("foo");
} catch( NameAlreadyBoundException ne ) {
ne.printStackTrace();
}
try {
ctx.createSubcontext("foo/two");
} catch( NameAlreadyBoundException ne ) {
ne.printStackTrace();
}
ctx.rebind("foo/two/Date", viewDate);
ctx.rebind("foo/two/Calendar", viewCalendar);
After startup, all of the entries registered
under "foo/one" by the MBean are there. After calling
the EJB date-setter, foo has a "two" with the correct
children, but "one" and its children no longer exist.
No exception is triggered.
(An obvious workaround is to reverse the logic and
expect a NameNotFoundException if the name is not
bound -- probably more efficient anyway)
Still, the behavior described above is contrary to the
API which states that a NameAlreadyBoundException
should be thrown.
Logged In: YES
user_id=175228
This has been fixes in Rel_2_4_1_8 and main.