pgjdbc: Required class information missing after upgrade to version higher than 42.2.14

I’ve upgraded driver to version 42.2.18, then Required class information missing error appeared. Source code with traces bellow. To omit error i had to back to version 42.2.14.

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
             http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
  <persistence-unit name="valuation" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

    <class>com.example.model.Data</class>

    <properties>
      <!-- Configuring JDBC properties -->
      <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://url:5432/db"/>
      <property name="javax.persistence.jdbc.user" value="dbadmin"/>
      <property name="javax.persistence.jdbc.password" value="xyz"/>
      <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>

      <!-- Hibernate properties -->
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL95Dialect"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="hibernate.format_sql" value="true"/>
      <property name="hibernate.show_sql" value="false"/>

      <!-- batching size -->
      <property name="hibernate.connection.autocommit" value="false"/>
      <property name="hibernate.jdbc.batch_size" value="30"/>
      <property name="hibernate.order_inserts" value="true"/>
      <property name="hibernate.order_updates" value="true"/>
      <property name="hibernate.jdbc.batch_versioned_data" value="true"/>
    </properties>
  </persistence-unit>
</persistence>

Stack trace:

Caused by: java.lang.IllegalStateException: Required class information is missing
	at org.jboss.jandex.Indexer.rebuildNestedType(Indexer.java:926)
	at org.jboss.jandex.Indexer.resolveTypePath(Indexer.java:786)
	at org.jboss.jandex.Indexer.resolveTypeAnnotation(Indexer.java:705)
	at org.jboss.jandex.Indexer.resolveTypeAnnotations(Indexer.java:613)
	at org.jboss.jandex.Indexer.index(Indexer.java:1602)
	at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassDescriptor(ClassFileArchiveEntryHandler.java:64)
	at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:52)
	at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:147)
	at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:48)
	at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:76)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:107)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:254)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:175)
	at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:76)
	at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:171)
	at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:119)
	at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:61)
	at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:50)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
	at com.okarmusk.data.converter.persistence.dao.EntityManagerProvider.<clinit>(EntityManagerProvider.java:11)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33 (21 by maintainers)

Commits related to this issue

Most upvoted comments

Here’s a relevant jandex issue: https://github.com/wildfly/jandex/issues/92

I’ve created jandex issue: https://github.com/wildfly/jandex/issues/99

The takeaway for pgjdbc is we might want to verify that the produced bytecode is parseable with jandex, asm, and probably other bytecode analysis frameworks.

public class LruCache<Key extends @NonNull Object, Value extends @NonNull CanEstimateSize>
    implements Gettable<Key, Value> {

javap -verbose -p LruCache.class

Signature: #116                         // <Key:Ljava/lang/Object;Value::Lorg/postgresql/util/CanEstimateSize;>Ljava/lang/Object;Lorg/postgresql/util/Gettable<TKey;TValue;>;
SourceFile: "LruCache.java"
RuntimeVisibleTypeAnnotations:
  0: #119(): CLASS_TYPE_PARAMETER_BOUND, param_index=0, bound_index=0
    org.checkerframework.checker.nullness.qual.NonNull
  1: #119(): CLASS_TYPE_PARAMETER_BOUND, param_index=1, bound_index=1
    org.checkerframework.checker.nullness.qual.NonNull

This represents the two @NonNull annotations.

Unfortunately, it is not clear which specification declares that optional class bound should reserve “bound_index=0”, however, OpenJDK implementation does adjust the index. Interestingly enough, there was a recent fix in the area of reflection vs type annotations: https://github.com/openjdk/jdk/commit/9d7f8bc9a053595c290ae339b902dc762b848ab9

Interestingly in my email what I see your error becoming is:

Exception in thread "main" java.lang.IllegalStateException: Required class information is missing
	at org.jboss.jandex.Indexer.rebuildNestedType(Indexer.java:932)
	at org.jboss.jandex.Indexer.resolveTypePath(Indexer.java:792)
	at org.jboss.jandex.Indexer.resolveTypeAnnotation(Indexer.java:711)
	at org.jboss.jandex.Indexer.resolveTypeAnnotations(Indexer.java:619)
	at org.jboss.jandex.Indexer.index(Indexer.java:1617)
	at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassDescriptor(ClassFileArchiveEntryHandler.java:64)