2

I'm using the Weblogic Scripting Tool aka WLST, a Python-based shell environment, to programmatically edit variables in Plan.xml files for projects to be deployed to the Weblogic server. I can get as far as getting an instance of the WLSTPlan Object, and can run getVariables and other methods to check that it is populated and view its contents. However, when I try to call the setVariable method, I get an AttributeError, which to my limited understanding means the method doesn't exist:

wls:/UoADevDomain/serverConfig> plan.setVariable("foo", "bar")
Traceback (innermost last):
  File "<console>", line 1, in ?
AttributeError: setVariable

As the docs linked above (which I checked are the right version) show, this method definitely should exist, and other methods listed in the same doc work. I'm not sure if this is an issue with Weblogic or with my understanding of Python, but either way it's beyond me. I tried using the dir() function to list the plan object's attributes, but it returned an empty set so I guess that trick doesn't work in this environment.

Can anyone suggest how to go about diagnosing this problem, or better still fixing it?

Johansensen
  • 371
  • 1
  • 12
  • Can you try `plan.showVariables()` – JoseK Aug 25 '11 at 08:25
  • Yes. Further investigation shows that all the methods which create, delete or read data in the model work fine, but all the methods which update existing data (so basically plan.set*) claim to not exist. – Johansensen Aug 25 '11 at 22:09

2 Answers2

2

Using javap and looking for setters on the WLSTPlan bean shows only the following setter

void setVariableValue(java.lang.String, java.lang.String);

Could be a typo in the docs. Can you try 'setVariableValue' instead.

prash
  • 361
  • 2
  • 1
  • Thanks, this appears to work. Very odd that the docs here are so wrong- the class doc lists a whole bunch of different setters, and not this one, but this is the only one that works. Thanks! – Johansensen Aug 30 '11 at 00:21
  • Looking at WLS 10.3 docs, it appears like the docs have been corrected - http://download.oracle.com/docs/cd/E21764_01/web.1111/e13715/dep_obs.htm#i1019049 – prash Aug 30 '11 at 18:20
0

The documentation is rather unclear, but from reading between the lines, it looks like setVariable is a method that you invoke on a VariableBean.

I'd try using the following:

plan.createVariable("foo").setVariable("foo", "bar");

(that's without having tested the code, though)

kevinpowe
  • 496
  • 3
  • 5
  • I'm not sure what gives you that idea, the docs list setVariable as a method for WLSTPlan. VariableBean does not have this method, although I'm yet to find any documentation on what methods it *does* have (thanks, BEA/Oracle). – Johansensen Aug 30 '11 at 00:17