Re: openjms in tomcat

Tim Anderson <[email protected]> Wed, 10 Jan 2007 09:39:36 +1100
Newsgroups gmane.comp.java.openjms.user
Message-ID <[email protected]>
You can either:

1. put the configuration information in your web.xml, and extract it
using getInitParameter()

2. use Tomcat's support for Generic
JavaBean Resources

-Tim

stroj_casu wrote:

Hi, when working with openjms from a standalone programe I could use the file
jndi.properties to configure the initial context factory and the URL of the JMS
server. Precisely, my jndi.properties looks like this:

java.naming.provider.url=tcp://192.168.1.100:3035
java.naming.factory.initial=org.exolab.jms.jndi.InitialContextFactory
java.naming.security.principal=foo
java.naming.security.credentials=bar

However, this approach fails when I use the same code in a Tomcat servlet. I
have to use Properties in my servlet to set the init. context factory and the
provider URL:

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
props.put(Context.PROVIDER_URL, "tcp://192.168.1.100:3035");
props.put(Context.SECURITY_PRINCIPAL, "foo");
props.put(Context.SECURITY_CREDENTIALS, "bar");
ctx = new InitialContext(props);

otherwise I get this exception:

javax.naming.NameNotFoundException: Name TopicCF is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
at javax.naming.InitialContext.lookup(Unknown Source)
at de.trcsystem.aj.QueueTrafficMessaging.init(QueueTrafficMessaging.aj:33)

QueueTrafficMessaging.aj:

30 ctx = new InitialContext();
31
32 TopicConnectionFactory topicConnectionFactory =
33 (TopicConnectionFactory) ctx.lookup("TopicCF");

What needs to be done to avoid hardcoding the init. context factory and the
provider URL information into my servlet? I assume something (a resource?) has
to be configured in server.xml (would like to avoid that) or web.xml of my
Tomcat application.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
openjms-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openjms-user

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
openjms-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openjms-user