geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Viet Nguyen" <vhng...@gmail.com>
Subject how to get jsr77 stats
Date Mon, 27 Aug 2007 21:45:52 GMT
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

Mime
View raw message