rmarchei / jmxsh

Automatically exported from code.google.com/p/jmxsh
Apache License 2.0
0 stars 0 forks source link

Shell Mode: error using mbean names containing quotes (e.g. Tomcat 7 ThreadPools) #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. connect to a Tomcat 7 instance:
% jmx_connect -h localhost -p 1234

2. query a mbean ending with a quote:  
% jmx_get -m Catalina:type=ThreadPool,name="ajp-bio-8009" currentThreadsBusy
Error: Cannot convert result to a string.
Cannot convert result to a string.

Debug output is:
105151 [ConsoleThread] DEBUG jmxsh.ShellMode  - jmx_get -m 
Catalina:type=ThreadPool,name="ajp-bio-8009" currentThreadsBusy
105165 [main] DEBUG jmxsh.Jmx  - Getting attribute for server - 
service:jmx:rmi:///jndi/rmi://localhost:1234/jmxrmi, mbean - Catal
ina:type=ThreadPool,name="ajp-bio-8009, attribute - currentThreadsBusy
105167 [main] ERROR jmxsh.Jmx  - Error while getting attribute.
java.lang.IllegalArgumentException: Invalid object name 
'Catalina:type=ThreadPool,name="ajp-bio-8009' - Unterminated quoted value
        at jmxsh.Jmx.getObjectName(Jmx.java:198)
        at jmxsh.Jmx.getAttribute(Jmx.java:265)
        at jmxsh.GetCmd.cmdProc(GetCmd.java:164)
        at tcl.lang.Parser.evalObjv(Parser.java:826)
        at tcl.lang.Parser.eval2(Parser.java:1228)
        at tcl.lang.Interp.eval(Interp.java:2679)
        at tcl.lang.Interp.eval(Interp.java:2747)
        at tcl.lang.Interp.recordAndEval(Interp.java:2900)
        at jmxsh.ShellMode$1.processEvent(ShellMode.java:79)
        at tcl.lang.Notifier.serviceEvent(Notifier.java:457)
        at tcl.lang.Notifier.doOneEvent(Notifier.java:610)
        at tcl.lang.Notifier.processTclEvents(Notifier.java:786)
        at jmxsh.JInterp.processTclEvents(JInterp.java:116)
        at jmxsh.Main.run(Main.java:358)
        at jmxsh.Main.main(Main.java:262)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.simontuffs.onejar.Boot.run(Boot.java:306)
        at com.simontuffs.onejar.Boot.main(Boot.java:159)

What version of the product are you using? On what operating system?
jmxsh-R5.jar
SPARC Solaris 10
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)

This will work around the problem (two terminating quotes):
% jmx_get -m Catalina:type=ThreadPool,name="ajp-bio-8009"" currentThreadsBusy
4

...or this (change the order of the key/value pairs):
% jmx_get -m Catalina:name="ajp-bio-8009",type=ThreadPool currentThreadsBusy
4

Browse Mode works just fine for these mbeans.

Original issue reported on code.google.com by gscha...@gmail.com on 14 Sep 2011 at 2:24

GoogleCodeExporter commented 8 years ago
i have the same problem, but my mbean does not come with 'type' , and even I 
start jmxsh with '-d', I dont see any debug log print. 
Any idea? 
I am testing in SPARC solaris 10, jre 1.6.0.24 

regards

Original comment by kwa...@gmail.com on 1 Dec 2011 at 7:35

GoogleCodeExporter commented 8 years ago
forgot to mentioned, mbean name with space in between, eg. "Par Eden Space"

Original comment by kwa...@gmail.com on 1 Dec 2011 at 7:55

GoogleCodeExporter commented 8 years ago
found the solution, should quoted the mbean as a whole string then following by 
attrob , like:
 jmx_get -m "java.lang:type=MemoryPool,name=Par Eden Space" Name

Original comment by kwa...@gmail.com on 1 Dec 2011 at 9:13

