From: Samuele P. <pe...@in...> - 2001-06-12 14:43:09
|
Hi. > > 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() where's the env here, jndiContext = javax.naming.InitialContext(env) could help ;) > 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 |
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 > |
From: <la...@lu...> - 2001-06-12 14:49:19
|
Arg. Actually, having the env in there doesn't help. This is what I get for writing emails before I've had coffee :) The env is in the call in my code I still get the same error jndiContext = javax.naming.InitialContext(env) name = "interest/Interest" jndiContext.lookup(name) Here's the entire exception 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 at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:647) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284) at javax.naming.InitialContext.lookup(InitialContext.java:351) at java.lang.reflect.Method.invoke(Native Method) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160) at org.python.core.PyMethod.__call__(PyMethod.java:96) at org.python.core.PyObject.__call__(PyObject.java:274) at org.python.core.PyInstance.invoke(PyInstance.java:263) at org.python.pycode._pyx0.f$0(interest.py:15) at org.python.pycode._pyx0.call_function(interest.py) at org.python.core.PyTableCode.call(PyTableCode.java:198) at org.python.core.PyCode.call(PyCode.java:13) at org.python.core.Py.runCode(Py.java:1075) at org.python.core.__builtin__.execfile(__builtin__.java:298) at org.python.core.__builtin__.execfile(__builtin__.java:302) at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:155) at org.python.util.jython.main(jython.java:164) javax.naming.NoInitialContextException: 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 ----------------------------------------------------------------------------- Brian Knox Just Another Perl Hacker perl -le '$_="6110>374086;2064208213:90<307;55";tr[0->][ LEOR!AUBGNSTY];print' On Tue, 12 Jun 2001, Samuele Pedroni wrote: > Hi. > > > > > 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() > > where's the env here, > jndiContext = javax.naming.InitialContext(env) could help ;) > > > 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 > |