When I deploy a Grails application using RDS I am getting this error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager':
Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory':
Invocation of init method failed; nested exception is java.lang.NullPointerException
Related
Grails 3 (3.0.9) app is failing to start on a TC server where another 2 Grails 2 apps using each its JNDI datasource are running fine.
It seems that replicating my Grails 2 JNDI settings in Grails 3 is not working (I left everything else default and specified driverClassName, dbCreate and jndiName for my prod datasource settings).
The application has no problem connecting to the MySQL database straight through JDBC. Only JNDI makes it crash with the below exception (fragment)...
ERROR grails.boot.GrailsApp - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.spr
ingframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property
'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dat
aSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot r
esolve reference to bean 'dataSourceLazy' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'dataSourceLazy': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreation
Exception: Error creating bean with name 'dataSourceUnproxied': Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class
name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547) ~[spring-beans-4.1.7.RELEASE.jar:4
.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1
.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE
]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:199) ~[spring-context-4.1.7.RELEA
SE.jar:4.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.R
ELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at grails.boot.GrailsApp.run(GrailsApp.groovy:52) [grails-core-3.0.7.jar:3.0.7]
at grails.boot.GrailsApp.run(GrailsApp.groovy:330) [grails-core-3.0.7.jar:3.0.7]
at grails.boot.GrailsApp.run(GrailsApp.groovy:319) [grails-core-3.0.7.jar:3.0.7]
at grails.boot.GrailsApp$run.call(Unknown Source) [grails-core-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) [groovy-2.4.4.jar:2.4.4]
at miron3.Application.main(Application.groovy:8) [main/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while sett
ing bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve refe
rence to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dat
aSource': Cannot resolve reference to bean 'dataSourceLazy' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error c
reating bean with name 'dataSourceLazy': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.fa
ctory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need
to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEA
SE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-4.1.7.RELEASE.jar:4.1.
7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1477) ~[spring-beans-4.1.7.RELEA
SE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-4.1.7.RELEASE.jar:
your correct above didn't work. I followed below steps, its working now for me.
tomcat context.xml file defined like this:
Resource name="grailsDB"
application.yml added this production datasource.
production:
dataSource:
dbCreate: update
jndiName: java:comp/env/grailsDB
created the grails-app/conf/DataSource.groovy file, based on https://grails.github.io/grails-doc/3.0.x/ref/Plug-ins/dataSource.html document.
dataSource {
jndiName = "java:comp/env/grailsDB"
}
created the war file using grails war command.
deployed in tomcat and tested it by adding deleting the sample data.
Here is software versions I tested with.
APPLICATION STATUS
Environment: production
App profile: web
App version: 0.1
Grails version: 3.0.3
Groovy version: 2.4.3
JVM version: 1.8.0_65
Hope this helps.
thanks
-SR
In application.yml I replaced url with this value,it work for me. you can try the same.
production:
dataSource:
dbCreate: update
jndiName: java:comp/env/jdbc/dbjndiname
When running the build of our Grails app locally, it works fine. However, when it runs out on our TeamCity instance, after it does the unit tests and goes into the integration test phase, this happens:
[13:15:35][exec] Configuring Spring Security Core ...
[13:15:36][exec] ... finished configuring Spring Security Core
[13:15:36][exec]
[13:26:43][exec] Error |
[13:26:43][exec] Fatal error running tests: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] (Use --stacktrace to see the full trace)
[13:26:43][exec] Tests FAILED |
[13:26:43][exec]
[13:26:45][exec] Error |
[13:26:45][exec] Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] (Use --stacktrace to see the full trace)
[13:26:45][exec] Result: 1
Any clue why this would happen on the build box but not locally? I can't find anything that makes sense to me.
I have created a new Grails 2.2 app that contains the platform-ui-1.0.RC5 plugin. Whenever I use the Grails “run-app” command to start the app in development mode, everything works OK. However, if I run “prod run-war” or war up the app and run it under Tomcat on a separate server, I get the following error:
Oct 31, 2013 8:07:16 AM org.apache.catalina.core.ApplicationContext
log INFO: Initializing Spring root WebApplicationContext Oct 31, 2013
8:07:28 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener
instance of class
org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'instanceTagLibraryApi': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire method: public void
org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi.setGspTagLibraryLookup(org.codehaus.groovy.grails.web.pages.TagLibraryLookup);
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'gspTagLibraryLookup': Invocation of init
method failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'org.grails.plugin.platform.ThemeTagLib':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsThemes': Cannot resolve reference to
bean 'grailsViewFinder' while setting bean property
'grailsViewFinder'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsViewFinder': Cannot create inner bean
'(inner bean)' while setting bean property 'precompiledGspMap'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#1': Instantiation of bean
failed; nested exception is java.lang.IllegalStateException: No bean
class specified on bean definition at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at
java.util.concurrent.FutureTask.run(FutureTask.java:166) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722) Caused by:
org.springframework.beans.factory.BeanCreationException: Could not
autowire method: public void
org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi.setGspTagLibraryLookup(org.codehaus.groovy.grails.web.pages.TagLibraryLookup);
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'gspTagLibraryLookup': Invocation of init
method failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'org.grails.plugin.platform.ThemeTagLib':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsThemes': Cannot resolve reference to
bean 'grailsViewFinder' while setting bean property
'grailsViewFinder'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsViewFinder': Cannot create inner bean
'(inner bean)' while setting bean property 'precompiledGspMap'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#1': Instantiation of bean
failed; nested exception is java.lang.IllegalStateException: No bean
class specified on bean definition ... 5 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'gspTagLibraryLookup': Invocation of init
method failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'org.grails.plugin.platform.ThemeTagLib':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsThemes': Cannot resolve reference to
bean 'grailsViewFinder' while setting bean property
'grailsViewFinder'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsViewFinder': Cannot create inner bean
'(inner bean)' while setting bean property 'precompiledGspMap'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#1': Instantiation of bean
failed; nested exception is java.lang.IllegalStateException: No bean
class specified on bean definition ... 5 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'org.grails.plugin.platform.ThemeTagLib':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsThemes': Cannot resolve reference to
bean 'grailsViewFinder' while setting bean property
'grailsViewFinder'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsViewFinder': Cannot create inner bean
'(inner bean)' while setting bean property 'precompiledGspMap'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#1': Instantiation of bean
failed; nested exception is java.lang.IllegalStateException: No bean
class specified on bean definition ... 5 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsThemes': Cannot resolve reference to
bean 'grailsViewFinder' while setting bean property
'grailsViewFinder'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsViewFinder': Cannot create inner bean
'(inner bean)' while setting bean property 'precompiledGspMap'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#1': Instantiation of bean
failed; nested exception is java.lang.IllegalStateException: No bean
class specified on bean definition ... 5 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'grailsViewFinder': Cannot create inner bean
'(inner bean)' while setting bean property 'precompiledGspMap'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#1': Instantiation of bean
failed; nested exception is java.lang.IllegalStateException: No bean
class specified on bean definition ... 5 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name '(inner bean)#1': Instantiation of bean
failed; nested exception is java.lang.IllegalStateException: No bean
class specified on bean definition ... 5 more Caused by:
java.lang.IllegalStateException: No bean class specified on bean
definition ... 5 more
Oct 31, 2013 8:07:28 AM org.apache.catalina.core.StandardContext
startInternal SEVERE: Error listenerStart Oct 31, 2013 8:07:28 AM
org.apache.catalina.core.StandardContext startInternal SEVERE: Context
[/zdummy] startup failed due to previous errors
Here is the “plugins” section of my BuildConfig.groovy file:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.10.2"
runtime ":resources:1.2"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.2.1"
compile ':cache:1.0.1'
compile ":platform-ui:1.0.RC5"
}
I commented out the platform-ui plugin.
Refreshed the dependencies.
Ran the Grails clean command.
Ran the project using “prod run-war” and it ran correctly.
Any help would be appreciated.
Thanks
David
I am using grails 2.2.0 when executing command test-app-integration -coverage it is giving error
Error Exception occurred trigger event [TestPhasesEnd]: Could not create a new instance of class [AdminController]! (Use --stacktrace to see the full trace)
| Error Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.VerifyError: (class: com/cantina/lab/Movie$FileGroupVideo, method: whereAny signature: (Lgroovy/lang/Closure;)Lgrails/gorm/DetachedCriteria;) Incompatible type for getting or setting field
Move the enum to src/groovy as a workaround. See this jira issue., should be fixed in 2.2.1.
I am using spring security core plug in in my grails app. When I run the app, I'm getting following error. How can I solve this?
Configuring Spring Security ...
2011-06-30 10:45:19,468 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.InstantiationException: could not instantiate test objecthospitalmanagement.Physician
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.InstantiationException: could not instantiate test objecthospitalmanagement.Physician
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.InstantiationException: could not instantiate test objecthospitalmanagement.Physician
... 23 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.InstantiationException: could not instantiate test objecthospitalmanagement.Physician
... 23 more
Caused by: org.hibernate.InstantiationException: could not instantiate test objecthospitalmanagement.Physician
... 23 more
Caused by: java.lang.reflect.InvocationTargetException
... 23 more
Caused by: groovy.lang.MissingPropertyException: No such property: Patient for class: hospitalmanagement.Physician
at hospitalmanagement.Physician.<init>(Physician.groovy)
... 23 more
Caused by: groovy.lang.MissingPropertyException: No such property: Patient for class: hospitalmanagement.Physician
at hospitalmanagement.Physician.<init>(Physician.groovy)
This is telling you that hospitalmanagement.Physician is trying to access a Patient property which doesn't exist (in the same class).
No idea how you should solve that since you haven't shown the corresponding code.
There is a solution at the link below. It worked for me.
http://forum.springsource.org/showthread.php?120786-Upgraded-from-Grails-1-3-7-to-2-0-and-am-getting-method-lt-init-gt-%28%29V-not-found-error&p=409849#post409849