I did also that, I mean a classic java client with QueueReceiver and it works as expected:
Code:
public class JMSReceiver {
...
private static final String QCF_NAME = "WL.mb0_sb.CF";
private static final String QUEUE_NAME = "WL.mb0_sb.BU";
private static final String WLS_URL = "t3://bsrpdev0012.dev.b-source.net:7841";
private static final String WLS_USER = "WLS_USER";
private static final String WLS_PWD = "WLS_USER";
private static final int TIMEOUT = 10*1000;
public static void main(String[] args) {
retrieveMessage();
}
public static void retrieveMessage() {
Hashtable<String, String> properties = new Hashtable<String, String>();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, WLS_URL);
properties.put(Context.SECURITY_PRINCIPAL, WLS_USER);
properties.put(Context.SECURITY_CREDENTIALS, WLS_PWD);
try {
ctx = new InitialContext(properties);
} catch (Exception e) {
System.out.println(e.getMessage());
}
try {
qcf = (QueueConnectionFactory) ctx.lookup(QCF_NAME);
qc = qcf.createQueueConnection();
qsess = qc.createQueueSession(false, 0);
q = (Queue)ctx.lookup(QUEUE_NAME);
qrcvr = qsess.createReceiver(q);
qc.start();
message = qrcvr.receive(TIMEOUT);
System.out.println("received: " + message.toString());
} catch(Throwable e) {
System.out.println(e.getMessage());
} finally {
try {
qrcvr.close();
qsess.close();
qc.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
In order to find out a solution some days ago I posted the same issue on OTN Discussion Forum and today I've just got:
Code:
Spring JMS and WebLogic JMS have given a tough time to lot of us.
When Spring looks up the connection factory & queue, it does so using the proper credentials, but since the actual publish/consume takes place in a different thread, the security information doesn't get passed on to that new thread.
There is apparently a flag called "exposeAccessContext" that you can set on the connection factory & queue in Spring to ensure that the security credentials are available to other threads.
I will try with that. Do you know that flag ?