Setting JMX attributes


#1

Hi, I am using edge jruby edge (rev 9083) and I am trying to set a JMX
attribute. I can establish the connection and and read the variables no
problem. But, when I try to set them I get this exception.

Here is the code that is causing the exception:
JMX::MBean.find_by_name(“com.armorize:type=ScanEngine”).maximum_concurrent_scans=(1)(Using
the jmx4r gem for convience but even when I do not use jmx4r I get
the same exception see next command).
conn.set_attribute(ObjectName.getInstance(“com.armorize:type=ScanEngine”),
Attribute.new(“MaximumConcurrentScans”, 2))

Also I checked the MBean interface and I it is expecting an integer.

Thanks,

Josh

NativeException: javax.management.InvalidAttributeValueException:
attribute=
MaximumConcurrentScans value = 6
from com/sun/jmx/mbeanserver/StandardMetaDataImpl.java:735:in
setAttribute' from com/sun/jmx/mbeanserver/StandardMetaDataImpl.java:360:insetAttribute’
from com/sun/jmx/mbeanserver/MetaDataImpl.java:206:in setAttribute' from com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java:737:insetAttribute’
from com/sun/jmx/mbeanserver/JmxMBeanServer.java:722:in
setAttribute' from javax/management/remote/rmi/RMIConnectionImpl.java:1433:indoOperation’
from javax/management/remote/rmi/RMIConnectionImpl.java:81:in
access$100' from javax/management/remote/rmi/RMIConnectionImpl.java:1247:inrun’
from javax/management/remote/rmi/RMIConnectionImpl.java:1343:in
doPrivilegedOperation' from javax/management/remote/rmi/RMIConnectionImpl.java:681:insetAttribute’
from sun.reflect.GeneratedMethodAccessor150:-1:in invoke' from sun/reflect/DelegatingMethodAccessorImpl.java:25:ininvoke’
from java/lang/reflect/Method.java:585:in invoke' from sun/rmi/server/UnicastServerRef.java:294:indispatch’
from sun/rmi/transport/Transport.java:153:in run' from java/security/AccessController.java:-2:indoPrivileged’
… 121 levels…
from org/jruby/ast/NewlineNode.java:104:in interpret' from org/jruby/ast/BlockNode.java:71:ininterpret’
from
org/jruby/internal/runtime/methods/InterpretedMethod.java:163:in
call' from org/jruby/internal/runtime/methods/DefaultMethod.java:144:incall’
from org/jruby/runtime/callsite/CachingCallSite.java:273:in
cacheAndCall' from org/jruby/runtime/callsite/CachingCallSite.java:112:incall’
from usr/local/share/jruby_edge/bin/jirb:19:in __file__' from usr/local/share/jruby_edge/bin/jirb:-1:inload’
from org/jruby/Ruby.java:575:in runScript' from org/jruby/Ruby.java:478:inrunNormally’
from org/jruby/Ruby.java:352:in runFromMain' from org/jruby/Main.java:222:inrun’
from org/jruby/Main.java:103:in run' from org/jruby/util/ShellLauncher.java:102:inrun’
from java/lang/Thread.java:619:in `run’


#2

I hate to ask, but does it do the same from Java? I know JMX is pretty
painful to do from Java so I won’t fault you if you haven’t tried.

You might try pulling Tom Enebo’s JMX gem “gem install jmx” since it
works pretty well…then we could at least rule out whether it’s
specific to the library.

Josh M. wrote:

from com/sun/jmx/mbeanserver/StandardMetaDataImpl.java:360:in 
from javax/management/remote/rmi/RMIConnectionImpl.java:1247:in `run'

… 121 levels…
from org/jruby/Ruby.java:575:in runScript' from org/jruby/Ruby.java:478:inrunNormally’
from org/jruby/Ruby.java:352:in runFromMain' from org/jruby/Main.java:222:inrun’
from org/jruby/Main.java:103:in run' from org/jruby/util/ShellLauncher.java:102:inrun’
from java/lang/Thread.java:619:in `run’


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

I just tried Tom Enebo’s JMX gem and using Java and the Java worked but
the
gem did not. It seams like the 2 is not getting cast right when it is
passed into JMX because when I was using java if I passed in a non
integer I
got the same exception. Is there anyway to force JRuby to convert the 2
to
an integer?

Josh

On Tue, Feb 17, 2009 at 4:03 PM, Charles Oliver N. <


#4

Perhaps try java.lang.Integer.new(2) in place of a raw 2. I notice
that Attribute.new accepts an Object as a parameter. I am not sure
how we pass our RubyFixnum over in that case, but I would still hope
it was getting unwrapped long/Long/int/Integer. If that works, then
let us know. This may be a JI bug.

-Tom

On Tue, Feb 17, 2009 at 4:34 AM, Josh M. removed_email_address@domain.invalid
wrote:

attribute. I can establish the connection and and read the variables no
Also I checked the MBean interface and I it is expecting an integer.
setAttribute'doPrivilegedOperation’
from org/jruby/ast/BlockNode.java:71:in interpret' from org/jruby/Ruby.java:478:inrunNormally’

http://xircles.codehaus.org/manage_email


Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: removed_email_address@domain.invalid , removed_email_address@domain.invalid


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

Thomas E Enebo wrote:

Perhaps try java.lang.Integer.new(2) in place of a raw 2. I notice
that Attribute.new accepts an Object as a parameter. I am not sure
how we pass our RubyFixnum over in that case, but I would still hope
it was getting unwrapped long/Long/int/Integer. If that works, then
let us know. This may be a JI bug.

Yeah, if it’s Object it probably gets passed as Long. If that angers
JMX, we may need to hack around it in the various JMX libraries until JI
is smarter about coercing (and even then, what do we coerce “2” to?
Byte? Short? Integer?).

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

Thanks to everybody for there help. The java.lang.Integer.new(2) did
the
trick.

Thanks,

Josh

On Wed, Feb 18, 2009 at 12:20 AM, Charles Oliver N. <