Tomcat 使用 CDI:相同的项目和不同的部署结果

Tomcat with CDI: same project and different results at deploy

我在使用 JSF (CDI/Weld) Tomcat 启动期间遇到了一些问题。最大的问题是,在工作中,同一个项目启动,但在家里却没有初始化。

今天我复制了工作的功能日志(Linux 和 Java 8)与我在家的日志(Windows 和 Java 8)进行比较,它是:console log at home and at work请注意 "Home Log" 中的第 210 行,Tomcat 在 /docs 文件夹中部署了一些应用程序,但是在 "Work Log" 中他放入了 /host-manager。

我正在使用 Maven 和 Git 来促进档案的重用,所以,基本上,它在我的工作站上是同一个项目(两个项目都是最后提交的)。

这是我的 web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
version="2.5">
  <display-name>sgcp</display-name>
  <welcome-file-list>
    <welcome-file>login.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

context.xml

<Context>
    <Manager pathname="" />
    <Resource name="BeanManager" 
        auth="Container"
        type="javax.enterprise.inject.spi.BeanManager"
        factory="org.jboss.weld.resources.ManagerObjectFactory" />
</Context>

和文件夹结构

只是总结评论中的讨论:原来问题是由非常不稳定的 Weld 版本引起的。

顺便说一句:我个人不建议使用不稳定的 Weld 版本。因为稳定版的bug已经够多了