Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么对WEB-INF/WEB.xml的更改不会导致tomcat重新加载上下文?_Java_Eclipse_Tomcat_Web.xml_Eclipse Wtp - Fatal编程技术网

Java 为什么对WEB-INF/WEB.xml的更改不会导致tomcat重新加载上下文?

Java 为什么对WEB-INF/WEB.xml的更改不会导致tomcat重新加载上下文?,java,eclipse,tomcat,web.xml,eclipse-wtp,Java,Eclipse,Tomcat,Web.xml,Eclipse Wtp,我已经使用Eclipse WTP Tomcat创建了一个名为“test”的动态Web项目,Eclipse版本是Java EE Kepler Service Release 2,Tomcat版本是7.0.53,Servlet 3.0,Win 8.1 x86,jdk 1.6.045,但是经过几次尝试,我发现在匹配以下所有条件时出现了问题: Webapp(web上下文)不在/webapps(appBase的默认值)中,并且: 通过在元素下的\conf\server.xml中写入元素来配置Webapp

我已经使用Eclipse WTP Tomcat创建了一个名为“test”的动态Web项目,Eclipse版本是Java EE Kepler Service Release 2,Tomcat版本是7.0.53,Servlet 3.0,Win 8.1 x86,jdk 1.6.045,但是经过几次尝试,我发现在匹配以下所有条件时出现了问题:

  • Webapp(web上下文)不在/webapps(appBase的默认值)中,并且:
  • 通过在元素下的\conf\server.xml中写入元素来配置Webapp
  • 以下是\conf\server.xml的一部分:

       <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
    
        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->
    
        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
        <Context docBase="D:/tmpdev/apache-tomcat-7.0.53/wtpwebapps/test" path="/test" reloadable="true"/>
      </Host>
    
    虽然默认情况下WEB-INF/WEB.xml位于\conf\context.xml中,但我尝试以以下每种格式添加一个元素,但仍然不起作用:

    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>WEB-INF\web.xml</WatchedResource>
    <WatchedResource>D:/tmpdev/apache-tomcat-7.0.53/wtpwebapps/test/WEB-INF/web.xml</WatchedResource>
    <WatchedResource>D:\tmpdev\apache-tomcat-7.0.53\wtpwebapps\test\WEB-INF\web.xml</WatchedResource>
    
    WEB-INF/WEB.xml
    WEB-INF\WEB.xml
    D:/tmpdev/apache-tomcat-7.0.53/wtpwebapps/test/WEB-INF/WEB.xml
    D:\tmpdev\apache-tomcat-7.0.53\wtpwebapps\test\WEB-INF\WEB.xml
    
    以下是其他有效的配置方式:

  • 使用单独的文件\conf\Catalina\localhost\test.xml配置上下文,或者:
  • 将“测试”移动到\webapps而不进行任何配置,或者:
  • 选中EclipseWTP中服务器选项的“不发布服务模块”

  • 仅适用于自动部署功能,该功能在从server.xml部署上下文时不使用。

    只有在我更新了server.xml文件后,重新加载才能工作

    通过设置autoDeploy=true

    <br>
    The output from the logs then showed a "Reloading context" 
    
    08-May-2018 20:58:56.654 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.reload <b>Reloading context </b>[/prototype_maven]
    08-May-2018 20:58:56.654 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/prototype_maven] has started
    08-May-2018 20:58:58.619 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    08-May-2018 20:58:58.629 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/prototype_maven] is completed
    

    然后,日志的输出显示“重新加载上下文” 2018年5月8日20:58:56.654信息[ContainerBackgroundProcessor[StandardEngine[Catalina]]org.apache.Catalina.startup.HostConfig.Reloading重载上下文[/prototype\u maven] 2018年5月8日20:58:56.654信息[ContainerBackgroundProcessor[StandardEngine[Catalina]]org.apache.Catalina.core.StandardContext.reload已开始重新加载名为[/prototype_maven]的上下文 2018年5月8日20:58:58.619信息[ContainerBackgroundProcessor[StandardEngine[Catalina]]]org.apache.jasper.servlet.TldScanner.scanJars至少扫描了一个JAR以查找TLD,但未包含TLD。为此记录器启用调试日志记录以获取已扫描的JAR的完整列表,但未找到TLD。在扫描过程中跳过不需要的JAR可以缩短启动时间和JSP编译时间。 2018年5月8日20:58:58.629信息[ContainerBackgroundProcessor[StandardEngine[Catalina]]org.apache.Catalina.core.StandardContext.reload重新加载名为[/prototype_maven]的上下文已完成
    你到底在哪里添加了这些元素?@MarkThomas,我在conf/server.xml的element下一个接一个地尝试了这些元素,但没有人成功!每次更改server.xml后,您都重新启动了Tomcat?@MarkThomas,是的,我确实重新启动了。我知道如果不重新启动Tomcat,就无法重新加载主conf/server.xml文件。我将检查这个问题是否在Linux下发生。@MarkThomas,我在Ubuntu下用相同的Tomcat版本进行了测试,它的行为与Windows下的相同。我还使用Tomcat 7.0.8再次进行了测试,但也不起作用。好像是个虫子?
    <br>
    The output from the logs then showed a "Reloading context" 
    
    08-May-2018 20:58:56.654 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.reload <b>Reloading context </b>[/prototype_maven]
    08-May-2018 20:58:56.654 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/prototype_maven] has started
    08-May-2018 20:58:58.619 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    08-May-2018 20:58:58.629 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/prototype_maven] is completed