Eclipse + Tomcat + maven +过滤web.xml url-pattern,namingException

时间:2015-02-03 22:04:17

标签: java eclipse maven tomcat7 m2e-wtp

我正在使用Maven过滤(除其他外)我的web.xml,如下所示:

在web.xml中:

> <filter-mapping>
>     <filter-name>CAS Authentication Filter</filter-name>
>     <url-pattern>
>         ${cas.filter.pattern}
>     </url-pattern>   </filter-mapping>

在pom.xml中:

<profile>
    <id>test</id>
    <properties>
        <cas.filter.pattern>/blank/*</cas.filter.pattern>
    </properties>
</profile>

...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <configuration>
                              <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
        </configuration>
                <webResources>
                    <resource>
                        <filtering>true</filtering>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/META-INF/context.xml</include>
                        </includes>
                    </resource>
                    <resource>
                        <filtering>true</filtering>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>web.xml</include>
                        </includes>
                    </resource>
                </webResources>
                <webXml>src/main/resources/web.xml</webXml>
            </configuration>
        </plugin>

当我使用命令行构建并部署到独立的Tomcat版本7.0.0.28时,它会部署正常并且可以正常工作。

但是,当我在Eclipse中部署时,我得到一个NamingException:

WARNING: Failed to retrieve JNDI naming context for container



[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/XXXX]] so no cleanup was performed for that container
javax.naming.NamingException: No naming context bound to this class loader
    at org.apache.naming.ContextBindings.getClassLoader(ContextBindings.java:352)
    at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:987)
    at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:970)

我不确定如何解决这个问题。我真的需要能够在构建/部署某些配置文件(即开发)时绕过某些过滤器 - 并在构建/部署其他环境时打开它们。我已经在许多其他已成功运行的文件中过滤了属性。

作为测试,我硬编码 url-pattern是在过滤器属性列表中定义的,并且在Eclipse / Tomcat中工作正常。但是,如果我将其保留为属性名称(如上所示),则会失败。

有什么想法吗?

0 个答案:

没有答案