Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Startup class : Context lookup for a Home fails in a new thread

0 views
Skip to first unread message

Srikanth Goli

unread,
Aug 15, 2001, 8:25:52 PM8/15/01
to

Hi All,

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)


0 new messages