Jython - How to get the path of the executed script - websphere

I've found many answer about the python way but what I found isn't working with jython.
I'm running a jython script using the WebSphere interpreter wsadmin -lang jython -f /path/to/script
I'd like to know the path of the script im running.
This script if versionned and can be checked out anywhere so I need to reliably know where the script is being executed from.
Thanx to everyone

WebSphere doesn't make this easy. And I've yet to find a way to do this when using Sun's JVM running WebSphere on Solaris. However, you may be able to figure out the script name using the environment when running WebSphere on Linux, Aix and possibly others OSes. On these platforms, IBM's JVM sets the environment variable IBM_JAVA_COMMAND_LINE. You can parse it to get the '-f' argument passed to wsadmin.sh Dave Brand has code to do this on his blog. See fix #6 in his ibmfixes.py script.

Related

Heap Dump not working Centos 7

I have added following setting in my catalina.sh file
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/root/logs".
But still the heap dump file is not created when tomcat is going down. I have this setup on centos 7 on AWS.
Please help me in solving this issue... Thanks in advance.
I would suggest try create it manually if it is not generating automatically by using a JDK bundled tool called jmap, although we recommend that you use the automatic method above for best result.
For Linux/Solaris-based Operating Systems:
Please execute the following command on Linux OS:
$JAVA_HOME/bin/jmap -dump:format=b,file=heap.bin <pid>
More Ref Follow the link below :
https://confluence.atlassian.com/doc/generating-a-heap-dump-219024032.html
the tomcat process is usually set up to run as the tomcat user, who most likely will not have any write access to your /root folder.
Please try to set it to somewhere like /tmp

Will the IBM Websphere Application Server run the Python/Jython script without Python Interpreter installed

I am new to Python and IBM Websphere Application Server.
I run a status.bat file which calls status.py file through wsadmin(provided username, password and status.py path passed as parameters to wsadmin). IBM Websphere Application Server is installed in the machine.What i want to know is a Python Interpreter needed to run a python script, it was not installed in the system.
Since the script is running through a WAS server-wsadmin, it had a capability to run a PY script even without having a PY Interpreter in that machine?? by its own compiling tool??
If it is must to have PYTHON.exe installed, do i need to tell wsadmin or anywhere that it is a PY script??
NOTE: The script and .bat was already existed in the machine and im supossed to work on it. I dont have any idea of the purpose of using wsadmin to run the script instead of by directly calling script by [python status.py] in .bat
Summary :- WS server had an any internal PY Interperter??
Thanks in Advance Friends....
WebSphere Application Server comes with Jython – Python implementation for JVM. It is usually located under <WAS_HOME>/optionalLibraries/jython.
To run a script you can use wsadmin:
./wsadmin.sh -lang jython -f your_script.py
The purpose of using wsadmin is that it provides facilities for server administration. If you don't need those then you can probably utilize optionalLibraries/jython/jython.jar directly although I never did this myself.

Starting a application with graphical interface on boot

I have a small question that I havn't found any answers to.
I run a virtual machine on my CentOS server, and I have made a simple script to start the virtual machine. I would like to run the script on boot so that the virtual machine starts up on boot also. So I successfully registered the script with following
chkconfig --add myscript
and enabled it with following
chkconfig --level 2345 myscript on
at last I checked it so its registered and enabled correctly with
$ chkconfig --list | grep myscript
So long, so fine, but when I restart my machine to test it, well nothing happens.
So now I wonder why isn't my script running? I had some thaughts that it cold be because of some missing arguments, myscript requires an argument "start" to run properly, so I think that could be the cause why it's not running, in that case where should I add the argument?
Note also, my script is ok, or at least I can run it manually.
UPDATE
The script is run during boot and is working as it should. Tha application I try to start with a script, my virtal machine, has a graphical interface and it seems like it's that causing the trouble. Does anyone have any experience in starting a graphical application with script on boot, on unix based OS's ofcourse? Or if there are any other clever ways of achieve this?
Thanks!
Make sure that the proper symlinks get created in /etc/rc.?/ and your startup script in /etc/init.d/ should contain start and stop methods.

