Orika mapping exception java.io.IOException: invalid constant type: 18 at 55

In this post we will see about orika mapping exception “ma.glasnost.orika.MappingException: java.lang.RuntimeException: java.io.IOException: invalid constant type: 18 at 55”.

Possible reason –

  1. Upgrade to java version – You may be started encounter problem after updating your Java version to 1.8.
  2. You might see weird issues after deployment the first time it will throw exception later it will work fine.

Error is coming from below class –

The javassist library contains class called ConstPool.java in javassist.bytecode  package. This class contains readOne() method, if the tag variable doesn’t have a value between 1 to 12 then we have this exception. See line number 10.

private int readOne(DataInputStream in) throws IOException {
        int tag = in.readUnsignedByte();
        Object info;
        switch(tag) {
        case 1:
            info = new Utf8Info(in, this.numOfItems);
            break;
        case 2:
        default:
            throw new IOException("invalid constant type: " + tag + " at " + this.numOfItems);
        case 3:
            info = new IntegerInfo(in, this.numOfItems);
            break;
      //some more code
        return tag;
    }

 

Solution –

Update your javassist version older to new one.

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

 

or any latest version.