2

I got stuck with a problem with an EAR deployment on JBOSS 10.1.2

I get the foolowing exception:

Caused by: org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile
    at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassFile(ClassFileArchiveEntryHandler.java:64)
    at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:47)
    at org.jboss.as.jpa.hibernate5.VirtualFileSystemArchiveDescriptor.processVirtualFile(VirtualFileSystemArchiveDescriptor.java:94)
    at org.jboss.as.jpa.hibernate5.VirtualFileSystemArchiveDescriptor.processVirtualFile(VirtualFileSystemArchiveDescriptor.java:69)
    at org.jboss.as.jpa.hibernate5.VirtualFileSystemArchiveDescriptor.processVirtualFile(VirtualFileSystemArchiveDescriptor.java:69)
    at org.jboss.as.jpa.hibernate5.VirtualFileSystemArchiveDescriptor.visitArchive(VirtualFileSystemArchiveDescriptor.java:49)
    at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:47)
    at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:75)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:199)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149)
    at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:28)
    at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:40)
    at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.<init>(TwoPhaseBootstrapImpl.java:39)
    at org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor.getBootstrap(HibernatePersistenceProviderAdaptor.java:159)
    at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.createContainerEntityManagerFactoryBuilder(PhaseOnePersistenceUnitServiceImpl.java:242)
    at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.access$800(PhaseOnePersistenceUnitServiceImpl.java:59)
    at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:117)
    ... 7 more

I looked on the internet and found out, that this exception comes because of different javassist version.

The answers in this post on stackoverflow were not usefull, because I neither use Spring, nor Weblogic, nor Thymyleaf.

There are two libraries which use javassist: Hibernate and org.reflections. Using Maven dependency tree I can find following out:

for org.reflections

[INFO] |  +- org.reflections:reflections:jar:0.9.11:compile
[INFO] |  |  +- (com.google.guava:guava:jar:20.0:compile - omitted for conflict with 21.0)
[INFO] |  |  \- (org.javassist:javassist:jar:3.21.0-GA:compile - omitted for conflict with 3.20.0-GA)

for Hibernate:

[INFO] |  |  +- org.hibernate:hibernate-core:jar:5.2.8.Final:provided
[INFO] |  |  |  +- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:provided - omitted for conflict with 3.1.4.GA)
[INFO] |  |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:provided
[INFO] |  |  |  +- org.javassist:javassist:jar:3.20.0-GA:provided

My lib folder of the EAR contains

hibernate-core-5.2.8.Final.jar
javassist-3.20.0-GA.jar

JBOSS has also a module for javassists with

javassist-3.18.1.GA-redhat-2.jar

Now I am a little bit confused about the whole problem. I tried to remove references for org.reflections, but the deployment still failed.

Has anyone an idea?

EDIT

Ok, I found out which library causes exception:

<dependency>
   <groupId>com.google.template</groupId>
   <artifactId>soy</artifactId>
   <version>2018-01-03</version>
</dependency>

But I stil don't know how to solve the problem.

EDIT

Ok, I tried to use the previous maven version of the libarary (2017-08-08) and it works. Don't know what the issue can be. Should possibly report it to the library owner on Github. If anyone has an idea you are welcome.

N.Zukowski
  • 600
  • 1
  • 12
  • 31

2 Answers2

3

As mentioned by @GlenPeterson in the comments:

I had this issue and upgrading the maven-shade-plugin from 2.4.3 to 3.1.1 fixed it.

Upgrading the maven-shade-plugin from 2.4.3 to 3.2.1 (latest one right now) worked. I saw that the shade plugin created a slightly smaller uber jar.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
awd020
  • 31
  • 2
0

The problem is caused by javassist conflict

  1. you can use: mvn dependency:tree, find which jar include javassist
  2. you can exclude it:
<dependency>
    <groupId>xxx</groupId>
    <artifactId>xxx</artifactId>
    <version>xxxx</version>
    <exclusions>
        <!-- 排除javassist-->
        <exclusion>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Steffen Harbich
  • 2,639
  • 2
  • 37
  • 71