Is new InitialContext supposed to be thread safe?  It doesn't seem to be...

I have a client test program that creates multiple threads, each of which 
does a getInitialContext.  This fails about 2 times out of three, usually 
with a:

ObjectIdMgrTest:-- Getting Initial Context --
javax.naming.NamingException: Error reading application-client descriptor: 
Error
  looking up EJBHome: Lookup error: java.io.EOFException; nested exception is:
         java.io.EOFException
         at 
com.evermind.server.ApplicationClientInitialContextFactory.getInitial
Context(JAX)
         at 
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
68)
         at 
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
)
         at javax.naming.InitialContext.init(InitialContext.java:222)
         at javax.naming.InitialContext.<init>(InitialContext.java:178)
         at 
sbd.sd.ejb.sb.objectidmgr.ObjectIdMgrTest.getInitialContext(ObjectIdM
grTest.java:305)
         at 
sbd.sd.ejb.sb.objectidmgr.ObjectIdMgrTest.run(ObjectIdMgrTest.java:16
1)
         at java.lang.Thread.run(Thread.java:484)


occasionally it will hang instead.  This is on W98, SDK 1.3.0, Orion 1.4.4.


The test is straightforward; in pseudo code...

private InitialContext iCtx;
private final static String testName = "name of test";

main()
   loop: create new thread, start

run()
   this.getInitialContext()
   hammer away...

getInitialContext()
   this.iCtx = new InitialContext()



to get around this I modified getInitialContext to

   synchronized (testName)
     this.iCtx = new InitialContext()


This works when tried a dozen or so times.

Is this an Orion bug?  If not, how should it be handled?



Kirk Yarina
[EMAIL PROTECTED]


Reply via email to