You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Leigh Williamson <le...@us.ibm.com> on 2006/01/09 20:11:18 UTC
JSR77 StateManageable inconsistency?
I have been attempting to port a J2EE 1.4 management program to Geronimo and
noticed what appears to be inconsistency in the way JSR77 StateManageable
attribute is handled.
The spec says that if one of the JSR77 objects does support the StateManageable
interface it should return "true" for the stateManageable attribute of the
J2EEManagedObject interface. Returning "true" for the stateManageable attribute
is supposed to tell the management program that this object supports the
StateManageable interface which includes the "state" attribute, as well as
implementing the "stop", "start", and "startRecursive" operations.
But the J2EEManagedObjects returned by the ManagementEJB in Geronimo appear to
be inconsistent in this area. For instance, the J2EEDeployedObject claims to be
a state manageable object (stateManageable="true") but if you attempt to
getAttribute the "state" attribute you will receive an exception:
javax.management.AttributeNotFoundException: state
In a different example of inconsistency, the J2EEServer object also claims to
be StateManageable, yet I cannot invoke the "stop" operation on that object.
Perhaps I am accessing these J2EEManagedObjects incorrectly? I am using the
ManagementEJB as per the spec. Is this a bug in the implementation?
Re: JSR77 StateManageable inconsistency?
Posted by Leigh Williamson <le...@us.ibm.com>.
Yes, I will extract a small example from the program I am working on and
post it. Thanks!
Leigh Williamson
leighw@us.ibm.com
Aaron Mulder <am...@alumni.princeton.edu>
Sent by: ammulder@gmail.com
01/09/2006 02:27 PM
Please respond to
user@geronimo.apache.org
To
user@geronimo.apache.org
cc
Subject
Re: JSR77 StateManageable inconsistency?
Hmm, that's curious. Every GBean is state manageable in the sense
that if you talk to the kernel it can get and change the state of the
GBean. And if you have the kernel generate you a proxy it includes
the state manageable methods in one of the implemented interfaces,
IIRC.
However, it may well be the case that invoking such a method through
the MEJB doesn't work properly. If so, we should be able to just
change the MEJB to make the right kernel calls under the covers if you
call one of the state manageable methods.
Can you send over (post to JIRA or the mailing list) a small test
program that demonstrates the problem, which we could then use to test
the fix?
Thanks,
Aaron
On 1/9/06, Leigh Williamson <le...@us.ibm.com> wrote:
> I have been attempting to port a J2EE 1.4 management program to Geronimo
and
> noticed what appears to be inconsistency in the way JSR77
StateManageable
> attribute is handled.
>
> The spec says that if one of the JSR77 objects does support the
StateManageable
> interface it should return "true" for the stateManageable attribute of
the
> J2EEManagedObject interface. Returning "true" for the stateManageable
attribute
> is supposed to tell the management program that this object supports the
> StateManageable interface which includes the "state" attribute, as well
as
> implementing the "stop", "start", and "startRecursive" operations.
>
> But the J2EEManagedObjects returned by the ManagementEJB in Geronimo
appear to
> be inconsistent in this area. For instance, the J2EEDeployedObject
claims to be
> a state manageable object (stateManageable="true") but if you attempt to
> getAttribute the "state" attribute you will receive an exception:
> javax.management.AttributeNotFoundException: state
>
> In a different example of inconsistency, the J2EEServer object also
claims to
> be StateManageable, yet I cannot invoke the "stop" operation on that
object.
>
> Perhaps I am accessing these J2EEManagedObjects incorrectly? I am using
the
> ManagementEJB as per the spec. Is this a bug in the implementation?
>
>
Re: JSR77 StateManageable inconsistency?
Posted by Leigh Williamson <le...@us.ibm.com>.
Here is a simple example program to demonstrate the issue. It can be
directly deployed to Geronimo.
The essential ingredients are a TestBean.java class that is a client to
the JSR77 ManagementEJB, and a JSP to display the results of testBean
methods.
Here is the source for the TestState.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet"
type="text/css">
<TITLE>TestState.jsp</TITLE>
</HEAD>
<BODY>
<P><jsp:useBean id="testBean" class="test.TestBean"></jsp:useBean>
<BR>
<FONT size="+1">Testing JSR77 StateManageable interface for:</FONT><BR>
<%=testBean.getObjectName()%>
<P>
<BR>
<FONT size="+1">Is this object StateManageable?</FONT>
<BR>
<%=testBean.getStateManageable()%>
</P>
<P><BR>What is its state?<BR>
<%=testBean.getState()%>
</P>
<P><BR>Invoke the "stop" operation on this Object:
</P>
<%=testBean.doStop()%>
<P></P>
</BODY>
</HTML>
Here is the source code for the TestBean.java class that exercises the
ManagementEJB.
Note that you can switch between J2EEServer or J2EEDeployedObject JSR77
entities, but the result is still the same.
The object claims to be stateManageable but does not expose a "state"
attribute nor a "stop" operation.
/*
* Created on Jan 9, 2006
*
*/
package test;
import java.util.Set;
import javax.management.ObjectName;
import javax.management.j2ee.Management;
import javax.management.j2ee.ManagementHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
/**
* @author leighw
*
*/
public class TestBean {
protected ObjectName objName = null;
protected Management mejb = null;
//protected String OBJNAME_PATTERN =
"*:j2eeType=J2EEApplication,*";
protected String OBJNAME_PATTERN = "*:j2eeType=J2EEServer,*";
public TestBean(){
mejb = getMEJB();
objName = getThisObjectName();
}
protected ObjectName getThisObjectName() throws RuntimeException{
ObjectName objName = null;
ObjectName searchpattern = null;
// set search pattern
try {
searchpattern = new ObjectName(OBJNAME_PATTERN);
} catch (Exception e) {
e.printStackTrace();
}
// issue queryNames for ObjectName
try {
Set s = mejb.queryNames(searchpattern, null);
objName = (ObjectName) s.iterator().next();
} catch (Exception e) {
e.printStackTrace();
}
if (objName == null){
throw new RuntimeException("No ObjectName returned
for \""+searchpattern.toString()+"\"");
}
return objName;
}
protected Management getMEJB() throws RuntimeException{
Management m = null;
ManagementHome mejbHome = null;
Object obj = null;
Context ic = null;
// get initial JNDI naming context
try {
ic = new InitialContext();
} catch (Exception e) {
e.printStackTrace();
}
// lookup MEJB Home
try {
obj = ic.lookup("java:comp/env/ejb/mgmt/MEJB");
} catch (Exception e) {
e.printStackTrace();
}
if (obj==null) {
// MEJB Home was not found
return m;
}
// convert generic Object to MEJB Home
mejbHome =
(ManagementHome)PortableRemoteObject.narrow(obj, ManagementHome.class);
// create MEJB instance from Home object
try {
m = mejbHome.create();
} catch (Exception e) {
e.printStackTrace();
}
if (m == null){
throw new RuntimeException("Failed to obtain
MEJB.");
}
return m;
}
public String getObjectName(){
return objName.toString();
}
public String getStateManageable(){
String value = "undefined";
try {
Boolean bo =
(Boolean)mejb.getAttribute(objName,"stateManageable");
value = bo.toString();
}
catch (Exception e){
return new String("Exception: "+e.toString());
}
return value;
}
public String getState(){
String value = "undefined";
try {
Integer i =
(Integer)mejb.getAttribute(objName,"state");
value = i.toString();
}
catch (Exception e){
e.printStackTrace();
return new String("Exception: "+e.toString());
}
return value;
}
public String doStop(){
String value = "undefined";
try {
mejb.invoke(objName,"stop",new Object[]{},new
String[]{});
value = "Stop Invoked";
}
catch (Exception e){
e.printStackTrace();
return new String("Exception: "+e.toString());
}
return value;
}
}
Leigh Williamson
leighw@us.ibm.com
Aaron Mulder <am...@alumni.princeton.edu>
Sent by: ammulder@gmail.com
01/09/2006 02:27 PM
Please respond to
user@geronimo.apache.org
To
user@geronimo.apache.org
cc
Subject
Re: JSR77 StateManageable inconsistency?
Hmm, that's curious. Every GBean is state manageable in the sense
that if you talk to the kernel it can get and change the state of the
GBean. And if you have the kernel generate you a proxy it includes
the state manageable methods in one of the implemented interfaces,
IIRC.
However, it may well be the case that invoking such a method through
the MEJB doesn't work properly. If so, we should be able to just
change the MEJB to make the right kernel calls under the covers if you
call one of the state manageable methods.
Can you send over (post to JIRA or the mailing list) a small test
program that demonstrates the problem, which we could then use to test
the fix?
Thanks,
Aaron
On 1/9/06, Leigh Williamson <le...@us.ibm.com> wrote:
> I have been attempting to port a J2EE 1.4 management program to Geronimo
and
> noticed what appears to be inconsistency in the way JSR77
StateManageable
> attribute is handled.
>
> The spec says that if one of the JSR77 objects does support the
StateManageable
> interface it should return "true" for the stateManageable attribute of
the
> J2EEManagedObject interface. Returning "true" for the stateManageable
attribute
> is supposed to tell the management program that this object supports the
> StateManageable interface which includes the "state" attribute, as well
as
> implementing the "stop", "start", and "startRecursive" operations.
>
> But the J2EEManagedObjects returned by the ManagementEJB in Geronimo
appear to
> be inconsistent in this area. For instance, the J2EEDeployedObject
claims to be
> a state manageable object (stateManageable="true") but if you attempt to
> getAttribute the "state" attribute you will receive an exception:
> javax.management.AttributeNotFoundException: state
>
> In a different example of inconsistency, the J2EEServer object also
claims to
> be StateManageable, yet I cannot invoke the "stop" operation on that
object.
>
> Perhaps I am accessing these J2EEManagedObjects incorrectly? I am using
the
> ManagementEJB as per the spec. Is this a bug in the implementation?
>
>
Re: JSR77 StateManageable inconsistency?
Posted by Aaron Mulder <am...@alumni.princeton.edu>.
Hmm, that's curious. Every GBean is state manageable in the sense
that if you talk to the kernel it can get and change the state of the
GBean. And if you have the kernel generate you a proxy it includes
the state manageable methods in one of the implemented interfaces,
IIRC.
However, it may well be the case that invoking such a method through
the MEJB doesn't work properly. If so, we should be able to just
change the MEJB to make the right kernel calls under the covers if you
call one of the state manageable methods.
Can you send over (post to JIRA or the mailing list) a small test
program that demonstrates the problem, which we could then use to test
the fix?
Thanks,
Aaron
On 1/9/06, Leigh Williamson <le...@us.ibm.com> wrote:
> I have been attempting to port a J2EE 1.4 management program to Geronimo and
> noticed what appears to be inconsistency in the way JSR77 StateManageable
> attribute is handled.
>
> The spec says that if one of the JSR77 objects does support the StateManageable
> interface it should return "true" for the stateManageable attribute of the
> J2EEManagedObject interface. Returning "true" for the stateManageable attribute
> is supposed to tell the management program that this object supports the
> StateManageable interface which includes the "state" attribute, as well as
> implementing the "stop", "start", and "startRecursive" operations.
>
> But the J2EEManagedObjects returned by the ManagementEJB in Geronimo appear to
> be inconsistent in this area. For instance, the J2EEDeployedObject claims to be
> a state manageable object (stateManageable="true") but if you attempt to
> getAttribute the "state" attribute you will receive an exception:
> javax.management.AttributeNotFoundException: state
>
> In a different example of inconsistency, the J2EEServer object also claims to
> be StateManageable, yet I cannot invoke the "stop" operation on that object.
>
> Perhaps I am accessing these J2EEManagedObjects incorrectly? I am using the
> ManagementEJB as per the spec. Is this a bug in the implementation?
>
>