You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Viet Nguyen <vh...@gmail.com> on 2007/08/27 22:36:15 UTC
how to get jsr77 stats
Hi,
I have been trying to fetch the JSR 77 stats with the following snippet of
code
Stats stats = null;
try {
stats = (Stats)mejb.getAttribute(objName, "stats");
}catch (Exception ex){
System.out.println("Error finding stats- " + ex.toString());
}
And I get the exception message:
[INFO] Error finding stats- java.lang.ClassCastException:
org.apache.geronimo.management.stats.WebModuleStatsImpl
I am deploying a GBean into Geronimo, which I think is the worth mentioning
because I tried Anita's code from her work with Geronimo-1293 which uses a
very similar style of fetching the JSR 77 data. So I think the code itself
is not the problem. Because I have tried
WebModuleStatsImpl stats = null;
try {
stats = (WebModuleStatsImpl)mejb.getAttribute(objName, "stats");
}catch (Exception ex){
System.out.println("Error finding stats- " + ex.toString());
}
and I still get the same error.
Also, I even wrote this snippet to see what was up:
Object o = (Object)mejb.getAttribute(objName, "stats");
if(o instanceof WebModuleStatsImpl) {
System.out.println("webmodulestatsimpl");
} else if(o instanceof Stats) {
System.out.println("stats");
} else if(o instanceof WebModuleStats) {
System.out.println("webmodulestats");
} else{
System.out.println("none of the above");
}
By casting it to a Object, it was okay. But the output was "none of the
above." The weird thing about it is that when I executed System.out.println(
o.getClass().toString()); it tells me that the class is WebModuleStatsImpl.
I have tried a lot of variations and cannot figure this classcastexception
problem. If anyone can give me any insight, I will appreciate it.
Thanks,
Viet Nguyen
Re: how to get jsr77 stats
Posted by Viet Nguyen <vh...@gmail.com>.
On 8/27/07, Paul McMahan <pa...@gmail.com> wrote:
>
> On Aug 27, 2007, at 4:36 PM, Viet Nguyen wrote:
>
> > The weird thing about it is that when I executed System.out.println
> > (o.getClass().toString()); it tells me that the class is
> > WebModuleStatsImpl.
>
> Do you have a copy of the geronimo-management jar either in your
> application or as a dependency in your deployment plan? If so then
> you might want to inherit those classes via dependency on
> org.apache.geronimo.configs/j2ee-server//car instead. That should
> help ensure that you're not dealing with the same class in two
> different classloaders.
>
>
> Best wishes,
> Paul
Wow, thanks a lot Paul. That fixed the problem.
-Viet
Re: how to get jsr77 stats
Posted by Paul McMahan <pa...@gmail.com>.
On Aug 27, 2007, at 4:36 PM, Viet Nguyen wrote:
> The weird thing about it is that when I executed System.out.println
> (o.getClass().toString()); it tells me that the class is
> WebModuleStatsImpl.
Do you have a copy of the geronimo-management jar either in your
application or as a dependency in your deployment plan? If so then
you might want to inherit those classes via dependency on
org.apache.geronimo.configs/j2ee-server//car instead. That should
help ensure that you're not dealing with the same class in two
different classloaders.
Best wishes,
Paul