Could not build ClassFile - ArchiveException

The issue can be a conflict between a java version and a javaassist version. If you're using the java 8 on your server you should make sure to use the latest javassist version as well. This blog shows the origin of a conflict being inside the thymeleaf which pulls in an older javassist, the solution being to exclude it from the dependencies

<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf</artifactId>
    <version>${thymeleaf.version}</version>
    <exclusions>
        <exclusion>
            <artifactId>javassist</artifactId>
            <groupId>org.javassist</groupId>
        </exclusion>
    </exclusions>
</dependency>

your case could be different, so you should inspect the dependency tree to find a suitable solution


I had the exact same issue, in that it worked fine on a development machine and then failed in production.

The reason can be seen if you build the war file locally and then unzip it. You'll see you end up with two javassist jars:

javassist-3.11.0.GA.jar
javassist-3.18.1-GA.jar

which will just be deployed together in the same lib folder. So when your java application loads and it requires a class from the javassist library it will search the classpath and probably encounter the first (and incorrect) jar and load it.

This probably doesn't happen locally because your buld tool (maven, or in my case gradle) constructs a long intricate classpath of specific resources, in which it probably specifies the compatible version first which makes it more probable that the classpath search will find it.

(I keep saying probable because it will depend on how the classpath searching has been implemented and I think this can depend on the JVM, and other things, but I don't have the impetus to look it up right now but will add it to my TODO list and get back to you... or if anyone else knows the answer please just edit this post!)

Anway, for any gradle users out there I solved the problem with the following snippet:

configurations {
    all*.exclude group: 'javassist', module: 'javassist' // get rid of hibernate-incompatible javassist
}

I had to use a global exclusion because the javassist-3.11 library (group: 'javassist') was being pulled in as a dependency of a dependency of a dependency and hibernate wanted the javassist-3.18 library (group: 'org.javassist') instead.

Thanks to all invovled, especially master-slave.


I had a same issue when tried to deploy Java 8 application to Weblogic 12.1.3c. What i did is add this to weblogic.xml:

    <wls:prefer-application-packages>
        <wls:package-name>javassist</wls:package-name>
    </wls:prefer-application-packages>

Thanks to master-slave, I found the problem, as he describes there is a conflict with a incompatible java 8 library of javassist.

In my case, it was a dependency of tiles:

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-extras</artifactId>
    <version>3.0.5</version>
    <exclusions>
        <exclusion>
            <artifactId>javassist</artifactId>
            <groupId>jboss</groupId>
        </exclusion>
    </exclusions>
</dependency>