|
I've had a look at a couple of blog posts from Glen Smith and Steve Dalton and tried to merge the two for using Postgres with Tomcat for development, since Jetty is no longer the default embedded server.
I think you can substitute /web-app/WEB-INF /jetty-env.xml with an equivalent web-app/META-INF/context.xml that emulates Steve's point 4. See Tomcat 6 Context bullet points I've managed to get Glassfish V3 working find for the production environment, (by tweaking another app - the petclinic to use JNDI) but can't seem to get the Tomcat Development setup correctly Datasource.groovy looks like this: dataSource { pooled = false // JNDI across the board Connection pooling handled by Jetty?? and Glassfish dbCreate = 'update' } hibernate { cache.use_second_level_cache=true cache.use_query_cache=true cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider' } // environment specific settings environments { development { dataSource { jndiName = 'java:comp/env/jdbc/GrailsContacts' } } test { dataSource { url = 'jdbc:hsqldb:mem:testDb' driverClassName = 'org.hsqldb.jdbcDriver' username = 'sa' password = '' } } production { dataSource { jndiName = 'jdbc/GrailsContacts' } } } context.xml looks like this: <Context reloadable="true" crossContext="true"> <Resource name="jdbc/GrailsContacts" auth="Container" type="javax.sql.DataSource" username="grails" password="grails" driverClassName="org.postgresql.ds.PGSimpleDataSource" url="jdbc:postgresql://localhost:5432/grails" /> </Context> When I attempt to do a grails run-app I get: Welcome to Grails 1.3.0.BUILD-SNAPSHOT - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: /opt/grails/grails Base Directory: /Users/JGF/Documents/workspace-sts-2.3.0.RELEASE/GrailsContacts Resolving dependencies... Dependencies resolved in 1602ms. Running script /opt/grails/grails/scripts/RunApp.groovy Environment set to development [delete] Deleting directory /Users/JGF/.grails/1.3.0.BUILD-SNAPSHOT/projects/GrailsContacts/tomcat Running Grails application.. 2010-02-02 20:00:23,242 [main] ERROR context.ContextLoader - Context initialization failed 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) 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:287) 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:115) 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_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 23 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 23 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 23 more Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) ... 23 more 2010-02-02 20:00:23,243 [main] ERROR [localhost].[/GrailsContacts] - 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 '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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) 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:287) 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:115) 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_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 23 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 23 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 23 more Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) ... 23 more 2010-02-02 20:00:23,243 [main] ERROR core.StandardContext - Error listenerStart 2010-02-02 20:00:23,250 [main] ERROR core.StandardContext - Context [/GrailsContacts] startup failed due to previous errors Server running. Browse to http://localhost:8080/GrailsContacts [groovyc] Compiling 1 source file to /Users/JGF/Documents/workspace-sts-2.3.0.RELEASE/GrailsContacts/target/classes [delete] Deleting directory /Users/JGF/.grails/1.3.0.BUILD-SNAPSHOT/projects/GrailsContacts/tomcat Running Grails application.. 2010-02-02 20:37:23,180 [main] ERROR context.ContextLoader - Context initialization failed 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) at grails.web.container.EmbeddableServer$start$0.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:287) 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:115) at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) at RunApp$_run_closure1.doCall(RunApp.groovy:35) at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 28 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 28 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 28 more Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) ... 28 more 2010-02-02 20:37:23,181 [main] ERROR [localhost].[/GrailsContacts] - 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 '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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) at grails.web.container.EmbeddableServer$start$0.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:287) 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:115) at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) at RunApp$_run_closure1.doCall(RunApp.groovy:35) at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 28 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 28 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 28 more Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) ... 28 more 2010-02-02 20:37:23,182 [main] ERROR core.StandardContext - Error listenerStart 2010-02-02 20:37:23,183 [main] ERROR core.StandardContext - Context [/GrailsContacts] startup failed due to previous errors Server running. Browse to http://localhost:8080/GrailsContacts [groovyc] Compiling 1 source file to /Users/JGF/Documents/workspace-sts-2.3.0.RELEASE/GrailsContacts/target/classes [delete] Deleting directory /Users/JGF/.grails/1.3.0.BUILD-SNAPSHOT/projects/GrailsContacts/tomcat Running Grails application.. 2010-02-02 20:39:48,109 [main] ERROR context.ContextLoader - Context initialization failed 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) at grails.web.container.EmbeddableServer$start$0.call(Unknown Source) at grails.web.container.EmbeddableServer$start$0.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:287) 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:115) at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) at RunApp$_run_closure1.doCall(RunApp.groovy:35) at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 29 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 29 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 29 more Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) ... 29 more 2010-02-02 20:39:48,113 [main] ERROR [localhost].[/GrailsContacts] - 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 '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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) at grails.web.container.EmbeddableServer$start$0.call(Unknown Source) at grails.web.container.EmbeddableServer$start$0.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:287) 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:115) at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) at RunApp$_run_closure1.doCall(RunApp.groovy:35) at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) 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': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 29 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 29 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context ... 29 more Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) ... 29 more 2010-02-02 20:39:48,116 [main] ERROR core.StandardContext - Error listenerStart 2010-02-02 20:39:48,117 [main] ERROR core.StandardContext - Context [/GrailsContacts] startup failed due to previous errors Server running. Browse to http://localhost:8080/GrailsContacts Can someone tell me what I'm doing wrong here? I think Grails puts the results of run-app into the {USER_HOME}/.grails/{GRAILS_VERSION}/projects/GrailsContacts folder. But this is new territory to me. I'll see if I can ascertain what's going on from that in the meantime. |
|
OK - I started writing this and then notice you're doing a run-app in
development mode - I can only talk about deploying Grails 1.2/Postgres/Tomcat 6 a production war. In DataSource.groovy you have it correct in development for Tomcat: jndiName = "java:comp/env/jdbc/GrailsContacts" In the tomcat context (and I'm using a separate one for each app in $CATALINA_HOME/conf/Catalina/localhost/<war-name>.xml) I'm using: driverClassName="org.postgresql.Driver" I _think_ you also need (and I have this): bash-3.2$ cat scripts/_Event.groovy import groovy.xml.StreamingMarkupBuilder if (Environment.current == Environment.PRODUCTION) { eventWebXmlEnd = {String tmpfile -> def root = new XmlSlurper().parse(webXmlFile) // add the data source root.appendNode { 'resource-ref'{ 'description'('The JNDI Database resource') 'res-ref-name'('jdbc/GrailsContacts') 'res-type'('javax.sql.DataSource') 'res-auth'('Application') } } webXmlFile.text = new StreamingMarkupBuilder().bind { mkp.declareNamespace("": "http://java.sun.com/xml/ns/j2ee") mkp.yield(root) } } } Like I said, I haven't done this in a "run-app". Good luck. On 2 February 2010 23:01, Jeremy Flowers <[hidden email]> wrote: > > I've had a look at a couple of blog posts from > http://blogs.bytecode.com.au/glen/2008/07/24/grails--jetty--glassfish-and-jndi-data-sources.html > Glen Smith and > http://refactor.com.au/blog/idiots-guide-tomcat-6-grails-jndi-datasource > Steve Dalton and tried to merge the two for using Postgres with Tomcat for > development, since Jetty is no longer the default embedded server. > I think you can substitute /web-app/WEB-INF /jetty-env.xml with an > equivalent web-app/META-INF/context.xml that emulates Steve's point 4. See > http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Tomcat 6 Context > bullet points > > I've managed to get Glassfish V3 working find for the production > environment, (by tweaking another app - the petclinic to use JNDI) but can't > seem to get the Tomcat Development setup correctly > > Datasource.groovy looks like this: > > dataSource { > pooled = false // JNDI across the board Connection pooling handled by > Jetty?? and Glassfish > dbCreate = 'update' > } > hibernate { > cache.use_second_level_cache=true > cache.use_query_cache=true > cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider' > } > // environment specific settings > environments { > development { > dataSource { > jndiName = 'java:comp/env/jdbc/GrailsContacts' > } > } > test { > dataSource { > url = 'jdbc:hsqldb:mem:testDb' > driverClassName = 'org.hsqldb.jdbcDriver' > username = 'sa' > password = '' > } > } > production { > dataSource { > jndiName = 'jdbc/GrailsContacts' > } > } > } > > context.xml looks like this: > > <Context > reloadable="true" crossContext="true"> > > <Resource name="jdbc/GrailsContacts" > auth="Container" > type="javax.sql.DataSource" > username="grails" > password="grails" > driverClassName="org.postgresql.ds.PGSimpleDataSource" > url="jdbc:postgresql://localhost:5432/grails" > /> > </Context> > > When I attempt to do a grails run-app I get: > > Welcome to Grails 1.3.0.BUILD-SNAPSHOT - http://grails.org/ > Licensed under Apache Standard License 2.0 > Grails home is set to: /opt/grails/grails > > Base Directory: > /Users/JGF/Documents/workspace-sts-2.3.0.RELEASE/GrailsContacts > Resolving dependencies... > Dependencies resolved in 1602ms. > Running script /opt/grails/grails/scripts/RunApp.groovy > Environment set to development > [delete] Deleting directory > /Users/JGF/.grails/1.3.0.BUILD-SNAPSHOT/projects/GrailsContacts/tomcat > Running Grails application.. > 2010-02-02 20:00:23,242 [main] ERROR context.ContextLoader - Context > initialization failed > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) > 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:287) > 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:115) > 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_closure4.doCall(Gant.groovy:324) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) > at gant.Gant.withBuildListeners(Gant.groovy:344) > at gant.Gant.this$2$withBuildListeners(Gant.groovy) > at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) > at gant.Gant.dispatch(Gant.groovy:334) > at gant.Gant.this$2$dispatch(Gant.groovy) > at gant.Gant.invokeMethod(Gant.groovy) > at gant.Gant.processTargets(Gant.groovy:495) > at gant.Gant.processTargets(Gant.groovy:480) > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 23 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sessionFactory': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 23 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'dataSource': Invocation of init method failed; > nested exception is javax.naming.NameNotFoundException: Name jdbc is not > bound in this Context > ... 23 more > Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in > this Context > at org.apache.naming.NamingContext.lookup(NamingContext.java:770) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:153) > at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > ... 23 more > 2010-02-02 20:00:23,243 [main] ERROR [localhost].[/GrailsContacts] - > 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 '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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) > 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:287) > 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:115) > 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_closure4.doCall(Gant.groovy:324) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) > at gant.Gant.withBuildListeners(Gant.groovy:344) > at gant.Gant.this$2$withBuildListeners(Gant.groovy) > at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) > at gant.Gant.dispatch(Gant.groovy:334) > at gant.Gant.this$2$dispatch(Gant.groovy) > at gant.Gant.invokeMethod(Gant.groovy) > at gant.Gant.processTargets(Gant.groovy:495) > at gant.Gant.processTargets(Gant.groovy:480) > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 23 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sessionFactory': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 23 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'dataSource': Invocation of init method failed; > nested exception is javax.naming.NameNotFoundException: Name jdbc is not > bound in this Context > ... 23 more > Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in > this Context > at org.apache.naming.NamingContext.lookup(NamingContext.java:770) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:153) > at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > ... 23 more > 2010-02-02 20:00:23,243 [main] ERROR core.StandardContext - Error > listenerStart > 2010-02-02 20:00:23,250 [main] ERROR core.StandardContext - Context > [/GrailsContacts] startup failed due to previous errors > Server running. Browse to http://localhost:8080/GrailsContacts > [groovyc] Compiling 1 source file to > /Users/JGF/Documents/workspace-sts-2.3.0.RELEASE/GrailsContacts/target/classes > [delete] Deleting directory > /Users/JGF/.grails/1.3.0.BUILD-SNAPSHOT/projects/GrailsContacts/tomcat > Running Grails application.. > 2010-02-02 20:37:23,180 [main] ERROR context.ContextLoader - Context > initialization failed > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) > at grails.web.container.EmbeddableServer$start$0.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:287) > 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:115) > at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) > at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) > at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) > at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) > at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) > at RunApp$_run_closure1.doCall(RunApp.groovy:35) > at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) > at gant.Gant.withBuildListeners(Gant.groovy:344) > at gant.Gant.this$2$withBuildListeners(Gant.groovy) > at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) > at gant.Gant.dispatch(Gant.groovy:334) > at gant.Gant.this$2$dispatch(Gant.groovy) > at gant.Gant.invokeMethod(Gant.groovy) > at gant.Gant.processTargets(Gant.groovy:495) > at gant.Gant.processTargets(Gant.groovy:480) > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 28 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sessionFactory': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 28 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'dataSource': Invocation of init method failed; > nested exception is javax.naming.NameNotFoundException: Name jdbc is not > bound in this Context > ... 28 more > Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in > this Context > at org.apache.naming.NamingContext.lookup(NamingContext.java:770) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:153) > at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > ... 28 more > 2010-02-02 20:37:23,181 [main] ERROR [localhost].[/GrailsContacts] - > 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 '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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) > at grails.web.container.EmbeddableServer$start$0.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:287) > 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:115) > at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) > at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) > at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) > at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) > at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) > at RunApp$_run_closure1.doCall(RunApp.groovy:35) > at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) > at gant.Gant.withBuildListeners(Gant.groovy:344) > at gant.Gant.this$2$withBuildListeners(Gant.groovy) > at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) > at gant.Gant.dispatch(Gant.groovy:334) > at gant.Gant.this$2$dispatch(Gant.groovy) > at gant.Gant.invokeMethod(Gant.groovy) > at gant.Gant.processTargets(Gant.groovy:495) > at gant.Gant.processTargets(Gant.groovy:480) > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 28 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sessionFactory': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 28 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'dataSource': Invocation of init method failed; > nested exception is javax.naming.NameNotFoundException: Name jdbc is not > bound in this Context > ... 28 more > Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in > this Context > at org.apache.naming.NamingContext.lookup(NamingContext.java:770) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:153) > at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > ... 28 more > 2010-02-02 20:37:23,182 [main] ERROR core.StandardContext - Error > listenerStart > 2010-02-02 20:37:23,183 [main] ERROR core.StandardContext - Context > [/GrailsContacts] startup failed due to previous errors > Server running. Browse to http://localhost:8080/GrailsContacts > [groovyc] Compiling 1 source file to > /Users/JGF/Documents/workspace-sts-2.3.0.RELEASE/GrailsContacts/target/classes > [delete] Deleting directory > /Users/JGF/.grails/1.3.0.BUILD-SNAPSHOT/projects/GrailsContacts/tomcat > Running Grails application.. > 2010-02-02 20:39:48,109 [main] ERROR context.ContextLoader - Context > initialization failed > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) > at grails.web.container.EmbeddableServer$start$0.call(Unknown Source) > at grails.web.container.EmbeddableServer$start$0.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:287) > 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:115) > at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) > at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) > at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) > at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) > at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) > at RunApp$_run_closure1.doCall(RunApp.groovy:35) > at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) > at gant.Gant.withBuildListeners(Gant.groovy:344) > at gant.Gant.this$2$withBuildListeners(Gant.groovy) > at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) > at gant.Gant.dispatch(Gant.groovy:334) > at gant.Gant.this$2$dispatch(Gant.groovy) > at gant.Gant.invokeMethod(Gant.groovy) > at gant.Gant.processTargets(Gant.groovy:495) > at gant.Gant.processTargets(Gant.groovy:480) > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 29 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sessionFactory': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 29 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'dataSource': Invocation of init method failed; > nested exception is javax.naming.NameNotFoundException: Name jdbc is not > bound in this Context > ... 29 more > Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in > this Context > at org.apache.naming.NamingContext.lookup(NamingContext.java:770) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:153) > at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > ... 29 more > 2010-02-02 20:39:48,113 [main] ERROR [localhost].[/GrailsContacts] - > 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 '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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:135) > at grails.web.container.EmbeddableServer$start$0.call(Unknown Source) > at grails.web.container.EmbeddableServer$start$0.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:287) > 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:115) > at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) > at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:257) > at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) > at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:293) > at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) > at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:242) > at RunApp$_run_closure1.doCall(RunApp.groovy:35) > at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) > at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) > at gant.Gant.withBuildListeners(Gant.groovy:344) > at gant.Gant.this$2$withBuildListeners(Gant.groovy) > at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) > at gant.Gant.dispatch(Gant.groovy:334) > at gant.Gant.this$2$dispatch(Gant.groovy) > at gant.Gant.invokeMethod(Gant.groovy) > at gant.Gant.processTargets(Gant.groovy:495) > at gant.Gant.processTargets(Gant.groovy:480) > 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': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 29 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'sessionFactory': Cannot resolve reference to bean > 'dataSource' while setting bean property 'dataSource'; nested exception is > org.springframework.beans.factory.BeanCreationException: Error creating bean > with name 'dataSource': Invocation of init method failed; nested exception > is javax.naming.NameNotFoundException: Name jdbc is not bound in this > Context > ... 29 more > Caused by: org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'dataSource': Invocation of init method failed; > nested exception is javax.naming.NameNotFoundException: Name jdbc is not > bound in this Context > ... 29 more > Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in > this Context > at org.apache.naming.NamingContext.lookup(NamingContext.java:770) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:140) > at org.apache.naming.NamingContext.lookup(NamingContext.java:781) > at org.apache.naming.NamingContext.lookup(NamingContext.java:153) > at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) > at javax.naming.InitialContext.lookup(InitialContext.java:392) > ... 29 more > 2010-02-02 20:39:48,116 [main] ERROR core.StandardContext - Error > listenerStart > 2010-02-02 20:39:48,117 [main] ERROR core.StandardContext - Context > [/GrailsContacts] startup failed due to previous errors > Server running. Browse to http://localhost:8080/GrailsContacts > > Can someone tell me what I'm doing wrong here? > > I think Grails puts the results of run-app into the > {USER_HOME}/.grails/{GRAILS_VERSION}/projects/GrailsContacts folder. But > this is new territory to me. > I'll see if I can ascertain what's going on from that in the meantime. > -- > View this message in context: http://n4.nabble.com/Questions-about-JNDI-JDBC-for-Tomcat-Postgres-Grails-working-off-1-3-0-BUILD-SNAPSHOT-tp1460546p1460546.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > -- http://worldofnic.org --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Hi Nic.
I'll have a play around with this. 1) I noticed a comment at the foot of Steve Dalton's post that mentioned scripts/_Event.groovy wasn't required and I'm a fan of the KISS rule. ![]() 2) I also remember doing stuff with Tomcat, JNDI & MySQL some years back and experiencing all sorts of pain then! I posted a solution on Server-side. I'm wondering if I'm missing something from that.
3) I also think there's some new DSL stuff going on from the Tomcat Plug-in wiki revolving around grails.naming.entries in grails-app/conf/Config.groovy and grails-app/conf/spring/resources.groovy (incorrect path on wiki! ) to define beans in the jee namespace.
I did see a JIRA post that sort of made sense of the "bar" part of config.groovy from the Tomcat Plug-in wiki on Grails.org but I can't see why you have to suddenly jump through all these hoops when DataSource.groovy should suffice. 4)I know JNDI can be used for things other than Datasources, but what I can't currently fathom is why DataSource.groovy with the jndiName can't do this on it's own with Tomcat, as it does for Glassfish. I'm assuming resources.groovy is for the Spring beans. So I'm a bit confused as to the web.xml in Steve's post vs applicationContext.xml on the Tomcat Plugin wiki. I'll have to get my Java/Spring books out and have a get my head around this.
5) I also suspect that in the Glen Smith post, you'd end up with the Jetty jetty-env.xml in your Glassfish war. I'd have a redundant config.xml too, which is kind of untidy. I'm wondering how I'd tweak that elegantly if I get things working. |
|
Right. I think I have the answer to part of the riddle.
I hiked out my old Core JSF book that I used when I was setting up Tomcat in the past, per my server-side post back in June 2008.
It seems Glassfish is an odd beast. It doesn't use resource-ref node in the web.xml. Instead Glassfish uses an artefact called sun-web.xml that goes in the WEB-INF folder instead. I'm guessing when you setup your JNDI resources in the Glassfish admin console, it creates the sun-web.xml for you, and hence you don't need to deploy this with the WAR. So, indeed the web.xml will need a bit of manipulation per Steve Dalton's blog post. I would love to hear from Christian Sonne Jensen as to how you can avoid modifying web.xml since as far as I am aware you DO need to do this!
|
|
I just thought you guys you like to know that the grails application I've
been developing for the last few months has entered the final rounds of QA testing as is expected to be deployed at the end of the month. If you're interested it's an application that manages customer licenses for various encrypted voice communication products that the company I work full time for sells. It features Shiro authentication and permissions system that works on a hierarchical set of company domain objects, each with their own child domain objects (users, licenses, etc). It's a regular web app with a clean and simple xhtml UI behind which hides a complex collection of custom validation rules in the 18 domain classes. Alas unless you're a customer of the company I work for you won't get to see the user interface as it hides behind a login system with closed registration. Many thanks to the grails core developers, plugin developers, bug reporters, bloggers and mailing list users without which I'd of had a much harder time. Once it's deployed I'll update an appropriate page on the grails wiki with a link. Cheers! Dominic Clifton --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Congrats!
On Wed, Feb 3, 2010 at 9:52 AM, Dominic Clifton <[hidden email]> wrote: I just thought you guys you like to know that the grails application I've |
| Powered by Nabble | Edit this page |
