Web应用程序WAR文件中包含的自定义Tomcat Valve [英] Custom Tomcat Valve contained in web app WAR file

查看:343
本文介绍了Web应用程序WAR文件中包含的自定义Tomcat Valve的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻求实现自定义Valve并使用META-INF / context.xml对其进行配置。

I'm looking to implement a custom Valve and configuring it using META-INF/context.xml.

目前,当context.xml被解析时在部署期间,Tomcat(6.0.32)在我的自定义Valve实现中死于ClassNotFoundException。

At the moment though, when context.xml is parsed during deployment, Tomcat (6.0.32) dies with a ClassNotFoundException on my custom Valve implementation.

问题,我不是100%肯定我理解。

I'm under the impression that I'm running into a class loading context issue and I'm not 100% sure I understand it.

找不到我的班级,因为它位于WEB-INF / classes文件和上下文级别的班级中装入程序由于层次结构而无法找到该类?

Is my class not found because it is located in the WEB-INF/classes file and the Context level class loader is unable to locate the class because of the hierarchy?

预先感谢。

推荐答案

您不能从webapp类加载器内加载阀门。如果您查看 http://tomcat.apache.org/tomcat -6.0-doc / class-loader-howto.html 显示可用的类加载器。您必须使用Bootstrap,System或Common类加载器之一,因为 Valve 定义是在创建各个webapp类加载器之前进行处理的:必须先处理上下文,然后才能使用webapp。

You can not load Valves from inside the webapp class loader. If you look at http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html it shows the available class loaders. You must use one of the Bootstrap, System or Common classloaders because Valve definitions are processed BEFORE the individual webapp classloaders are created: the Context has to be processed before the webapp is available.

将Valve单独包装在罐子中,然后将其复制到 $ CATALINA_HOME / lib 文件夹中,全部设置。

Package your Valve in a jar by itself and copy it into the $CATALINA_HOME/lib folder and you should be all set.

这篇关于Web应用程序WAR文件中包含的自定义Tomcat Valve的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