I am having a funny problem with Weblogic Startup class.In the startup method,
I am creating an instance of InitialContext. I called look up in this context
for a bean's home. It works and it retuns the proper Home interface.
But, when I use the same InitialContext instance in a new thread, and again if
I call look up for the same bean's home, the server fails with a SecurityException.
I don't have any Role based Security for this bean.
Btw, I am using Weblogic 5.1 & SP7.
Any ideas or help, appreciated..
Thanks in Advance
Srikanth Goli
Here is the code.
public String startup(String name, Hashtable args) throws Exception {
InitialContext initialContext = null;
try {
initialContext = new InitialContext();
UserPreferencesHome userPreferencesHome =
(UserPreferencesHome)initialContext.lookup
(UserPreferencesHome.DEFAULT_URL);
//This prints Properly
System.err.println("StartupTest: userPrefsHome is " + userPreferencesHome);
} catch(Exception e) {
e.printStackTrace();
}
Thread th = new Thread(new TestThread(initialContext));
th.start();
return "ok";
}
}
class TestThread implements Runnable {
Context context;
public TestThread(InitialContext ctx) {
context = ctx;
}
public void run() {
try {
//This is failing
UserPreferencesHome userPreferencesHome1 =
(UserPreferencesHome)context.lookup
(UserPreferencesHome.DEFAULT_URL);
System.err.println("UserPreferencesHome1 in the thread is " + userPreferencesHome1);
} catch(Exception e) {
e.printStackTrace();
}
}
}
Here is the exception, I am getting
java.lang.SecurityException: User "guest" does not have Permission "lookup" base
d on ACL "weblogic.jndi.com.capgroup.btps".
at weblogic.security.acl.Security.logAndThrow(Security.java:372)
at weblogic.security.acl.Security.checkPermission(Security.java:254)
at weblogic.jndi.internal.NamingSecurityManagerImpl.checkPermission(Nami
ngSecurityManagerImpl.java:98)
at weblogic.jndi.internal.NamingSecurityManagerImpl.checkLookup(NamingSe
curityManagerImpl.java:45)
at weblogic.jndi.toolkit.BasicWLContext.resolveName(BasicWLContext.java:
737)
at weblogic.jndi.toolkit.BasicWLContext.lookup(BasicWLContext.java:133)
at weblogic.jndi.toolkit.BasicWLContext.lookup(BasicWLContext.java:574)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at com.capgroup.btps.server.TestThread.run(StartupTest.java:49)
at java.lang.Thread.run(Thread.java:484)