users@jmsjca.java.net

Re: Sessions are already closed / now NPEs

From: Andreas Loew <Andreas.Loew_at_Sun.COM>
Date: Mon, 12 Jan 2009 18:26:16 +0100

Sorry Brian,

I was even trying to make it more complex as it indeed is:

There is no NPE thrown from this:

Andreas Loew schrieb:

> throw Exc.jmsExc(LOCALE.x("E034: Could not create session {0}: {1}",
> sessionClass.getName(), ex), ex);

but rather, the hidden "ex" being thrown is the infamous NPE, as you can
see from the fact that the following ends up in the log:

2009-01-11 23:26:34,699 ERROR [httpSSLWorkerThread-50011-4]:cluster1svr3
(SpringJmsBroadcastListener.java:219) - unable to send message
javax.jms.JMSException: JMSJCA-E034: Could not create session
javax.jms.Session: java.lang.NullPointerException

So do an ex.printStackTrace() before line 153 and you'll find out about
the NPE.

And just one more important finding:

In your connection pool definition, you register a
javax.jms.TopicConnectionFactory in JNDI. Therefore, from the
SpringTemplate, you get a TopicConnectionFactory instance (and *not* the
generic javax.jms.ConnectionFactory from JMS 1.1).

 From the way the old-style JMS 1.0.2 API had been designed, it is only
legal to call createTopicConnection() on this TopicConnectionFactory
(and not createConnection()), and on the topicConnection returned fron
this, you may only call createTopicSession() (and not createSession()).

Or - if you have a JMS 1.1 provider - simply change your connection pool
definition to provide the generic javax.jms.ConnectionFactory from the
pool - should be much easier... :-)

Maybe this is what got you into these troubles...

I wouldn't bet on it, but chances are not too bad... ;-)

Keeping my fingers crossed...

Best regards

Andreas

-- 
Andreas Loew
Senior Java Architect
Sun Microsystems (Germany)