"java.lang.UnsupportedOperationException: EnversService#initialize should be called only once" when building Hibernate metadata

Solution Verified - Updated -

Issue

  • Explicitly bootstrapping Hibernate to access a legacy (non-JPA) session factory
  • Encountering the exception below

    ... java.lang.UnsupportedOperationException: EnversService#initialize should be called only once
        at org.hibernate.envers.boot.internal.EnversServiceImpl.initialize(EnversServiceImpl.java:105)
        at org.hibernate.envers.boot.internal.AdditionalJaxbMappingProducerImpl.produceAdditionalMappings(AdditionalJaxbMappingProducerImpl.java:101)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:297)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:84)
        at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:474)
        at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:85)
        at org.hibernate.boot.MetadataSources.buildMetadata(MetadataSources.java:180)
        ...
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.3
  • Hibernate 5.3

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content