You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "G. Wade Johnson" <wa...@abbnm.com> on 2003/03/27 21:50:53 UTC

MBeanException on init new Realm class

I am working on a Tomcat-based server (4.1.18). I've checked the
list archive without a match.

The particular application required an authentication model that was
close-to but not quite the same as JDBCRealm.

I wrote a new class that extends JDBCRealm to add the needed behavior.
When I restart the Tomcat server, I get the following exception:

ServerLifecycleListener: createMBeans: MBeanException
java.lang.Exception: ManagedBean is not found with CryptJDBCRealm
        at
org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:614)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:574)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:783)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:751)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:339)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLifecycleListener.java:206)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
        at
org.apache.catalina.core.StandardServer.start(StandardServer.java:2182)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
        at
org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
        at
org.apache.catalina.startup.Catalina.process(Catalina.java:180)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)

The code is called. It does function. My class basically overrides the
method 

    public synchronized Principal authenticate(Connection dbConnection,
                                               String username,
                                               String credentials);

There are no other methods in the class.

Any thoughts,
G. Wade

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: MBeanException on init new Realm class - FIXED

Posted by "G. Wade Johnson" <wa...@abbnm.com>.
I found the solution to my final problem on this.

For the CryptJDBCRealm class, the mbean-descriptor is exactly the same
as the one for JDBCRealm except for two attributes: name and type.

  <mbean         name="CryptJDBCRealm"
	    className="org.apache.catalina.mbeans.ClassNameMBean"
          description="Extension of "
               domain="Catalina"
                group="Realm"
                 type="com.abbnm.realm.CryptJDBCRealm">
    ...

Don't change the 'className' attribute like I did. You'll get the
ClassCastException I reported below.

BTW, it is important not to change configuration files you don't
understand when you are low on caffeine.<shrug/>

Thanks for everyone's help.

G. Wade


"G. Wade Johnson" wrote:
> 
> Thanks for the response. (Apparently, all of the list archives are
> _not_ created equal.<shrug/>)
> 
> I've attempted this change and ended up with another problem.
> 
> Now I exception with:
> 
> ServerLifecycleListener: createMBeans: MBeanException
> java.lang.ClassCastException
>         at
> org.apache.commons.modeler.ManagedBean.createMBean(ManagedBean.java:386)
>         at
> org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:620)
>         at
> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:574)
>         at
> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:783)
>         at
> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:751)
> 
> Checking the code in
> org.apache.commons.modeler.ManagedBean.createMBean() shows the
> exception is occurring in this code:
> 
>         Class clazz = null;
>         try {
>             clazz = Class.forName(getClassName());
>         } catch (Exception e) {
>             throw new MBeanException
>                 (e, "Cannot load ModelMBean class " + getClassName());
>         }
> 
>         // Create a new ModelMBean instance
>         ModelMBean mbean = null;
>         try {
> // ---- exception occurs here vvvvv -------------------
>             mbean = (ModelMBean) clazz.newInstance();
>             mbean.setModelMBeanInfo(createMBeanInfo());
>         } catch (MBeanException e) {
> 
> As near as I can tell, this method has not even accessed my object
> yet. Obviously, I'm baffled. Any clues that can help me track this
> further?
> 
> Thanks again,
> G. Wade
> 
> Bill Barker wrote:
> >
> > It's sparsely documented (and AFAIK only at all for > 4.1.18), but it comes
> > up on this list like clockwork ;-).  You need to do a better search on the
> > archives.
> >
> > You need to create an mbeans-descriptors.xml file (in your case, just copy
> > the JDBCRealm stuff and change the name), usually in the same package as
> > your Realm, and package it in the same jar file as your Realm.  Then set the
> > 'descriptors' attribute on the ServerLifeCycleListener to point to your
> > mbeans-descriptors.xml.  e.g. :
> > <Listener className="org.apache.catalina.mbeans.ServerLifeCycleListener"
> >        descriptors="/com/myfirm/mypackage/realm/mbeams-descriptors.xml" />
> >
> > "G. Wade Johnson" <wa...@abbnm.com> wrote in message
> > news:3E83642D.4BE3FB7F@abbnm.com...
> > > I am working on a Tomcat-based server (4.1.18). I've checked the
> > > list archive without a match.
> > >
> > > The particular application required an authentication model that was
> > > close-to but not quite the same as JDBCRealm.
> > >
> > > I wrote a new class that extends JDBCRealm to add the needed behavior.
> > > When I restart the Tomcat server, I get the following exception:
> > >
> > > ServerLifecycleListener: createMBeans: MBeanException
> > > java.lang.Exception: ManagedBean is not found with CryptJDBCRealm
> > >         at
> > > org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:614)
> > >         at
> > >
> > org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> > cleListener.java:574)
> > >         at
> > >
> > org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> > cleListener.java:783)
> > >         at
> > >
> > org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> > cleListener.java:751)
> > >         at
> > >
> > org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> > cleListener.java:339)
> > >         at
> > >
> > org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLife
> > cycleListener.java:206)
> > >         at
> > >
> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor
> > t.java:166)
> > >         at
> > > org.apache.catalina.core.StandardServer.start(StandardServer.java:2182)
> > >         at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
> > >         at
> > > org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
> > >         at
> > > org.apache.catalina.startup.Catalina.process(Catalina.java:180)
> > >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >         at
> > >
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> > )
> > >         at
> > >
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> > .java:25)
> > >         at java.lang.reflect.Method.invoke(Method.java:324)
> > >         at
> > > org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
> > >
> > > The code is called. It does function. My class basically overrides the
> > > method
> > >
> > >     public synchronized Principal authenticate(Connection dbConnection,
> > >                                                String username,
> > >                                                String credentials);
> > >
> > > There are no other methods in the class.
> > >
> > > Any thoughts,
> > > G. Wade
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: MBeanException on init new Realm class

Posted by "G. Wade Johnson" <wa...@abbnm.com>.
Thanks for the response. (Apparently, all of the list archives are
_not_ created equal.<shrug/>)

I've attempted this change and ended up with another problem.

Now I exception with:

ServerLifecycleListener: createMBeans: MBeanException
java.lang.ClassCastException
        at
org.apache.commons.modeler.ManagedBean.createMBean(ManagedBean.java:386)
        at
org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:620)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:574)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:783)
        at
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:751)

Checking the code in
org.apache.commons.modeler.ManagedBean.createMBean() shows the
exception is occurring in this code:

        Class clazz = null;
        try {
            clazz = Class.forName(getClassName());
        } catch (Exception e) {
            throw new MBeanException
                (e, "Cannot load ModelMBean class " + getClassName());
        }

        // Create a new ModelMBean instance
        ModelMBean mbean = null;
        try {
// ---- exception occurs here vvvvv -------------------
            mbean = (ModelMBean) clazz.newInstance();
            mbean.setModelMBeanInfo(createMBeanInfo());
        } catch (MBeanException e) {


As near as I can tell, this method has not even accessed my object
yet. Obviously, I'm baffled. Any clues that can help me track this
further?

Thanks again,
G. Wade


Bill Barker wrote:
> 
> It's sparsely documented (and AFAIK only at all for > 4.1.18), but it comes
> up on this list like clockwork ;-).  You need to do a better search on the
> archives.
> 
> You need to create an mbeans-descriptors.xml file (in your case, just copy
> the JDBCRealm stuff and change the name), usually in the same package as
> your Realm, and package it in the same jar file as your Realm.  Then set the
> 'descriptors' attribute on the ServerLifeCycleListener to point to your
> mbeans-descriptors.xml.  e.g. :
> <Listener className="org.apache.catalina.mbeans.ServerLifeCycleListener"
>        descriptors="/com/myfirm/mypackage/realm/mbeams-descriptors.xml" />
> 
> "G. Wade Johnson" <wa...@abbnm.com> wrote in message
> news:3E83642D.4BE3FB7F@abbnm.com...
> > I am working on a Tomcat-based server (4.1.18). I've checked the
> > list archive without a match.
> >
> > The particular application required an authentication model that was
> > close-to but not quite the same as JDBCRealm.
> >
> > I wrote a new class that extends JDBCRealm to add the needed behavior.
> > When I restart the Tomcat server, I get the following exception:
> >
> > ServerLifecycleListener: createMBeans: MBeanException
> > java.lang.Exception: ManagedBean is not found with CryptJDBCRealm
> >         at
> > org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:614)
> >         at
> >
> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> cleListener.java:574)
> >         at
> >
> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> cleListener.java:783)
> >         at
> >
> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> cleListener.java:751)
> >         at
> >
> org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
> cleListener.java:339)
> >         at
> >
> org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLife
> cycleListener.java:206)
> >         at
> >
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor
> t.java:166)
> >         at
> > org.apache.catalina.core.StandardServer.start(StandardServer.java:2182)
> >         at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
> >         at
> > org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
> >         at
> > org.apache.catalina.startup.Catalina.process(Catalina.java:180)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
> >         at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:324)
> >         at
> > org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
> >
> > The code is called. It does function. My class basically overrides the
> > method
> >
> >     public synchronized Principal authenticate(Connection dbConnection,
> >                                                String username,
> >                                                String credentials);
> >
> > There are no other methods in the class.
> >
> > Any thoughts,
> > G. Wade
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: MBeanException on init new Realm class

Posted by Bill Barker <wb...@wilshire.com>.
It's sparsely documented (and AFAIK only at all for > 4.1.18), but it comes
up on this list like clockwork ;-).  You need to do a better search on the
archives.

You need to create an mbeans-descriptors.xml file (in your case, just copy
the JDBCRealm stuff and change the name), usually in the same package as
your Realm, and package it in the same jar file as your Realm.  Then set the
'descriptors' attribute on the ServerLifeCycleListener to point to your
mbeans-descriptors.xml.  e.g. :
<Listener className="org.apache.catalina.mbeans.ServerLifeCycleListener"
       descriptors="/com/myfirm/mypackage/realm/mbeams-descriptors.xml" />

"G. Wade Johnson" <wa...@abbnm.com> wrote in message
news:3E83642D.4BE3FB7F@abbnm.com...
> I am working on a Tomcat-based server (4.1.18). I've checked the
> list archive without a match.
>
> The particular application required an authentication model that was
> close-to but not quite the same as JDBCRealm.
>
> I wrote a new class that extends JDBCRealm to add the needed behavior.
> When I restart the Tomcat server, I get the following exception:
>
> ServerLifecycleListener: createMBeans: MBeanException
> java.lang.Exception: ManagedBean is not found with CryptJDBCRealm
>         at
> org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:614)
>         at
>
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
cleListener.java:574)
>         at
>
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
cleListener.java:783)
>         at
>
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
cleListener.java:751)
>         at
>
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
cleListener.java:339)
>         at
>
org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLife
cycleListener.java:206)
>         at
>
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor
t.java:166)
>         at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:2182)
>         at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
>         at
> org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
>         at
> org.apache.catalina.startup.Catalina.process(Catalina.java:180)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
>         at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
>
> The code is called. It does function. My class basically overrides the
> method
>
>     public synchronized Principal authenticate(Connection dbConnection,
>                                                String username,
>                                                String credentials);
>
> There are no other methods in the class.
>
> Any thoughts,
> G. Wade




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org