Using Hibernate 5 on Payara

Mert Çalışkan
2 min readSep 14, 2015

--

While deploying Hibernate 5.0.1.Final powered application on Payara 4.1.153, I faced with the stacktrace given below.

java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:764)at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:495)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)

With the hint of NoSuchMethodError, It was obvious that I was stuck with different versions of jboss-logging.jar so I executed mvn dependency:tree within my project to get the whole dependency tree. The result was given as follows for the hibernate jars that I used.

So the hibernate-core jar was transitively dependant on jboss-logging with version 3.3.0.Final. I excluded it with <exclusion> tag. The next execution of dependency:tree prompted me with another jboss-logging transitively bundled within hibernate-entitymanager.jar

I continued with excluding that also to see if any other transitive dependency exists. And yet there is more…

Hibernate Validator came up with a slightly older version, 3.2.1.Final. Ok, moved on with excluding it. By the way Hibernate Validator team should update their transitive dependencies and align with the -core team IMO.

Ok, this was the last jboss-logging dependency that I came across. I was pretty sure that Hibernate 5 depends on jboss-logging 3.3.X.

The error was mentioning about a missing debugf method, so after searching about it, I saw that the …f methods are newly implemented. There has to be an older version of jboss-logging on my classpath so I went through the jar files under Payara (a.k.a. Glassfish) installation folder.

I found a jboss-logging.jar under payara/glassfish/modules folder. When I opened up its manifest file I saw that the version was: 3.1.3.GA.

Removing the jboss-logging.jar and adding the jboss-logging-3.3.0.Final.jar resolved the issue for me. I also added jboss-logging dependency with provided scope in pom.xml file. By adding a new dependency there was no need to exclude any artifact from hibernate-* dependency definitions.

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
<scope>provided</scope>
</dependency>

--

--

Mert Çalışkan

Opsgenie Champion at Atlassian. Oracle Java Champion. AnkaraJUG Lead. Author of Beginning Spring & PrimeFaces Cookbook.