From: Don C. <don...@em...> - 2001-06-12 14:53:36
|
I use jython to test EJBs. I've found it is really easy to put the jndi info in a jndi.properties files in the classpath. This allows you to say "context = InitialContext()" which is much easier to type in the interpreter. You can also modify the jython.bat and pass the information in with -Dproperty=value. # this code seem to work fine # I'm using weblogic but I think I've used this with JBoss too props = Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContectory"); props.put(Context.PROVIDER_URL,"t3://localhost:7001"); context = InitialContext(props); object = jndiContext.lookup("BeanName") beanHome = PortableRemoteObject.narrow(object, BeanHome.class) bean = beanHome.create() > -----Original Message----- > From: la...@lu... > [mailto:la...@lu...] > Sent: Tuesday, June 12, 2001 10:31 AM > To: Robert Kuzelj > Cc: jyt...@li... > Subject: [Jython-users] Jython / EJB question > > > > Hi all. I'm working on writing a small client to an EJB in > jython, that > I've already implemented in Perl. I'm using JBoss as my ejb > server. I'm > stumped on calling javax.naming.initialContext. > > Here's a snippet of the java code: > > ---- JAVA CODE -------- > Properties env = new Properties(); > env.setProperty("java.naming.factory.initial", > "org.jnp.interfaces.NamingContextFactory"); > env.setProperty("java.naming.provider.url", "localhost:1099"); > env.setProperty("java.naming.factory.url.pkgs", > "org.jboss.naming"); > > InitialContext jndiContext = new InitialContext(env); > Object ref = jndiContext.lookup("interest/Interest"); > ----- END JAVA CODE ----- > > here's what I'm trying in jython: > > ---- JYTHON CODE -------- > env = java.util.Properties() > env.setProperty("java.naming.factory,initial", > "org.jnp.interfaces.NamingContextFactory") > env.setProperty("java.naming.provider.url", "localhost:1099") > env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming") > > jndiContext = javax.naming.InitialContext() > jndiContext.lookup("interest/Interest"); > ---- END JYTHON CODE ---- > > Here's the error I'm getting w/ the jython code: > > File "interest.py", line 15, in ? > 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 > > Looking up javax.naming.InitialContext, I see this for its > constructor: > > public InitialContext(java.util.Hashtable environment) throws > NamingException > > What I would guess, being almost totally new to both Jython > and Java, is > that "env" is not being properly passed as a java.util.Hashtable, and > therefore I'm not getting a context to do my name lookup in. > > I notice that NoInitialContext is thrown when JNDI cannot create an > initial context. > > Any pointers would be much appreciated. > > -------------------------------------------------------------- > --------------- > Brian Knox > Just Another Perl Hacker > perl -le '$_="6110>374086;2064208213:90<307;55";tr[0->][ > LEOR!AUBGNSTY];print' > > > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > |