ClassLoadingException : Unable to load class [*], with SpringBoot - JPA (JPQL request)

Hello,

During our load tests, via the Dynatrace monitoring tool, we noted the presence of many exceptions of type: “org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [*]”

Technos: SpringBoot version: 1.5.16.RELEASE, Hibernate version: 5.0.12.Final, WebLogic Server version: 12.2.1.3.0

These exceptions do not block the processes because the requests work correctly, they are invisible in console (we have never seen their presence outside of dynatrace or debug) but are expensive in terms of performance.

We were able to reproduce locally (on Tomcat) by adding a breakpoint in the ClassLoaderServiceImpl class on this part of the code:

public Class classForName (String className) {
try {
return Class.forName (className, true, this.getAggregatedClassLoader ());
} catch (Exception var3) {
throw new ClassLoadingException (“Unable to load class [” + className + “]”, var3);
} catch (LinkageError var4) {
throw new ClassLoadingException (“Unable to load class [” + className + “]”, var4);
}
}

After several tests, it seems that the exceptions appear when the application is started (specifically when loading JPQL queries) and when these queries are executed:

Example:

@Query (“SELECT foyer FROM FoyerEntity foyer”

  • “LEFT JOIN FETCH foyer.compoFoyerEntityList compoFoyer”
  • “LEFT JOIN FETCH compoFoyer.personneEntity person”
  • “LEFT JOIN FETCH personne.situationProfessionnelleEntityList situationPro”
  • “LEFT JOIN FETCH foyer.situationFamilialeEntityList situationFam”
  • “LEFT JOIN FETCH foyer.maintienDroitEntity maintenanceDroit”
  • “LEFT JOIN FETCH foyer.rattachementLogementEntityList logementList”
  • “LEFT JOIN FETCH housingList.logementEntity housing”
  • “WHERE foyer.idFoyer =: idFoyer”)
    FoyerEntity findFoyerByIdFoyer (@Param (“idFoyer”) Long idFoyer);

On this request we have 12 ClassLoaderException exceptions:

Org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [**. ****. ***. *********. Entity.foyer]
Org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [foyer]
Org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [compoFoyer]
Org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [person]
Org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [foyer]
Org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [logementList]

We don’t know why this specifically targets JPQL queries and we don’t know what to do to resolve them.

Thanks for your help

hello

The same problem occurs to me, and I can’t find the solution, could you find the solution or why does it happen?

thanks

Hello @alsoft27,

Thank you for your response, i was worried that i was the only one in this situation. I still don’t know why it happen but when i removed all entityGraph it was much better (but still happen when i start the application)

it is very strange what happens, to see if I find the problem

Hello @alsoft27,

i still have the same issue, did you find the problem ?

I still have the problem too :sweat:

Hello everyone, nobody else have the same problem or can analyze this issue ?

Please use our issue tracker to report such issues. I saw these exceptions through dynatrace as well in the past and this will be fixed in Hibernate 6, but these exceptions shouldn’t cause severe performance issues.