what initial context are you trying to connect to
you can do this:

Properties props = new Properties();
props.setProperty(...);
Context cxt = new InitialContext(props);

where you set the machine and port of the machine hosting your initial
context. (should be the URL to the server where your JMS server is running)
Filip


-----Original Message-----
From: Rui Zhang [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 26, 2004 6:45 PM
To: Tomcat Users List
Subject: Using JMS in Tomcat Valve


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.676 / Virus Database: 438 - Release Date: 5/3/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.676 / Virus Database: 438 - Release Date: 5/3/2004


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to