hc0re
hc0re

Reputation: 1986

Tomcat, two Java versions and "invalid constant type: 18"

I have a problem with deploying my app to Tomcat. I have Tomcat on a Docker containter, java -version gives output like this:

openjdk version "1.8.0_151"
OpenJDK Runtime Environment (IcedTea 3.6.0) (Alpine 8.151.12-r0)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

The app was build on a Windows machine, using:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode) 

When trying to start the app I get:

Caused by: java.io.IOException: invalid constant type: 18
    at javassist.bytecode.ConstPool.readOne(ConstPool.java:967)
    at javassist.bytecode.ConstPool.read(ConstPool.java:910)
    at javassist.bytecode.ConstPool.<init>(ConstPool.java:127)
    at javassist.bytecode.ClassFile.read(ClassFile.java:630)
    at javassist.bytecode.ClassFile.<init>(ClassFile.java:52)

One more thing - the app build on the Windows machine is running perfectly fine on the server with Java version:

openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

What should I do in this situation? Build the app on OpenJDK? Change the version?

Upvotes: 1

Views: 4623

Answers (2)

Chinthaka Dinadasa
Chinthaka Dinadasa

Reputation: 3461

Check the dependencies tree using MVN and check whether you've added multiple versions from javassist library.

mvn dependency:tree

If do, Remove the older version and keep the latest javassist with the application.

Upvotes: 0

Pratap Kumar Panda
Pratap Kumar Panda

Reputation: 171

Use higher version javassist jar. if you are using maven, make the following pom entry for java assist.

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.18.2-GA</version>
</dependency>

Upvotes: 0

Related Questions