Tomcat 8: Starting WebApps in a given order

你说的曾经没有我的故事 提交于 2020-05-01 06:26:38

问题


Using Tomcat 8.0.15 with Java 8

I need a certain WebApp to load first so I put the following in my server.xml:

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" className="com.my.class.MyCustomHost">
    <Context docBase="app_to_load" path="/app_to_load"/>
</Host>

MyCustomHost looks like below:

public class MyCustomHost extends StandardHost {
    public MyCustomHost () {
        super();
        this.children = new LinkedHashMap();
    } }

This setup worked in Tomcat 7.0.42 (with Java 7) but in Tomcat 8.0.15 (with Java 8), I get the following error:

Apr 16, 2015 3:36:53 PM org.apache.tomcat.util.digester.Digester startElement SEVERE: Begin event threw error java.lang.IllegalAccessError at com.my.class.MyCustomHost.(MyCustomHost.java:18)

The solution I am trying to use was derived from here. Any input would help! Thanks!


回答1:


children is a final field in Tomcat 8 (see this source code diff), so changing it is illegal. Fortunately, you can use this trick to set it to a LinkedHashMap, or use the referred hack (with some small changes) to make children non-final.



来源:https://stackoverflow.com/questions/29684918/tomcat-8-starting-webapps-in-a-given-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!