Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Using JMS in Tomcat Valve

Rui Zhang

2004-05-26

Replies:

Hi all,

How can I configure tomcat to use JMS in its valve?

I failed at the very beginning, when I tried to obtain the JNDI
context, after moving the J2EE jms.jar to under server/lib.

-----------------------------------
The Exception I got was:

[main] ERROR digester.Digester - Begin event threw exception
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an application
resource file: java.naming.factory.initial

-----------------------------------
My code in the valve constructor looks like the following. The same code
runs perfectly fine in a normal J2EE application.

Context cxt = new InitialContext();
cf = (ConnectionFactory)cxt.lookup("jms/TopicConnectionFactory");

con = cf.createConnection();

session = con.createSession(false,Session.AUTO_ACKNOWLEDGE);

dest = (Topic)cxt.lookup("jms/hWLMTopic");

producer = session.createProducer(dest);

-----------------------------------

Any advice will be hugely appreciated.

Best regards,

Rui


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.