From: Oti <oh...@gm...> - 2007-12-03 21:47:54
|
Marcel, thanks for the dir! It is now clear that there is no setInitialContext() method, so we are not dealing with bean properties here. I believe that 'initialContext' is a field, not a method. >From the javadoc at http://edocs.bea.com/wls/docs81/javadocs/weblogic/jndi/Environment.html, I could not find it. So over all it is very hard to believe that Jython 2.2 makes a difference. I tend saying it is the weblogic runtime initializing the field. But this is all subject to guessing... The good news is: getInitialContext() works. best wishes, Oti. On Dec 3, 2007 10:17 PM, marcel liker <m_...@ya...> wrote: > > Oti, > > [mliker@box1 ~]$ echo $CLASSPATH > /home/mliker/lib/weblogic.jar:/home/mliker/lib/libreadline-java.jar:/home/mliker/lib/ojdbc14_10g.jar > [mliker@jbox1 ~]$ jython/jython > > Jython 2.2.1 on java1.4.2_08 > Type "copyright", "credits" or "license" for more information. > >>> from weblogic.jndi import Environment > >>> env = Environment() > >>> dir(env) > ['DEFAULT_INITIAL_CONTEXT_FACTORY', 'FALSE', 'LOCAL_URL', > 'SSLClientCertificate', 'SSLClientKeyPassword', 'SSLRootCAFingerprints', > 'SSLServerName', 'TRUE', '__init__', 'cantReadSystemProperties', 'class', > 'class$weblogic$jndi$WLInitialContextFactory', 'clone', 'copyOnWrite', > 'createIntermediateContexts', 'delegateEnvironment', > 'enableCallByReference', 'enableServerAffinity', 'env', 'equals', > 'factoryReference', 'finalize', 'getBoolean', 'getClass', 'getContext', > 'getCreateIntermediateContexts', 'getDelegateEnvironment', > 'getEnableCallByReference', 'getEnableServerAffinity', 'getInitialContext', > 'getInitialContextFactory', 'getObsoleteProperty', 'getPinToPrimaryServer', > 'getProperties', 'getProperty', 'getProviderRJVM', 'getProviderUrl', > 'getRemoteProperties', 'getReplicateBindings', 'getSSLClientCertificate', > 'getSSLClientKeyPassword', 'getSSLRootCAFingerprints', 'getSSLServerName', > 'getSecurityCredentials', 'getSecurityPrincipal', 'getSecuritySubject', > 'getSecurityUser', 'getString', 'hashCode', 'ignoreTrustValidation', > 'initialContext', 'initialContextFactory', 'loadLocalIdentity', 'notify', > 'notifyAll', 'pinToPrimaryServer', 'properties', 'providerRJVM', > 'providerUrl', 'readExternal', 'registerNatives', 'remoteProperties', > 'removeProperty', 'replicateBindings', 'securityCredentials', > 'securityPrincipal', 'securitySubject', 'securityUser', 'serialVersionUID', > 'setBoolean', 'setCreateIntermediateContexts', 'setDelegateEnvironment', > 'setEnableCallByReference', 'setEnableServerAffinity', > 'setIgnoreTrustValidation', 'setInitialContextFactory', > 'setPinToPrimaryServer', 'setProperty', 'setProviderRJVM', 'setProviderUrl', > 'setReplicateBindings', 'setSSLClientCertificate', > 'setSSLClientKeyPassword', 'setSSLRootCAFingerprints', 'setSSLServerName', > 'setSecurityCredentials', 'setSecurityPrincipal', 'setSecuritySubject', > 'setSecurityUser', 'subject', 'toString', 'wait', 'writeExternal'] > > As I stated in my previous emails, the only difference between jython2.2 and > jython2.2.1 is that when using this method ('initialContext') in 2.2 it > returns proper however in 2.2.1 it seems as if it did not execute. Using > 'getInitialContext' works both under 2.2 and 2.2.1 > > Hope that helps, > Marcel > > > ----- Original Message ---- > From: Oti <oh...@gm...> > To: marcel liker <m_...@ya...> > > Cc: Charlie Groves <cha...@gm...>; > jyt...@li... > Sent: Monday, December 3, 2007 4:03:33 PM > Subject: Re: [Jython-users] jython's convenience java methods > > Marcel, > > could you please provide a > dir(env) > > I suspect that initialContext is not a setter/getter pair, but > something else, like in my example below. > > Consider the following Java class with an unbalanced initialContext: > package st.extreme.jython; > public class Environment { > public Environment() { > } > public String initialContext; > public String getInitialContext() { > return "getInitialContext"; > } > } > > and then, after calling jython interpreter: > > >>> from st.extreme.jython import Environment > >>> env = Environment() > >>> dir(env) > ['__init__', 'class', 'equals', 'getClass', 'getInitialContext', > 'hashCode', 'initialContext', 'notify', 'notifyAll', 'toString', > 'wait'] > >>> print env.getInitialContext() > getInitialContext > >>> print env.initialContext > None > >>> env.initialContext.someMethod() > >>> Traceback (innermost last): > File "<console>", line 1, in ? > AttributeError: 'NoneType' object has no attribute 'someMethod' > > > best wishes, > Oti. > > On Dec 1, 2007 10:37 PM, marcel liker <m_...@ya...> wrote: > > > > ----- Original Message ---- > > From: Charlie Groves <cha...@gm...> > > To: marcel liker <m_...@ya...> > > Cc: jyt...@li... > > Sent: Saturday, December 1, 2007 4:06:44 PM > > Subject: Re: [Jython-users] jython's convenience java methods > > > > On Dec 1, 2007 11:57 AM, marcel liker <m_...@ya...> wrote: > > > Hi there, > > > I ran into an issue with Jython's "convenience" java methods. > > Consider this example: > > > > > > [mliker@jbox1 ~]$ ./rlwrap jython/jython > > > Jython 2.2.1 on java1.4.2_08 > > > Type "copyright", "credits" or "license" for more information. > > > > > > >>> from weblogic.jndi import Environment > > > >>> server, user, password = 'server', 'user', 'password' > > > >>> env = Environment(providerUrl = 't3://' + server + ':80', > > securityPrincipal = user, securityCredentials = password) > > > >>> > > env.getInitialContext().lookup("javax.jms.QueueConnectionFactory") > > > weblogic.jms.client.JMSXAConnectionFactory@1d226a7 > > > > > > however: > > > > > > [mliker@box1 ~]$ ./rlwrap jython/jython > > > > > > Jython 2.2.1 on java1.4.2_08 > > > > > > Type "copyright", "credits" or "license" for more information. > > > > > > >>> from weblogic.jndi import Environment > > > >>> server, user, password = 'server', 'user', 'password' > > > > > > >>> env = Environment(providerUrl = 't3://' + server + ':80', > > securityPrincipal = user, securityCredentials = password) > > > >>> env.initialContext.lookup("javax.jms.QueueConnectionFactory") > > > Traceback (innermost last): > > > File "<console>", line 1, in ? > > > AttributeError: 'NoneType' object has no attribute 'lookup' > > > > It strikes me as odd that this is complaining about NoneType not > > having lookup on it. If the bean accessors weren't being created, > > you'd get an AttributeError about the lack of initialContext on env. > > Is there anything that could be going on here to cause > > getInitialContext to return null just in this instance? > > > > [Marcel] > > > > [mliker@box1 ~]$ ./rlwrap jython/jython > > >>> from weblogic.jndi import Environment > > >>> server, user, password = 'server', 'user', 'password' > > >>> env = Environment(providerUrl = 't3://' + server + ':80', > securityPrincipal = user, securityCredentials = password) > > >>> ctx = env.initialContext > > >>> type(ctx) > > <type 'NoneType'> > > >>> ctx = env.getInitialContext() > > >>> dir(ctx) > > ['APPLET', 'AUTHORITATIVE', 'BATCHSIZE', 'CREATE_INTERMEDIATE_CONTEXTS', > 'DELEGATE_ENVIRONMENT', 'DNS_URL', 'ENABLE_CALL_BY_REFERENCE', > 'ENABLE_SERVER_AFFINITY', 'INITIAL_CONTEXT_FACTORY', 'LANGUAGE', > 'OBJECT_FACTORIES', 'PIN_TO_PRIMARY_SERVER', 'PROVIDER_RJVM', > 'PROVIDER_URL', 'REFERRAL', 'REPLICATE_BINDINGS', 'SECURITY_AUTHENTICATION', > 'SECURITY_CREDENTIALS', 'SECURITY_PRINCIPAL', 'SECURITY_PROTOCOL', > 'SSL_CLIENT_CERTIFICATE', 'SSL_CLIENT_KEY_PASSWORD', > 'SSL_ROOT_CA_FINGERPRINTS', 'SSL_SERVER_NAME', 'STATE_FACTORIES', > 'URL_PKG_PREFIXES', 'addToEnvironment', 'bind', 'class', 'clone', 'close', > 'composeName', 'createSubcontext', 'destroySubcontext', > 'enableLogoutOnClose', 'env', 'environment', 'equals', 'finalize', > 'getClass', 'getEnvironment', 'getNameInNamespace', 'getNameParser', > 'getNode', 'getRemoteDelegate', 'hashCode', 'kernelId', 'list', > 'listBindings', 'log', 'loginThread', 'lookup', 'lookupLink', > 'nameInNamespace', 'node', 'notify', 'notifyAll', > > 'readExternal', 'rebind', 'registerNatives', 'remoteDelegate', > 'removeFromEnvironment', 'rename', 'serialVersionUID', 'toString', > 'translateException', 'unbind', 'wait', 'writeExternal'] > > >>> type(ctx) > > <type 'javainstance'> > > > > > > > > Your console > > output makes it seem like that's impossible, but it's the first thing > > I want to be sure of. Would it be hard for me to set this up locally > > or have you seen this anywhere else? > > > > [Marcel] > > > > I do not remember that I saw this before. If you would like to reproduce > it you would need: > > - Weblogic Server 8.1 sp5 installed and running > > - for jython put the $BEA_HOME/weblogic81/server/lib/weblogic.jar on your > classpath > > - use the same java version as the one used to run Weblogic Server > > > > > If somebody could also shed some light on how does jython provide > > these "convenience" methods as I have come across instances where not all > > java methods would have a jython "convenience" method > > > > It's based off of JavaBean properties: > > http://jython.org/Project/userguide.html#javabean-properties > > Essentially, if an object x has a getBlah method that returns a > > String, it can be accessed as x.blah and if it has a setBlah(String) > > method, it can be set with x.blah = 'whatever'. If the get method > > takes an argument, or if the setter returns something, they won't be > > exposed as a field since they're not JavaBeans. > > > > [Marcel] > > > > Thanks for the info Charlie > > > > Charlie > > > > > > > > > > > > Be smarter than spam. See how smart SpamGuard is at giving junk email > the boot with the All-new Yahoo! Mail. Click on Options in Mail and switch > to New Mail today or register for free at http://mail.yahoo.ca > > > > > > ------------------------------------------------------------------------- > > SF.Net email is sponsored by: The Future of Linux Business White Paper > > from Novell. From the desktop to the data center, Linux is going > > mainstream. Let it simplify your IT future. > > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > > > > > > ________________________________ > > > Yahoo! Canada Toolbar : Search from anywhere on the web and bookmark your > favourite sites. Download it now! |