Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Doew anyone know th Initial Context properties for JMS?

0 views
Skip to first unread message

Ken Baltrinic

unread,
Sep 23, 2004, 3:43:18 PM9/23/04
to
I am trying to get the following code to work from a session bean running on
AppServer8. When I call new InitialContext(), the context I get pack has no
properties. This leads me to suspect that i need a jndi.properties file
with the correct settings. I suspect the settings I need are
java.naming.factory.initial and java.naming.provider.url but I don't know
what to set them to. I am also not sure exactly where to put the properties
file or how to tell the AppServer where to find it. Can anyone help?

Thanks in Advance,
Ken


Ken Baltrinic

unread,
Sep 23, 2004, 3:59:05 PM9/23/04
to
This is what I cant get to work:

Context ctx = new InitialContext(prop);

//THe above line runs but contains an empty context.
//consequently the following fails.

TopicConnectionFactory topicConnectionFactory;
topicConnectionFactory = (TopicConnectionFactory) ctx.lookup(
"jms/log4jConnectionFactory");

Sudsy

unread,
Sep 23, 2004, 4:33:40 PM9/23/04
to

It's specific to the app server; you'll have to dig into the
documentation to locate the definitive specification. I've
used code like this in the past:

Context context = null;
Properties props = new Properties();

try {
// for BEA WebLogic
props.put( Context.PROVIDER_URL,
"t3://hostname:7001" );
props.put( Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory" );
// for IBM WebSphere
props.put( Context.PROVIDER_URL,
"iiop://hostname" );
props.put( Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory" );
// for both
context = new InitialContext( props );
}
catch( NamingException e ) {
...
}

I don't run AppServer8 so I don't know that this is going to be of
any use whatsoever... :-(

Oscar kind

unread,
Sep 26, 2004, 7:14:13 AM9/26/04
to

As Sudsy already pointed out, this depends on the application server
you're using. For Resin and Tomcat for example, no properties are needed.

Some examples:

Resin:
Context context = new InitialContext();
// Option 1
DataSource dataSource1 = (DataSource)context.lookup("jdbc/datasource");
// Option 2
DataSource dataSource2 = (DataSource)context.lookup("java:comp/env/jdbc/datasource");

Tomcat:
Context initialContext = new InitialContext();
// Option 1
Context context = (Context)initialContext.lookup("java:comp/env");
DataSource dataSource = (DataSource)context.lookup("jdbc/datasource");
// Option 2
DataSource dataSource2 = (DataSource)initialContext.lookup("java:comp/env/jdbc/datasource");


--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2

0 new messages