0

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!

Community
  • 1
  • 1
373020
  • 3
  • 2

1 Answers1

0

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.

Community
  • 1
  • 1
vanOekel
  • 6,358
  • 1
  • 21
  • 56