unico 2004/02/24 05:02:47
Modified: src/blocks/jms/java/org/apache/cocoon/components/jms
JMSConnectionImpl.java
Log:
prevent NPE when root cause is null
Revision Changes Path
1.10 +22 -15
cocoon-2.1/src/blocks/jms/java/org/apache/cocoon/components/jms/JMSConnectionImpl.java
Index: JMSConnectionImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/jms/java/org/apache/cocoon/components/jms/JMSConnectionImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JMSConnectionImpl.java 15 Feb 2004 21:30:00 -0000 1.9
+++ JMSConnectionImpl.java 24 Feb 2004 13:02:47 -0000 1.10
@@ -159,19 +159,26 @@
this.available = true;
} catch (NamingException e) {
if (getLogger().isWarnEnabled()) {
- String rootCause = e.getRootCause().getClass().getName();
- String message = e.getRootCause().getMessage();
- if (rootCause.equals("java.lang.ClassNotFoundException")) {
- String info = "WARN! *** JMS block is installed but jms
client library not found. ***\n" + "- For the jms
block to work you must install and start a JMS server and " +
"place the client jar in WEB-INF/lib.";
- if (message.indexOf("exolab") > 0 ) {
- info += "\n- The default server,
OpenJMS is configured in cocoon.xconf but is not bundled with Cocoon.";
- }
- System.err.println(info);
- getLogger().warn(info,e);
- } else {
- System.out.println(message);
- getLogger().warn("Cannot get Initial
Context. Is the JNDI server reachable?",e);
- }
+ Throwable rootCause = e.getRootCause();
+ if (rootCause != null) {
+ String message = e.getRootCause().getMessage();
+ if (rootCause instanceof ClassNotFoundException) {
+ String info = "WARN! *** JMS block is installed but
jms client library not found. ***\n" +
+ "- For the jms block to work you must install
and start a JMS server and " +
+ "place the client jar in WEB-INF/lib.";
+ if (message.indexOf("exolab") > 0 ) {
+ info += "\n- The default server, OpenJMS is
configured in cocoon.xconf but is not bundled with Cocoon.";
+ }
+ System.err.println(info);
+ getLogger().warn(info,e);
+ } else {
+ System.out.println(message);
+ getLogger().warn("Cannot get Initial Context. Is the
JNDI server reachable?",e);
+ }
+ }
+ else {
+ getLogger().warn("Failed to initialize JMS.",e);
+ }
}
} catch (JMSException e) {
if (getLogger().isWarnEnabled()) {
@@ -250,7 +257,7 @@
* @throws NamingException
* @throws JMSException
*/
- public synchronized TopicSession getSession() throws NamingException,
JMSException {
+ public TopicSession getSession() throws NamingException, JMSException {
return this.session;
}