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

two parallel jms session fails with security exception

0 views
Skip to first unread message

Joseph Vallot

unread,
Dec 18, 2002, 7:14:33 AM12/18/02
to
Note: I post this question on weblogic.developer.interest.security
yesterday, but I wonder if it could be a jms implementation or usage
problem

Note 2: connections are on different servers

===


Hello!

I am trying to create two JMS Topic independant sessions in two
different threads, and the second one fails (independantly which one
is
run in second), with following log (see below).

What's wrong with this basic code?

thanks
--
Joseph

NB: test program runs with WL7's weblogic.jar (servers are also WL7)

=== stdout ======================

subscriber1 created on Log topic
>>> receive on Log topic
subscriber1 created on MyJMSTopic-2
>>> receive on MyJMSTopic-2
!!! weblogic.jms.common.JMSException: System error:
java.lang.SecurityException:
Invalid Subject: principals=[system]

Start server side stack trace:
java.lang.SecurityException: Invalid Subject: principals=[system]
at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:893)
at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:309)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
End server side stack trace

weblogic.jms.common.JMSException: System error:
java.lang.SecurityException: Invalid Subject: principals=[system]

Start server side stack trace:
java.lang.SecurityException: Invalid Subject: principals=[system]
at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:893)
at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:309)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
End server side stack trace

at weblogic.jms.client.JMSSession.handleException(JMSSession.java:1725)
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:416)
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:360)
at twojms$subscriberthread.run(twojms.java:66)
----------- Linked Exception -----------
java.lang.SecurityException: Invalid Subject: principals=[system]

Start server side stack trace:
java.lang.SecurityException: Invalid Subject: principals=[system]
at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:893)
at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:309)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
End server side stack trace

at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:127)
at weblogic.jms.dispatcher.DispatcherImpl_WLStub.dispatchSyncNoTranFuture(Unknown
Source)
at weblogic.jms.dispatcher.DispatcherWrapperState.dispatchSyncNoTran(DispatcherWrapperState.java:341)
at weblogic.jms.client.JMSSession.receiveMessage(JMSSession.java:443)
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:414)
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:360)
at twojms$subscriberthread.run(twojms.java:66)
java.lang.SecurityException: Invalid Subject: principals=[system]

Start server side stack trace:
java.lang.SecurityException: Invalid Subject: principals=[system]
at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:893)
at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:309)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
End server side stack trace

at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:127)
at weblogic.jms.dispatcher.DispatcherImpl_WLStub.dispatchSyncNoTranFuture(Unknown
Source)
at weblogic.jms.dispatcher.DispatcherWrapperState.dispatchSyncNoTran(DispatcherWrapperState.java:341)
at weblogic.jms.client.JMSSession.consumerClose(JMSSession.java:1657)
at weblogic.jms.client.JMSConsumer.close(JMSConsumer.java:429)
at twojms$subscriberthread.run(twojms.java:78)
<<< message received on Log topic
>>> receive on Log topic
<<< message received on Log topic
>>> receive on Log topic
[snip]

=== src =======================================

import java.util.*;
import javax.jms.*;
import javax.naming.*;


public class twojms {

private static final String ONE_PROVIDER = "t3://machine1:7003";
private final static String ONE_JNDIFRY =
"weblogic.jndi.WLInitialContextFactory";
private final static String ONE_TOPICFRY =
"log.jms.ConnectionFactory";
private final static String ONE_TOPIC =
"log.jms.LogMessageTopic";
private final static String ONE_USER = "user";
private final static String ONE_PASSWORD = "password";

private static final String TWO_PROVIDER = "t3://localhost:7001";
private final static String TWO_JNDIFRY = ONE_JNDIFRY;
private final static String TWO_TOPICFRY =
"JVTestTopicConnectionFactory";
private final static String TWO_TOPIC = "JVTestTopic3";
private final static String TWO_USER = ONE_USER;
private final static String TWO_PASSWORD = ONE_PASSWORD;

private final static int MAXMESSAGE = 10;

private class subscriberthread extends Thread
{
private TopicSubscriber subs = null;
private Topic topic = null;
private TopicSession session = null;
private TopicConnection connection = null;
boolean initok = false;
public subscriberthread (String prov, String jndif,
String topicf, String strtopic,
String user, String password)
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, jndif);
env.put(Context.PROVIDER_URL, prov);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.SECURITY_PRINCIPAL, user);

try {
InitialContext context = new InitialContext(env);
TopicConnectionFactory qcf
= (TopicConnectionFactory)context.lookup(topicf);
connection
= qcf.createTopicConnection(/*ONE_USER,ONE_PASSWORD*/);
session
= connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
topic = (Topic)context.lookup(strtopic);
subs = session.createSubscriber(topic);

System.out.println("subscriber1 created on " + topic.toString());
initok = true;
} catch (Throwable t) {
System.err.println("!!! " + t);
t.printStackTrace();
}
}
public void run () {
boolean b = initok;
int n = 0;
while (b) {
try {
System.out.println(">>> receive on " + topic);
Message m = subs.receive();
System.out.println("<<< message received on " + topic);
if (n > MAXMESSAGE) {
b = false;
}
n++;
} catch (Throwable t) {
System.err.println("!!! " + t);
t.printStackTrace();
b = false;
}
}
if (subs != null) { try { subs.close(); } catch (JMSException je)
{ }}
if (session!=null){ try { session.close(); } catch (JMSException
je) { }}
if (connection!=null) { try { connection.close(); } catch
(JMSException je) { }}
}
}

public twojms ()
{
new subscriberthread(ONE_PROVIDER, ONE_JNDIFRY, ONE_TOPICFRY,
ONE_TOPIC, ONE_USER, ONE_PASSWORD).start();
new subscriberthread(TWO_PROVIDER, TWO_JNDIFRY, TWO_TOPICFRY,
TWO_TOPIC, TWO_USER, TWO_PASSWORD).start();
}

public static void main (String[] args)
{
twojms tj = new twojms();
}
}

Tom Barnes

unread,
Dec 18, 2002, 6:11:11 PM12/18/02
to Joseph Vallot
Hi Joseph,

At first look the code seems OK, and so I suspect there may be a WL
bug. Just for the heck of it, and in order to narrow down
the problem, I suggest
trying a different username/password for the second thread
creating the contexts inside run() rather than in the constructor
putting a 1 seond "sleep" in between the first and second
thread create
Furthermore, I suggest raising a case with customer support - you
already have a clean reproducer...

Tom

Joseph Vallot

unread,
Dec 19, 2002, 6:21:49 AM12/19/02
to

Tom,

I tried your ideas (two different users, and a sleep (I tried 2s) between threads
instantiation) => nothing changed.

I will open a call today...

--
Joseph

Joseph Vallot

unread,
Dec 24, 2002, 8:40:17 AM12/24/02
to

I finally got the solution from bea support...
I just had to create Context, etc in the run() method (and not in the constructor).
this way, Context is owned by the new thread and not by main thread (which actually
call constructors).

--
Joseph


Tom Barnes

unread,
Dec 24, 2002, 2:10:55 PM12/24/02
to Joseph Vallot
Thanks for posting, note that you must have missed that the same
approach was suggested above:

[try] "creating the contexts inside run() rather than in the
constructor"

:-)

Tom

0 new messages