Tomcat - 不会加载我的META-INF \services\javax.servlet.ServletContainerInitializer文件? [英] Tomcat - won't load my META-INF\services\javax.servlet.ServletContainerInitializer file?

查看:1263
本文介绍了Tomcat - 不会加载我的META-INF \services\javax.servlet.ServletContainerInitializer文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web项目,它有一个 \META-INF\services\javax.servlet.ServletContainerInitializer 文件,其内容指向完全限定名称一个实现ServletContainerInitializer接口的类。我基本上按照这里给出的例子: http://nullhaus.com/2011/03/using -servlets-3-0-servletcontainerinitializer /



我将调试行放在我的类中,实现了ServletContainerInitializer接口,并且它不会在那里。甚至没有默认构造函数...



我的应用程序文件夹结构如下:

 code> \MyApp 
\META-INF\services\javax.servlet.ServletContainerInitializer
\WEB-INF \classes \
... [list的课程和包裹去这里]

任何想法我需要检查??

注意1:我的Tomcat从包含我的应用程序的爆炸式外部文件夹发布



注意2:我从Eclipse启动了我的Tomcat - 如果这样做有所作为!

解决方案

嗯,我想你需要包装你的初始化器类相关的META-INF目录)转换为单独的* .jar,并将其放在 WEB-INF / lib 中。



这是一个JAR服务,所以我想这可能与* .war文件中发现服务的问题有关。此外,如果将META-INF目录放在 WEB-INF / classes 中并设置,那么不会您的Tomcat的 server.xml 中的unpackWAR = false



HTH。


I have a web project that has a \META-INF\services\javax.servlet.ServletContainerInitializer file with its content pointing to the fully qualified name of a class that implements the ServletContainerInitializer interface. I basically followed the example given here: http://nullhaus.com/2011/03/using-servlets-3-0-servletcontainerinitializer/

I put debug lines in my class that implements the ServletContainerInitializer interface and it never makes it there. Not even the default constructor...

My application folder structure is as follows:

\MyApp
      \META-INF\services\javax.servlet.ServletContainerInitializer
      \WEB-INF\classes\
                 ... [list of classes and packages go here]

Any ideas what I need to check for??

Note 1: My Tomcat publishes from an exploded external folder that contains my application

Note 2: I started my Tomcat from Eclipse - if that makes a difference!

解决方案

Well, I think that you'll need to wrap your initializer class (and it's services-related META-INF directory) into a separate *.jar and put it in the WEB-INF/lib.

This is a JAR service, so I guess it could have something to do with problems with discovering services in a *.war file. Moreover, it doesn't even help if you put your META-INF directory inside WEB-INF/classes and set unpackWAR=false in your Tomcat's server.xml.

HTH.

这篇关于Tomcat - 不会加载我的META-INF \services\javax.servlet.ServletContainerInitializer文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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