2017-01-11 47 views
2

我按照Grails 3.2 documentation中的指示從hibernate 5(默認)切換到hibernate 4.但是,現在我的應用程序無法啓動。啓動時出現下面顯示的異常。在使用Hibernate 4和Grails 3.2.4時啓動時發生NullPointerException

01/12/2017 11:52:55 PST ERROR main SpringApplication:839 - Application startup failed 
java.lang.NullPointerException: null 
    at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1337) 
    at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197) 
    at java.beans.Introspector.getBeanInfo(Introspector.java:426) 
    at java.beans.Introspector.getBeanInfo(Introspector.java:173) 
    at java.beans.Introspector.getBeanInfo(Introspector.java:260) 
    at java.beans.Introspector.<init>(Introspector.java:407) 
    at java.beans.Introspector.getBeanInfo(Introspector.java:173) 
    at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3290) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3288) 
    at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3265) 
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:254) 
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285) 
    at org.codehaus.groovy.runtime.callsite.ClassMetaClassGetPropertySite.<init>(ClassMetaClassGetPropertySite.java:38) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.createClassMetaClassGetPropertySite(AbstractCallSite.java:373) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.createGetPropertySite(AbstractCallSite.java:325) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.acceptGetProperty(AbstractCallSite.java:312) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296) 
    at org.grails.plugins.databasemigration.DatabaseMigrationGrailsPlugin.configureLiquibase(DatabaseMigrationGrailsPlugin.groovy:96) 
    at org.grails.plugins.databasemigration.DatabaseMigrationGrailsPlugin.doWithSpring(DatabaseMigrationGrailsPlugin.groovy:55) 
    at org.grails.plugins.DefaultGrailsPlugin.doWithRuntimeConfiguration(DefaultGrailsPlugin.java:555) 
    at org.grails.plugins.AbstractGrailsPluginManager.doRuntimeConfiguration(AbstractGrailsPluginManager.java:167) 
    at grails.boot.config.GrailsApplicationPostProcessor.postProcessBeanDefinitionRegistry(GrailsApplicationPostProcessor.groovy:171) 
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) 
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) 
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) 

一些快速的谷歌搜索似乎暗示此錯誤是由項目的依賴關係中的一些不匹配造成的。然而,Grails 3.2文檔只提到了添加hibernate 4依賴關係,但沒有改變任何其他的依賴關係。有誰知道這裏發生了什麼,以及如何解決它?使用

回答

0

首先刷新依賴 -

grails clean --refresh-dependencies 

構建使用此命令的依賴性報告 -

grails dependency-report 

確認應用程序正在使用休眠4依賴。找出是否有任何插件使用hibernate 5依賴項。如果這樣從你的build.gradle文件中將它從各自的插件中排除。

+0

然後嘗試'grails run-app' –

+0

這樣做。原來我使用的數據庫遷移插件版本取決於hibernate 5,並拉入了與我使用hibernate 4不匹配的依賴項。我將其降級到版本2.0.0的數據庫遷移插件,它與Grails 3和休眠4(根據這裏的文檔:https://github.com/grails-plugins/grails-database-migration),並做到了這一點。謝謝! – Schmick

+0

很高興我能幫到你。 –

相關問題