grails-database-migration icon indicating copy to clipboard operation
grails-database-migration copied to clipboard

Command execution error: Bean named 'sessionFactory' is expected to be of type 'org.springframework.beans.factory.FactoryBean' but was actually of type 'org.hibernate.internal.SessionFactoryImpl'

Open jameskhedley opened this issue 7 years ago • 10 comments

Appears to be the same as #81 but with grails 3.3.8, plugin 2.0.0, hibernate4, gorm version 6.1.8.

Shouldn't that combination work?

Steps to Reproduce

  1. grails dbm-gorm-diff

Expected Behaviour

Diff produced

Actual Behaviour

Command execution error: Bean named 'sessionFactory' is expected to be of type 'org.springframework.beans.factory.FactoryBean' but was actually of type 'org.hibernate.internal.SessionFactoryImpl'

Environment Information

  • Operating System: RHEL7.5
  • Grails Version: 3.3.8
  • Plugin Version: 2.0.0
  • Database: Postgres 9.6
  • JDK Version: 1.8.0_181-b25

Example Application

Can supply if required.

jameskhedley avatar Nov 14 '18 15:11 jameskhedley

Please upload an example project

jameskleeh avatar Nov 14 '18 15:11 jameskleeh

https://github.com/jameskhedley/test151

It's just a fresh app $ grails create-app test151 --profile=web, then change the dependencies for hibernate5 to hibernate4, then add the plugin, then a single domain class.

The only other thing I did was change Gorm version to 6.1.8 instead of 6.1.10 in gradle.properties

jameskhedley avatar Nov 14 '18 16:11 jameskhedley

Adding specific liquibase doesn't help either, as per docs:

compile 'org.liquibase:liquibase-core:3.5.3'

jameskhedley avatar Nov 14 '18 17:11 jameskhedley

@jameskleeh anything yet? If migration plugin is broken for grails 3, would halt our migration project. Suspect I'm doing something wrong though...

jameskhedley avatar Nov 22 '18 15:11 jameskhedley

Surely plugin version 2.0.0? Current is 3.0.4

robertoschwald avatar Nov 30 '18 11:11 robertoschwald

@robertoschwald yes it says plugin version 2.0.0, which is the version that is supposed to work with hibernate4? As per https://github.com/grails-plugins/grails-database-migration#versions

As far as I can see, plugin v1.4 works ok with grails 2.x and hibernate3 (and hibernate4 i think) but plugin v2.0.0 doesn't work with grails 3.x and hibernate4... like at all.

jameskhedley avatar Nov 30 '18 14:11 jameskhedley

Not sure if 2.0.0 works with Grails 3.3.x. Can you try Hibernate 5 and 3.0.4?

robertoschwald avatar Nov 30 '18 15:11 robertoschwald

Using grails 3.3.8, hibernate5 and plugin v3.0.3 fails with a different error (see below).

Is there a version of grails 3.x that you would expect to work with 2.0.0 and hibernate 4? Not sure what the point of that branch is otherwise.

$ grails dbm-status
:compileJava NO-SOURCE
:compileGroovy UP-TO-DATE
:buildProperties
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:dbmStatus
INFO 30/11/18 17:38: liquibase: Can not use class org.grails.plugins.databasemigration.liquibase.GormDatabase as a Liquibase service because it does not have a no-argument constructor
Command execution error: java.lang.IllegalArgumentException: Script text to compile cannot be null!
:dbmStatus FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dbmStatus'.
> Process 'command '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 13.366 secs
| Error Command [dbm-status] error: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-bin.zip'. (Use --stacktrace to see the full trace)

jameskhedley avatar Nov 30 '18 17:11 jameskhedley

The error you see in 3.0.3 was fixed in 3.0.4. You need to use this version.

robertoschwald avatar Nov 30 '18 18:11 robertoschwald

Good spot and thanks for help so far.

Actually i tried it with 3.0.4 and got the same error - but only with dbm-status - dbm-gorm-diff worked! I think dbm-status may be broken? Error message was:

Command execution error: java.lang.IllegalArgumentException: Script text to compile cannot be null!

Also I was thrown off by the "no-argument" non-error.

I still think 2.0.0 is broken unless someone can say what versions of hibernate4 and grails it works with. In reality I think we'll probably try hibernate5 with our project and hope that doesn't break anything too badly.

jameskhedley avatar Nov 30 '18 20:11 jameskhedley