Fwd: MBeanOperationInfo array return types

Kirk Lund <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <[email protected]>
Just found part of the answer in the jmx spec under MBeanOperationInfo Class...

To para-phrase, getReturnType must return a string that's identical to the 
string returned by the getName method of java.lang.Class.  So 
Commons-Modeler has the bug, and MX4J is solid.

[Ljava.lang.Object; looks a little odd in the HttpAdaptor though...

Thanks,
Kirk

>Date: Tue, 17 Aug 2004 11:18:08 -0700
>To: [email protected]
>From: Kirk Lund <[email protected]>
>Subject: MBeanOperationInfo array return types
>
>We are using Jakarta Commons-Modeler in combination with MX4J.  By default 
>Commons-Modeler uses it's own impl of ModelMBean, but we are using the 
>MX4J impl of RequiredModelMBean.  This has highlighted a couple bugs in 
>Commons-Modeler.  However, one of the bugs could feasibly be considered an 
>MX4J bug.
>
>If Modeler configures a ModelMBean to have an operation which returns an 
>array of javax.management.ObjectName[] (or any object array...), it 
>produces the following situation...
>
>1) Modeler takes the String "javax.management.ObjectName[]" and simply 
>sets the MBeanOperationInfo return type to that string instead of 
>"[Ljavax.management.ObjectName;"
>
>2) MX4J's RequiredModelMBean enters method "invoke" and hits the following 
>line with "javax.management.ObjectName[]"...
>     Class declared = 
> loadClassWithContextClassLoader(operInfo.getReturnType());
>...loadClassWithContextClassLoader returns null.  RequiredModelMBean then 
>calls method "checkAssignability" which throws a NullPointerException 
>because variable "declared" is always assumed to never be null throughout.
>
>So, my main question is... should MX4J be altered to cope with 
>non-reflective array strings (ie, "java.lang.Object[]")?
>
>It would be inappropriate to set the Modeler descriptor xml file to have 
>"[Ljavax.management.ObjectName;" as the return type.  Why?  Because the 
>descriptor xml file should remain human readable and "Object[]" format is 
>appropriate in the xml.  One alternative to altering MX4J is to alter 
>Modeler to convert the string to the "[L..." format after reading in the 
>xml.  However, it's not clear from reading the JMX spec or the JavaDocs on 
>MBeanOperationInfo that the return type shouldn't display the "Object[]" 
>format as a return from MBeanOperationInfo.getReturnType().
>
>Another alternative would be to change ModelMBeanOperationInfo or 
>MBeanOperationInfo to convert the type string from "Object[]" to the 
>reflective "[L...".
>
>I would be happy to tackle a solution in either direction and provide the 
>necessary patch.  At the very least I believe RequiredModelMBean should be 
>altered to check for null "declared" instead of blowing up with a 
>NullPointerException.
>
>You're all more familiar w/ the spec and MX4J than I...  What you 
>think?  Which solution is more appropriate in your opinions?
>
>Thanks,
>Kirk
>
>PS: In addition to the NPE, I also get the expected ClassNotFoundException...
>java.lang.ClassNotFoundException: javax.management.ObjectName[]
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
>         at mx4j.util.Utils.loadClass(Utils.java:99)
>         at 
> javax.management.modelmbean.RequiredModelMBean.loadClassWithContextClassLoader(RequiredModelMBean.java:1194)
>         at 
> javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:669)
>         at 
> mx4j.server.interceptor.InvokerMBeanServerInterceptor.invoke(InvokerMBeanServerInterceptor.java:218)
>         at 
> mx4j.server.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:121)
>         at 
> mx4j.server.interceptor.SecurityMBeanServerInterceptor.invoke(SecurityMBeanServerInterceptor.java:86)
>         at 
> mx4j.server.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:121)
>         at 
> mx4j.server.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:121)
>         at 
> mx4j.server.interceptor.ContextClassLoaderMBeanServerInterceptor.invoke(ContextClassLoaderMBeanServerInterceptor.java:205)
>         at mx4j.server.MX4JMBeanServer.invoke(MX4JMBeanServer.java:1079)
>         at 
> mx4j.tools.adaptor.http.InvokeOperationCommandProcessor.executeRequest(InvokeOperationCommandProcessor.java:164)
>         at 
> mx4j.tools.adaptor.http.HttpAdaptor$HttpClient.run(HttpAdaptor.java:980)




-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.