Project

General

Profile

App won't start on Tomcat, no errors, JDK13 preview features

Added by Komorek, Kamil almost 5 years ago

Got very annoying problem last night. I've implemented big feature which adds many framework libraries to master branch.
I've also used "preview features" from JDK13, especially Text Blocks preview (read here, I love it).

Everything works fine running main @SpringBootApplication class. Manually tested, ok, it's great, may go to my little home-production.

However when I merged changes, which triggered CI/CD... the app silently dies just after startup on Apache Tomcat 9.

No logs, no errors, nothing. Just one row in localhost.YYYY-MM-DD.log:

12-Jan-2020 00:44:29.506 INFO [main] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath

I thought my liquibase changeset's didn't ran on Postgres database (I'm testing on H2).

Next I was thinking that added libraries already not works with JDK13, and became to compare with old build / removed jars. No luck.

Next I thought my last logging cleanup changes broke completely logging - nope, old war works.
Maybe one of libraries adds own logging library and overwrites mine bridges?
Moving forward I tried to add Log4j2 to my app, believing that default Logback makes me idiot. Didn't helped.

Finally I've changed Tomcat's conf/logging.properties from FINE and INFO to ALL and that finally gave me a hint.

12-Jan-2020 21:48:08.006 FINE [main] org.apache.catalina.util.Introspection.loadClass Failed to load class [pl.dexterxx.myapp.ServletInitializer]
        java.lang.UnsupportedClassVersionError: Preview features are not enabled for pl/dexterxx/myapp/ServletInitializer (class file version 57.65535). Try running with '--enable-preview' (unable to load class [pl.dexterxx.myapp.ServletInitializer])
                at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2424)
                at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:865)
                at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1334)
                at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
                at org.apache.catalina.util.Introspection.loadClass(Introspection.java:153)

Solution:
Add to bin/setenv.sh:

export CATALINA_OPTS="$CATALINA_OPTS --enable-preview" 

In maven project I've already did that, read more here. Forgot about Tomcat.


Comments