In Jython we have issubclass() to check superclass, subclass relation we can verify class relationship. You can find parent-child relationship with it. As per my understanding the Error hierarchy can be defined in WLST(Jython) as follows:
This WLST(Jython) Error tree I prepared and posted for your reference, so that you can make your script in perfect manner, here you can find what is going wrong why it is happen while working out your script.
try: # WLST code Block # perform some tasks that may throw an exception except ExceptionType, ExceptionVar: # WLST code or # perform some exception handling finally: # perform tasks that must always be completed (Will be performed before the exception is # raised.) else: # execute code that must always be invoked
The pass statement in WLST
While writing WLST scripts, there are some situations where you need ‘do nothing’ statement syntactically. That is provided by the pass statement. When you start working on Exception handling this statement will be the first experimenting statement for you.
WLST raise statement
In WLST raise is used to generate or invoke an exception condition. The syntax of this statement allows three comma separated expressions which are optional. If no expression is present, WLST attempt to re-raise the last exception that was raised. This raise statement we can use when we need exception handling with robust scripts. When you pass the expressions to the raise statement, the first two expressions are evaluated to get the objects. These objects are then used to determine the type and value of the exception. Omitted expressions are treated as None. The third expression could be used for traceback objects.
wls:/offline> try: ... raise Exception('SituationalResponse') ...except Exception, e: ... print e ... java.lang.Exception: SituationalResponse
SyntaxError
This you cannot be handled with the try-except block, because it will be thrown when your syntax is not in properly arranged, that is in the statement missing indentation or improper arguments. SyntaxError could be raised when the script lines are given for parsing, it will do token by token parsing wherever the improper syntax given WLST Shell points with cap char under the token.Now let us see the sample indentation issue that raises the Syntax Error.
wls:/offline>; try: ...connect('system','weblogic103','t3://adminhost:adminport') Traceback (innermost last): (no code object) at line 0 File "", line 2 connect('system','weblogic103','t3://adminhost:adminport') ^ SyntaxError: invalid syntax
Another option for Syntax Error
This Error I have observed when I tried to migrate the WebLogic domain with createDomain() command.
wls:/offline/wdomain>createDomain('/home/backup/olddomain.jar', '/home/otherusr/domains/newdomain',’system', 'weblogic103') Traceback (innermost last): (no code object) at line 0 File "", line 1 createDomain('/home/backup/olddomain.jar', '/home/otherusr/domains/newdomain',?system', 'weblogic103') ^ SyntaxError: Lexical error at line 1, column 99. Encountered: "\ufffd" (65533), after : ""
This "Lexical error" got due to the copying from the webpage which has single quotes in different unicode value. When I retype the single quotes it was resolved.
Here in the above sample after issuing try block starting we must use a tab or 4 spaces before connect() command. When it found that is not
having proper indentation it raised the SyntaxError.
NameError
When the name used to do something like print or use in some other expression without assigning the value before it was defined then WLST will raises NameError. When first time scripting most of the time user encounters this unknowingly.
The following example might give you an idea how to resolve your issue.
wls:/offline> var1=100 wls:/offline> var3=var1+var2 Traceback (innermost last): File "", line 1, in ?
You can handle this kind of error with our try-except block
wls:/offline> try: var3=var1+var2 ...except NameError, e: ... print "Please check there is: ", sys.exc_info()[0], sys.exc_info()[1] ... Please check there is: exceptions.NameError var2
The beauty of handling your Exception/Error more transparent and easy to understand with sys.exc_info() list.
KeyError
This error can be raised by the WLST while using the dictionary objects or map objects accessed with non-matching key.
wls:/offline> urls['b'] Traceback (innermost last): File "", line 1, in ? KeyError: b
ValueError
The ValueError is raised by the WLST shell when there is a inappropriate element is accessed in a list or a variable, that is such as the value specified for searching in the list with index() method. Removing the element which is not really exists in the list.wls:/offline> L.index('web2') Traceback (innermost last): File "<console>", line 1, in ? ValueError: list.index(x): x not in listI was working on thread and JVM monitoring script, encountered with the ValueError in different way. After storing the ThreadPool values, JVM values into local variables I was using C type of formatting to display the data in a row of Table. Some of the attribute values are Long integers, some of them plain integers some of them are strings.
cd('/ServerRuntimes/'+ svr +'/ThreadPoolRuntime/ThreadPoolRuntime') thtot=`get('ExecuteThreadTotalCount')` thid= `get('ExecuteThreadIdleCount')` hog= `get('HoggingThreadCount')` sbth= `get('StandbyThreadCount')` cr =`get('CompletedRequestCount')` pr =`get('PendingUserRequestCount')` ql =`get('QueueLength')` th= `get('Throughput')` cd('/ServerRuntimes/'+svr+'/JVMRuntime/'+svr) freejvm = long(get('HeapFreeCurrent'))/(1024*1024) totaljvm = long(get('HeapSizeCurrent'))/(1024*1024) usedjvm = (totaljvm - freejvm)
When I ran with all numbered values with format as %5d it was shouted as follows:
ValueError: unsupported format character ' ' (0x20) at index 23Don't know what attribute requires which format ... Initially to resolve this display without any format for all attributes values from the MBean.
print svr, thtot, thid, hog, sbth, cr, pr, ql, th, hs, totaljvm, freejvm, usedjvmBut still ValueError was exists, when I updated with formatter it was stuck with CompletedRequestCount that was not integer type, it is actually Long integer type and that was causing the Error. So, changed the format for that attribute it resolved one issue. Now the issue with different index number came... I have an idea that, if I found all the attributes and their data types then it will be easy to fix the right format for each. I tried the following way
print type(thtot),type(thid), type(hog), type(sbth), type(cr), type(pr), type(ql), type(th),type(freejvm), type(totaljvm), type(usedjvm)formatted accordingly the ValueError is resolved.
print '%14s %10s %5s %5s %5s %5s %8s %5s %5s %8s %5dMB %5dMB %5dMB' % (svr, hs, thtot, thid, hog, sbth, cr, pr, ql, th, totaljvm, freejvm, usedjvm)So now you can take care of Values of variables for your WLST code before use them for any operation!!
AttributeError
You might be on MBean tree where there is no such attribute defined and you tried to access it then WLST Shell raises AttributeError. Let us see an Example you can easily understand.
wls:/demodom/serverConfig> cmo.State() Traceback (innermost last): File "", line 1, in ? AttributeError: State
IndexError
The IndexError will be raised by the WLST shell, when thelist object is accessed with a out of range index value.Let us see the example a list is defined with 5 elements
wls:/offline> L['app1', 'app2', 'app3', 'app4', 'web1']when it is accessed with out of range index value say 7 then you get the IndexError.
wls:/offline> L[7] Traceback (innermost last): File "<console>", line 1, in ? IndexError: index out of range: 7
TypeError
The basic python object types int, str assignments or expressions or print statements withconcatenation does not allows you, raises the TypeError.
wls:/offline> print 'Number of servers:', 5 Number of servers: 5 wls:/offline>print 'Number of servers:'+ 5 Traceback (innermost last): File "<console>", line 1, in ? TypeError: cannot concatenate 'str' and 'int' objects
Thanks for reading this post, Give your feedback in comments. cheers!!
Good References:
Hi, I am getting Name Error when I run the following script. Could you please help on how to fix this. I have just pasted half the script here. If you want the full script please let me know.
ReplyDeleteThis is the error I get when I run the script:
=================================
java weblogic.WLST testdeploy.py -n true -u weblogic -p password123 -a localhost -m ShoppingCart.war -c deploy -d /home/oracle/fmw/ -t AdminServer
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
usage:
java weblogic.WLST testdeploy.py [-n] -u user -p password -a url -m moduleName -c command -d sourcedir -t targets
Problem invoking WLST - Traceback (innermost last):
File "/home/oracle/fmw/Atradius/testdeploy.py", line 30, in ?
NameError: opts
================================
========AutoDeploy.ps====================
import getopt
import sys
import os
from java.lang import System
def usage():
print 'usage:'
print 'java weblogic.WLST testdeploy.py [-n] -u user -p password -a url -m moduleName -c command -d sourcedir -t targets'
#print "java weblogic.WLST app_ctl.py [-n] -u user -p password -a url -m moduleName -c command -d sourcedir -t targets -s stagemode"
try:
opts, args = getopt.getopt(sys.argv[1:], "nu:p:a:m:c:d:t:", ["user=", "password=", "url=","moduleName=", "command=", "soucedir", "targets"])
#opts, args = getopt.getopt(sys.argv[1:], "nu:p:a:m:c:d:t:s:", ["user=", "password=", "url=","moduleName=", "command=", "soucedir", "targets", "stagemode"])
except getopt.GetoptError, err:
print str(err)
#sys.exit(2)
usage()
reallyDoIt = true
user=None
password=None
url=None
moduleName=None
command=None
sourcedir=None
targets=None
#stagemode=None
for opt, arg in opts:
if opt == "-n":
reallyDoIt = false
elif opt == "-u":
user = arg
elif opt == "-p":
password = arg
elif opt == "-a":
url = arg
elif opt == "-m":
moduleName = arg
elif opt == "-c":
command = arg
elif opt == "-d":
sourcedir = arg
elif opt == "-t":
targets = arg
=======================================
@Ajay, looking into your script I suggest two things please check the indentation that is mandatory for the Python scripting. other one is use your options with getopt module which you get it from the command lie arguments.
Deleteopts, args = getopt.getopt(sys.argv[1:], "nu:p:a:m:c:d:t:", ["user=", "password=", "url=","moduleName=", "command=", "soucedir", "targets"])
is this line working for you.
An "else:" statement applies to the "except:", so it only runs if there is not an exception. So in your first code sample the below comment is incorrect.
ReplyDelete"else:
# execute code that must always be invoked"
Great and useful article. Creating content regularly is very tough.Thanks you. argumentative thesis statement examples
ReplyDeletegreat article and usefull to Python Strings
ReplyDeleteiphongthuynet
ReplyDeleteiphongthuynet
iphongthuynet
iphongthuynet
iphongthuynet
iphongthuynet
iphongthuynet
iphongthuynet
iphongthuynet
An intriguing discussion is definitely worth comment. I do believe that you should publish more about this subject matter, it might not be a taboo matter but generally folks don't talk about these subjects. To the next! All the best!!
ReplyDeletemotorola display repair bangalore
Hi! I simply would like to offer you a big thumbs up for your excellent information you have got right here on this post. I will be coming back to your site for more soon.
lg service center Bangalore
After I originally commented I appear to have clicked on the -Notify me when new comments are added- checkbox and now whenever a comment is added I receive four emails with the same comment. There has to be an easy method you can remove me from that service? Thanks a lot!
vivo charging port replacement
I’m impressed, I have to admit. Seldom do I come across a blog that’s equally educative and amusing, and let me tell you, you've hit the nail on the head. The issue is an issue that too few folks are speaking intelligently about. I'm very happy that I stumbled across this during my search for something relating to this.
ReplyDeletehuawei display repair bangalore
Oh my goodness! Incredible article dude! Thanks, However I am encountering troubles with your RSS. I don’t know the reason why I cannot subscribe to it. Is there anybody getting similar RSS issues? Anybody who knows the answer can you kindly respond? Thanx!!
asus display replacement
An outstanding share! I've just forwarded this onto a coworker who was conducting a little homework on this. And he in fact bought me dinner due to the fact that I found it for him... lol. So allow me to reword this.... Thanks for the meal!! But yeah, thanks for spending time to discuss this topic here on your site.
onsite mobile repair bangalore
Thanks for posting. Its an Important topic to be read.
ReplyDeletePython Training in Hyderabad
Python Training
Python Online Training
thx for ur valuable time
ReplyDeletePHP Training in Chennai | Certification | Online Training Course | Machine Learning Training in Chennai | Certification | Online Training Course | iOT Training in Chennai | Certification | Online Training Course | Blockchain Training in Chennai | Certification | Online Training Course | Open Stack Training in Chennai |
Certification | Online Training Course
I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site.
ReplyDeletepython training in bangalore
python training in hyderabad
python online training
python training
python flask training
python flask online training
python training in coimbatore
Python Course in Noida
ReplyDeleteExactly, I was looking for such kind of article on the Internet and finally ended up here. Thanks for such kind of spectacular content.
ReplyDeleteDelhi Bazar Satta Chart
Wedding hall in Meerut
Top 10 CBSE Schools Meerut
SEO Expert in Meerut
SEO Expert in Meerut
Software Development Company In Delhi NCR
Digital Marketing Company in Hapur
Web Development Meerut
Non Availability of Birth Certificate in Kolkata
Website Design in Meerut
Siwaya Jamalullapur India
Selenium training in pune
ReplyDeleteSelenium classes in pune
Best Paramedical College in India
ReplyDeletethis is best post to read.
Such an interesting blog.
ReplyDeleteBest Ayurvedic College in India
This comment has been removed by the author.
ReplyDeleteI have learned so much from your article. I encourage you to keep on posting.
ReplyDeleteBest University for
Diploma Engineering in Roorkee
Best University for Legal Studies in Uttarakhand
It is a great wesite and useful information thanks for providing
ReplyDeleteMobile Prices Bangladesh
i found your this call despite the fact that searching for a few related reference concerning blog search...Its a nice publicize..store posting and update the mention. Nord VPN Cracked
ReplyDeleteUnlike additional blogs I have read which are really not tht good. I also found your posts very interesting.
ReplyDeletenachpromi
Your site blog was too good.
ReplyDeleteTotal Av Antivirus Crack
360 Total security Crack
Kutools For Excel Crack
Court marriage takes place through the court. Click here to know more Arya Samaj Mandir Haridwar
ReplyDeleteGreat post, thanks for sharing such a valuable information Salesforce Classes In Pune
ReplyDeletesuch an amazing blog
ReplyDeletesql server online training in hyderabad kphb
This comment has been removed by the author.
ReplyDeleteNice blog...We value the devotion you have shown to this site. Anticipate further excellent material. keep posting more
ReplyDeleteJava full stack training
This is one of the best blog about the wlst errors ,visit Full stack web development training in agra
ReplyDelete