Al eerder op nieuwsgroep ibm.software.websphere.application-server geplaatst én naar IBM als vraag verstuurd, maar niemand schijnt 't te weten, welke Java guru hier op GoT weet meer?
----
One of our servlets implements multithreading to save time
calling backend systems that take a while to reply. We have
problems with the multi-threading and I have a couple of questions
about this:
* In an EJB multi-threading is not allowed, how about servlets?
* If threading is allowed, how is the security managed?
We seem to experience two problems:
* Additional threads cannot perform lookups when using 'new InitialContext()',
we resolved this by passing the required references to the new threads.
* Additional threads cannot call EJB methods, an 'UnAuthorized' exception
message is the result. It seems that the new thread does not know about it's
security context.
------
Het gaat dus om de vraag hoe/of security context overgedragen kan worden van een servlet naar een EJB in WebSphere Applicatie Server 4 op AIX en waarom dat (mogelijk) anders is wanneer dat vanuit een new Thread in een servlet gebeurt. Het probleem treedt alleen op wanneer de Websphere security aanstaat.
Tevens volgt hieronder een stuk code wat illustreert wat we proberen te doen:
----
One of our servlets implements multithreading to save time
calling backend systems that take a while to reply. We have
problems with the multi-threading and I have a couple of questions
about this:
* In an EJB multi-threading is not allowed, how about servlets?
* If threading is allowed, how is the security managed?
We seem to experience two problems:
* Additional threads cannot perform lookups when using 'new InitialContext()',
we resolved this by passing the required references to the new threads.
* Additional threads cannot call EJB methods, an 'UnAuthorized' exception
message is the result. It seems that the new thread does not know about it's
security context.
------
Het gaat dus om de vraag hoe/of security context overgedragen kan worden van een servlet naar een EJB in WebSphere Applicatie Server 4 op AIX en waarom dat (mogelijk) anders is wanneer dat vanuit een new Thread in een servlet gebeurt. Het probleem treedt alleen op wanneer de Websphere security aanstaat.
Tevens volgt hieronder een stuk code wat illustreert wat we proberen te doen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| // These commands call EJB methods:
Runnable cmd1 = new XXX(bean, jndiRef, clazz);
Runnable cmd2 = new YYY(bean, jndiRef, clazz);
Runnable cmd3 = new ZZZ(bean, jndiRef, clazz);
VOUser[] users = new VOUser[3];
if (user == null) {
ITimer timerR = PerfLog.getLogger().startTimer("************** Retrieve result ***************");
ThreadGroup thGroup = new ThreadGroup("Id");
t1 = new Thread(thGroup, cmd1);
t2 = new Thread(thGroup, cmd2);
t3 = new Thread(thGroup, cmd3);
t1.start();
t2.start();
t3.start();
Thread waitingThread = new Thread(thGroup, new Runnable() {
public void run() {
try {
t1.join();
t2.join();
t3.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} );
waitingThread.start();
waitingThread.join(5000);
users[0] = (VOUser)cmd1.getOutput();
users[1] = (VOUser)cmd2.getOutput();
users[2] = (VOUser)cmd3.getOutput();
PerfLog.getLogger().stopTimer(timerR);
} |