How to stop/start specfic WebSphere-deployed EAR from command line?

I'm throwing a dependency jar into my exploded EAR on WebSphere app server. I need to stop/start the EAR to get WS to execute the new code. Is there a way to do this from command line?
Try running something like this:
/opt/ibm/websphere/appserver/profiles/<MyProfileName>/bin/wsadmin.sh -c "AdminControl.invoke(AdminControl.queryNames('type=ApplicationManager,process=<MyServerName>,*'),'stopApplication','MyAppName')" -lang jython
It will prompt you for a WAS Userid and password (in case you have enabled "Administrative Security") and when you enter them - provided your userid has at least been assigned the Operator Role - your application will be stopped.
In a similar way you may start the same application.
You should be able to manage that using the wsadmin command line tool provided as a part of your WAS installation. Pretty much any administration task can be scripted using this tool.
I don't know the specific command to do what you've asked but here is a link to the documentation that should help get you going.
http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Ftxml_script.html

Websphere MQ Client installation

I am working on a project where MQ client (Support PAC 7) is installed on one 64-bit Linux machine and it sends messages to server.
On client machine we are using 64-bit linux JDK 1.6.25
java -version
java version "1.6.0_25"
I have following environment variable set up
MQSERVER='my_channel/tcp/SRVD10995(1414)'
MQ_INSTALL_ROOT=/var/mqm/
MQ_JAVA_DATA_PATH=/var/mqm/
MQ_JAVA_INSTALL_PATH=/opt/mqm/java/
MQ_JAVA_LIB_PATH=/opt/mqm/java/lib64
LD_LIBRARY_PATH=/opt/mqm/java/lib64
CLASSPATH= /opt/mqm/java/lib/com.ibm.mq.jar:/opt/mqm/java/lib/com.ibm.mqjms.jar:/opt/mqm/samp/jms/samples:/opt/mqm/samp/wmqjava/samples
but when I run following command
dspmqver -p 6
For native libraries I am seeing following message:
Name: IBM WebSphere MQ
Version: 7.0.1.6
CMVC Level: k701-106-110721 mqjbnd=CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd' was not found. [3=mqjbnd]::no mqjbnd in java.library.path
Build Type: Production
I am also getting same error message when I execute JMS code to connect to server. I do not have libmqjbnd.so is not in the /opt/mqm/java/lib64 folder, and not even in 32 bit folder.
I have couple of questions :
1) How do I fix this problem for client installation?
2) Does the library file (.so) need to be there in that directory ?
I will be thankful if anyone provides me answer to above questions, I have already invested many hours in this but no joy.
There's a Technote on this specific question here. Let us know if the solution presented there does not resolve your problem.
Update: I noticed a mismatch between your CLASSPATH which is pointing to the 32-bit libs and the other variables pointing to the 64-bit libs. WMQ provides scripts that set the variables for you as described in the Infocenter:
On a UNIX system, you can use the script setjmsenv (if you are using a 32-bit
JVM) or setjmsenv64 (if you are using a 64-bit JVM) to set the environment
variables. On AIX, these scripts are in the /usr/mqm/java/bin directory and,
on HP-UX, Linux, and Solaris, they are in the /opt/mqm/java/bin directory.
Many people source the scripts in their .profile. Have you tried running these? Remember that simply running the script...
/opt/mqm/java/bin/setjmsenv64
...does not result in the env vars being set in the current shell. The script must be sourced using the dot syntax as follows:
. /opt/mqm/java/bin/setjmsenv64
What results do you get after sourcing the appropriate setjmsenv or setjmsenv64 script?
Whether you need the libraries depends how you want to send messages to the server. WebSphere MQ allows you to choose between bindings mode and client mode. Bindings mode uses the libraries with some IPC while client mode is purely Java and TCP based.
If your programming language is Java then i would choose client mode.
This message occurs also when you forget to set properties for host, port, ...
This is in case of standalone MQ client.
MQEnvironment.hostname = "mqm.onZos.myCompany.com";
MQEnvironment.port = 1234;
MQEnvironment.channel = "SYSTEM.MYCH.NAME";

Resources