Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hibernate-envers - UnsupportedOperationException #104

Closed
zyro23 opened this issue Dec 3, 2016 · 10 comments
Closed

hibernate-envers - UnsupportedOperationException #104

zyro23 opened this issue Dec 3, 2016 · 10 comments

Comments

@zyro23
Copy link
Contributor

zyro23 commented Dec 3, 2016

dbm-3.0.0, grails-3.2.3, gorm-6.0.4, hibernate-5.0.11.

when using hibernate envers, all liquibase commands that involve two databases (e.g. dbm-gorm-diff - 1 gorm db, 1 real db) cause an UnsupportedOperationException here:
https://github.com/hibernate/hibernate-orm/blob/5.0.11/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceImpl.java#L107

ugly workaround for now was to write a custom ÈnversService / ServiceContributor / ServiceInitiator that overrides the default hibernate EnversServiceImpl.

do we have any sane option to prevent that from happening or should we raise an upstream issue for hibernate-envers explaining the dbm diff use-case and request to remove that condition?

@jameskleeh
Copy link
Contributor

Can you include the stacktrace? I doubt hibernate would consider changing that for our use case.

@zyro23
Copy link
Contributor Author

zyro23 commented Dec 6, 2016

sure. gradlew dbmGormDiff only shows: Command execution error: EnversService#initialize should be called only once.
no stacktrace with--debug --stacktrace either.
debugging to https://github.com/hibernate/hibernate-orm/blob/5.0.11/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceImpl.java#L107 gives the following stack (note the condition only fails if it runs the 2nd time, that is for the GORM diff model):

java.lang.UnsupportedOperationException: EnversService#initialize should be called only once
	at org.hibernate.envers.boot.internal.EnversServiceImpl.initialize(EnversServiceImpl.java:107)
	at org.hibernate.envers.boot.internal.AdditionalJaxbMappingProducerImpl.produceAdditionalMappings(AdditionalJaxbMappingProducerImpl.java:99)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:288)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
	at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
	at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
	at org.grails.plugins.databasemigration.liquibase.GormDatabase.<init>(GormDatabase.groovy:39)
	at org.grails.plugins.databasemigration.command.ApplicationContextDatabaseMigrationCommand$Trait$Helper.createGormDatabase(ApplicationContextDatabaseMigrationCommand.groovy:90)
	at org.grails.plugins.databasemigration.command.ApplicationContextDatabaseMigrationCommand$Trait$Helper.withGormDatabase(ApplicationContextDatabaseMigrationCommand.groovy:69)
	at org.grails.plugins.databasemigration.command.DbmGormDiffCommand.withGormDatabase(DbmGormDiffCommand.groovy)
	at org.grails.plugins.databasemigration.command.DbmGormDiffCommand.handle(DbmGormDiffCommand.groovy:45)
	at org.grails.plugins.databasemigration.command.ApplicationContextDatabaseMigrationCommand$Trait$Helper.handle(ApplicationContextDatabaseMigrationCommand.groovy:48)
	at org.grails.plugins.databasemigration.command.DbmGormDiffCommand.handle(DbmGormDiffCommand.groovy)
	at grails.ui.command.GrailsApplicationContextCommandRunner.run(GrailsApplicationContextCommandRunner.groovy:65)
	at grails.ui.command.GrailsApplicationContextCommandRunner.main(GrailsApplicationContextCommandRunner.groovy:102)

this is a bit related to grails/gorm-hibernate5#15 as that would at least allow to cleanly override the EnversService used by hibernate by default (EnversServiceImpl) with a custom implementation.

@jameskleeh
Copy link
Contributor

@zyro23 I don't think there is anything I can do on this end. I see the issue you linked is closed. Does that satisfy your requirement?

@zyro23
Copy link
Contributor Author

zyro23 commented Jan 10, 2017

linked issue has kind of a follow up as it fixed being able to register a custom service in envers but now the configuration of a custom mappingContextConfiguration is not working. ref. grails/gorm-hibernate5#17

anyway, thats the right place where this should be fixed. closing this one here. thanks!

@zyro23 zyro23 closed this as completed Jan 10, 2017
@RobertStroud
Copy link

@zyro23 can you provide more information about your "ugly workaround"? Is this something that needs to be fixed in the "database-migration" plugin, or does it need to be fixed in the interface between Grails and Envers, for example, in an Envers plugin?

I am experiencing the same problem using Grails 3.2.12 with GORM 6.1.6 and a version of the "grails-envers" plugin that has been ported to Grails 3.

Thanks.

@zyro23
Copy link
Contributor Author

zyro23 commented Nov 11, 2017

@cgoIT
Copy link

cgoIT commented Jan 25, 2019

I know that this issue was closed a long time ago, but i'm lost in getting dbm-gorm-diff running. Could you please give me some advice how to do it?

Thanks.

@xavs
Copy link

xavs commented Sep 11, 2021

Same here, the plugin is broken for grails 4.

@davebrown1975
Copy link

Any update at all ?

@verglor
Copy link
Contributor

verglor commented Apr 28, 2023

There is open issue #204 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants