Tomcat 8:按给定顺序启动 WebApp [英] Tomcat 8: Starting WebApps in a given order
问题描述
在 Java 8 中使用 Tomcat 8.0.15
Using Tomcat 8.0.15 with Java 8
我需要先加载某个 WebApp,所以我将以下内容放入我的 server.xml 中:
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 如下所示:
MyCustomHost looks like below:
public class MyCustomHost extends StandardHost {
public MyCustomHost () {
super();
this.children = new LinkedHashMap();
} }
此设置在 Tomcat 7.0.42(使用 Java 7)中有效,但在 Tomcat 8.0.15(使用 Java 8)中,我收到以下错误:
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:
2015 年 4 月 16 日下午 3:36:53 org.apache.tomcat.util.digester.DigesterstartElement 严重:开始事件引发错误java.lang.IllegalAccessError 在com.my.class.MyCustomHost.(MyCustomHost.java:18)
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!
推荐答案
children
是 Tomcat 8 中的 final
字段(请参阅此源代码 diff),因此更改它是非法的.幸运的是,您可以使用这个技巧将其设置为LinkedHashMap
,或者使用引用的hack(有一些小改动)使 children
成为非最终的.
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.
这篇关于Tomcat 8:按给定顺序启动 WebApp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!