It turns out that the issue was/is somewhere behind the keyboard ;)

My jython2.2.1's registry file had respectJavaAccessibility set to false and that caused the issues described below.
When I set it to true my scripts work as before.

Is this the expected behavior of respectJavaAccessibility?

----- Original Message ----
From: marcel liker <m_liker@yahoo.com>
To: Oti <ohumbel@gmail.com>
Cc: jython-users@lists.sourceforge.net; Charlie Groves <charlie.groves@gmail.com>
Sent: Wednesday, January 16, 2008 6:16:57 PM
Subject: Re: [Jython-users] jython's convenience java methods

Picking up on this again now after I observed some interesting behavior.

Using the same example as below

[mliker@box1 ~]$ ./rlwrap jython
Jython 2.2.1 on java1.4.2_08
Type "copyright", "credits" or "license" for more information.
from weblogic.jndi import Environment
from weblogic.management import MBeanHome
>>> >>> user, password, server = 'user', 'password', 'server'
>>> env = Environment(providerUrl = 't3://' + server + ':80', securityPrincipal = user, securityCredentials = password)
>>> env.initialContext
>>> env.getInitialContext()
WLContext ()
>>> env.initialContext
WLContext ()

See how the call to env.initialContext returns the expected thing but not before the env.getInitialContext() is called!
 
I observed the same thing as above with getPassword() method from http://edocs.bea.com/wls/docs81/javadocs/weblogic/management/configuration/JDBCConnectionPoolMBean.html

Any thoughts?

Thanks,
Marcel

----- Original Message ----
From: marcel liker <m_liker@yahoo.com>
To: Oti <ohumbel@gmail.com>
Cc: jython-users@lists.sourceforge.net; Charlie Groves <charlie.groves@gmail.com>
Sent: Monday, December 3, 2007 5:35:04 PM
Subject: Re: [Jython-users] jython's convenience java methods

Thanks Oti for your analysis. I always considered 'initialContext' to be jython's shortcut to getInitialContext() and treated it like that (and actually prefer it as well).
I have not changed the weblogic.jar recently, however, I did change the jython version hence my suspicion that it is  jython 2.2.1's issue.
As you say the good news is that I can use getInitialContext(), however, the question why it works with 2.2 but not with 2.2.1 remains unanswered.

Marcel

----- Original Message ----
From: Oti <ohumbel@gmail.com>
To: marcel liker <m_liker@yahoo.com>
Cc: Charlie Groves <charlie.groves@gmail.com>; jython-users@lists.sourceforge.net
Sent: Monday, December 3, 2007 4:47:50 PM
Subject: Re: [Jython-users] jython's convenience java methods

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_liker@yahoo.com> 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 <ohumbel@gmail.com>
> To: marcel liker <m_liker@yahoo.com>
>
> Cc: Charlie Groves <charlie.groves@gmail.com>;
> jython-users@lists.sourceforge.net
> 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_liker@yahoo.com> wrote:
> >
> > ----- Original Message ----
> > From: Charlie Groves <charlie.groves@gmail.com>
> > To: marcel liker <m_liker@yahoo.com>
> > Cc: jython-users@lists.sourceforge.net
> > 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_liker@yahoo.com> 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
> > Jython-users@lists.sourceforge.net
> > 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!





      Connect with friends from any web browser - no download required. Try the new Yahoo! Canada Messenger for the Web BETA at http://ca.messenger.yahoo.com/webmessengerpromo.php

-------------------------------------------------------------------------
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
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users



Looking for the perfect gift? Give the gift of Flickr!



Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail