You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jon Eaves <jo...@eaves.org> on 2002/12/08 04:31:59 UTC

Custom Valve

Hi all,

I've implemented a custom Valve which wasn't a major effort,
but would like to try and resolve some strange effects that
are part of the "standard" installation of Tomcat.

I'm using TC 4.1.12, JDK 1.3.1 (just for the record).

When using the custom Valve, (which also has a custom path,
not an org.apache.* path) I get the following exception on
start of Tomcat.

-------
ServerLifecycleListener: createMBeans: MBeanException
java.lang.Exception: ManagedBean is not found with MyCustomValve
         at 
org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:783)
         at 
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:583)

[ rest snipped ]
-----

Now, I presume this is because my server.xml is including the
mbeans.ServerLifecycleListener as part of the configuration.

The code for various valves, and the ValveBase class recommends
implementing the Lifecycle interface, so clearly it should support
that.

However, there doesn't seem to be able to be a way to include an
additional mbeans-descriptors.xml file so that the MBeanUtils doesn't
barf.  The Registry class seems to be loaded with a hard-wired
path for the XML.

Additionally, I'd like to be able to manage MyCustomValve from within
the GUI Administration application, so this support would be very,
very nice.

So, my questions are:

1.  Can I prevent the exception, and if so how ?
2.  Can I implement "something" to allow the Valve to be configured
     using the GUI, and if so what ?
3.  Is this just an error with TC 4.1.12 and is fixed in 4.1.16 ??

Thanks to anybody who can shed some light on these questions...

Cheers all,
	-- jon

-- 
Jon Eaves <jo...@eaves.org>
http://www.eaves.org/jon/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Custom Valve

Posted by Jon Eaves <jo...@eaves.org>.
Bill,

Two words: You legend !

>>1.  Can I prevent the exception, and if so how ?
> 
> You can create your own mbeans-descriptor file, package it in the jar with
> your Valve, and set the
> descriptors="/com/myfirm/mypackage/mbeans-descriptor.xml" attribute on the
> ServerLifecycleListener element in server.xml.

Thanks, I didn't think to look for additional attributes here.

>>2.  Can I implement "something" to allow the Valve to be configured
>>     using the GUI, and if so what ?
>>3.  Is this just an error with TC 4.1.12 and is fixed in 4.1.16 ??
>>
> In 4.1.12, your Valve has to extend o.a.c.valves.ValveBase to work with the
> admin app.  In 4.1.16 this has been relaxed to only requiring that it
> implements o.a.c.Contained.

I saw this in the CVS log entries and realised that I was on the
right track, but didn't quite know exactly what to do with that
information.

Cheers,
	-- jon

-- 
Jon Eaves <jo...@eaves.org>
http://www.eaves.org/jon/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Custom Valve

Posted by Bill Barker <wb...@wilshire.com>.
"Jon Eaves" <jo...@eaves.org> wrote in message
news:3DF2BD2F.40009@eaves.org...
> Hi all,
>
> I've implemented a custom Valve which wasn't a major effort,
> but would like to try and resolve some strange effects that
> are part of the "standard" installation of Tomcat.
>
> I'm using TC 4.1.12, JDK 1.3.1 (just for the record).
>
> When using the custom Valve, (which also has a custom path,
> not an org.apache.* path) I get the following exception on
> start of Tomcat.
>
> -------
> ServerLifecycleListener: createMBeans: MBeanException
> java.lang.Exception: ManagedBean is not found with MyCustomValve
>          at
> org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:783)
>          at
>
org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecy
cleListener.java:583)
>
> [ rest snipped ]
> -----
>
> Now, I presume this is because my server.xml is including the
> mbeans.ServerLifecycleListener as part of the configuration.
>
> The code for various valves, and the ValveBase class recommends
> implementing the Lifecycle interface, so clearly it should support
> that.
>
> However, there doesn't seem to be able to be a way to include an
> additional mbeans-descriptors.xml file so that the MBeanUtils doesn't
> barf.  The Registry class seems to be loaded with a hard-wired
> path for the XML.
>
> Additionally, I'd like to be able to manage MyCustomValve from within
> the GUI Administration application, so this support would be very,
> very nice.
>
> So, my questions are:
>
> 1.  Can I prevent the exception, and if so how ?

You can create your own mbeans-descriptor file, package it in the jar with
your Valve, and set the
descriptors="/com/myfirm/mypackage/mbeans-descriptor.xml" attribute on the
ServerLifecycleListener element in server.xml.

> 2.  Can I implement "something" to allow the Valve to be configured
>      using the GUI, and if so what ?
> 3.  Is this just an error with TC 4.1.12 and is fixed in 4.1.16 ??
>

In 4.1.12, your Valve has to extend o.a.c.valves.ValveBase to work with the
admin app.  In 4.1.16 this has been relaxed to only requiring that it
implements o.a.c.Contained.

> Thanks to anybody who can shed some light on these questions...
>
> Cheers all,
> -- jon
>
> --
> Jon Eaves <jo...@eaves.org>
> http://www.eaves.org/jon/





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>