Thanks in Advance,
Ken
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");
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... :-(
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