This content has been marked as final.
Show 2 replies
-
1. Re: One Last ConnectionFactory Lookup Question.
genman Nov 30, 2004 11:50 PM (in response to gberish)
What does "telnet 1099" give you?
Are you using factory.url?
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -
2. Re: One Last ConnectionFactory Lookup Question.
gberish Dec 1, 2004 1:42 PM (in response to gberish)Thanks.
It seems I needed to add "java.naming.factory.url.pkgs"="org.jboss.naming:org.jnp.interfaces" to the Properties parameter for new InitialContext ().
The code and screen output is shown below for the next new guy to attempt JMS.
(PS: I didn't understand the question about telnet.)import java.util.*; import javax.jms.*; import javax.naming.*; public class JmsConnection { public static void main (String[] args) { System.out.println ("Start Main"); JmsConnection c = new JmsConnection (); System.out.println ("End Main"); } /*** * Constructor ***/ public JmsConnection () { try { Context jndiContext = getInitialContext(); System.out.println("Initial context obtained"); Object tmp = jndiContext.lookup("ConnectionFactory"); System.out.println ("ConnectionFactory looked up as Object"); TopicConnectionFactory factory = (TopicConnectionFactory) tmp; System.out.println ("Object cast to TopicConnectionFactory"); } catch (NamingException ne) { System.out.println ("NamingException Msg: "+ne.getMessage ()); } catch (NoClassDefFoundError ncfe) { System.out.println ("NoClassDefFoundERror Msg: "+ncfe.getMessage ()); } } /*** * Methods ***/ public Context getInitialContext() throws NamingException { Properties env = new Properties(); env.put( Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory"); env.put( Context.PROVIDER_URL, "jnp://localhost:1099/"); env.put ( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); return new InitialContext(env); } }
Screen OutputStart Main Initial context obtained ConnectionFactory looked up as Object Object cast to TopicConnectionFactory End Main Press any key to continue . . .