1 Reply Latest reply: Aug 8, 2012 4:17 AM by 944567 RSS

    running wlst from org.python.util.jython instead of weblogic.WLST

    user4478438
      Hi,

      I am trying to modularise my jython wlst scripts and in doing so I have noticed that it is recommended that when importing wlst as a module it is best to invoke the scripts using org.python.util.jython instead of weblogic.WLST to avoid unpredictable behaviour. (There is even a wlst command 'writeIniFile("<filename>.py")' which creates the wlst module for importing into your scripts.

      This was working well until I tried to use the built in object 'cmo'. This object exists when invoking jython though weblogic.WLST or from org.python.util.jython, but commands that are available when invoking under weblogic.WLST are not available when invoking under org.python.util.jython. It can be seen that the class of the cmo object running under weblogic.WLST is '$Proxy8' (which I guess is generated and so can change) and under org.python.util.jython it is "<type 'NoneType'>".

      Does anyone know why this is and what needs to happen in order to make these variables have the correct type.

      The commands I used to investigate this are as follows:

      (Set the environment as you would for running under weblogic.WLST)
      From Jython:
      java org.python.util.jython
      from wlstModule import *
      connect("weblogic","weblogic","t3://localhost:7001")
      domainConfig()
      dumpVariables()
      cmo [MBeanServerInvocationHandler]com.bea:Name=osb_domain1,Location=osb_domain1,Type=Domain
      cd("/")
      cmo.getAdminServerName()
      Traceback (innermost last):
      File "<console>", line 1, in ?
      AttributeError: 'NoneType' object has no attribute 'getAdminServerName'
      print cmo.__class__
      <type 'NoneType'>

      From weblogic.WLST:
      java weblogic.WLST
      connect("weblogic","weblogic","t3://localhost:7001")
      domainConfig()
      dumpVariables()
      cmo [MBeanServerInvocationHandler]com.bea:Name=osb_domain1,Location=osb_domain1,Type=Domain
      cd("/")
      cmo.getAdminServerName()
      'AdminServer'
      print cmo.__class__
      $Proxy8
        • 1. Re: running wlst from org.python.util.jython instead of weblogic.WLST
          944567
          Having a likewise problem(weblogic 10.3.3), here is what I found:

          while running jython interactively, I do an import of the wlst-file created by the writeIniFile-method(import wl)

          complete code:
          +
          import wl
          connect(serverdetails)
          wl.domainConfig()
          wl.cd('/')
          print(wl.cmo.getAdminServerName())
          +

          which gives the correct result 'weblogicTestDomainAdmin'(in my case)

          when I do

          +
          from wl import *
          connect(serverdetails)
          domainConfig()
          cd('/')
          print(cmo.getAdminServerName())
          +

          I get your error.

          the workaround as it stands is to prepend all your WL-calls with the name of your imported file and using + import wlstModule as w#now you can use w.connect instead of wlstModule.connect +


          Sorry for not being able to deliver a final solution, but atleast some extra info for fellow searchers.

          Greetings