GoogleCodeExporter commented 8 years ago
> and even I start jmxsh with '-d', I dont see any debug log print. 
> Any idea? 
You also need to specify a logfile (-l <LOGFILE>).

BTW: your problem is different from mine, because in my case the quotes (") are 
part of the actual mbean name (e.g. 
Catalina:type=ThreadPool,name="ajp-bio-8009").

Original comment by gscha...@gmail.com on 2 Dec 2011 at 9:30

GoogleCodeExporter commented 8 years ago
This seems to be a regression in jolokia.war
I have the same error as you when I use 1.0.1 going back to 0.95 its fine
About to check if there is anything on the jolokia site about it.

Original comment by thepeelo...@gmail.com on 5 Dec 2011 at 10:03

GoogleCodeExporter commented 8 years ago
Fixed it for me by upgrading jmx4perl to 1.04, that works with the 1.0.1 war 
agent

Original comment by thepeelo...@gmail.com on 5 Dec 2011 at 10:36

GoogleCodeExporter commented 8 years ago
Same problem with tomcat7 for me.

Version: jmxsh-R5

Not using jmx4perl

% jmx_get -n -m Catalina:type=ThreadPool,name="ajp-apr-8009" connectionCount
Error: Cannot convert result to a string.
Cannot convert result to a string.
% 

Was any solution found in the meantime?
Do you need any other detail?

Original comment by robe...@resecco.com on 27 Nov 2013 at 1:56

GoogleCodeExporter commented 8 years ago
Hello,

Same issue here - attempting to monitor the AEM 5.6.1 replication queue with 
jmxsh.
I am able to browse and get the correct values using the browse mode but not 
when using jmx_get.
The mbean name is com.adobe.granite.replication:type=agent,id="flush".

I've tried various methods of escaping the quotes but haven't managed to find 
anything that works so far..

Original comment by soli...@gmail.com on 3 Dec 2013 at 10:59

GoogleCodeExporter commented 8 years ago
Oh wait - I found a workaround. Double your last quote - in my case I changed 
the string to contain a double quote at the end: 
com.adobe.granite.replication:type=agent,id="flush""

Bit of a hack but I can confirm it works :)

Original comment by soli...@gmail.com on 3 Dec 2013 at 11:51

GoogleCodeExporter commented 8 years ago
not working 4 me... :(

% jmx_get -n -m Catalina:type=ThreadPool,name="ajp-apr-8009"" connectionCount
java0x3
% jmx_get -n -m Catalina:type=ThreadPool,name="ajp-apr-8009"" connectionCount
java0x4
% jmx_get -n -m Catalina:type=ThreadPool,name="ajp-apr-8009"" connectionCount
java0x5
% jmx_get -n -m Catalina:type=ThreadPool,name="ajp-apr-8009"" currentThreadCount
java0x6
% 

Not even moving the second quote elsewhere

% jmx_get -n -m Catalina:type=ThreadPool,name="ajp-apr-8009"" 
currentThreadCount"
Error: Cannot convert result to a string.
Cannot convert result to a string.
% jmx_get -n -m Catalina:type=ThreadPool,name="ajp-apr-8009" 
currentThreadCount" 
Error: Cannot convert result to a string.
Cannot convert result to a string.
% 

Original comment by robe...@resecco.com on 6 Dec 2013 at 9:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
% jmx_get -m 
\"kafka.controller\":type=\"KafkaController\",name=\"ActiveControllerCount\" 
Value
Error: Cannot convert result to a string.
Cannot convert result to a string.

You're in a tcl shell, so this works:

% set MBEAN 
\"kafka.controller\":type=\"KafkaController\",name=\"ActiveControllerCount\"
"kafka.controller":type="KafkaController",name="ActiveControllerCount"
% jmx_get Value
0

Original comment by wsanders...@technoratimedia.com on 26 Jun 2015 at 11:27