Cotrariello
Cotrariello

Reputation: 71

heroku grails bootstrap error

heroku ps
=== web (1X): `java $JAVA_OPTS -jar server/webapp-runner.jar $RUNNER_OPTS --port
$PORT target/*.war`
web.1: up 2014/01/15 12:03:40 (~ 35s ago)

heroku logs
←[36m2014-01-15T11:02:17.943114+00:00 app[web.1]:←[0m Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into user (version, cognome, data_registrazione, data_ultima_visita, email, nome, password, id) values ('0', 'pagliaro', '2014-01-15 11:02:02.721000 +00:00:00', '2014-01-15 11:02:02.721000 +00:00:00', '[email protected]', 'carmine', 'carmine', '13') was aborted.  Call getNextException to see the cause.
←[36m2014-01-15T11:02:17.943114+00:00 app[web.1]:←[0m   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
←[36m2014-01-15T11:02:17.943114+00:00 app[web.1]:←[0m   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
←[36m2014-01-15T11:02:17.943114+00:00 app[web.1]:←[0m 2014-01-15 11:02:17,942 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Could not execute JDBC batch update←[36m2014-01-15T11:02:17.943114+00:00 app[web.1]:←[0m   at java.util.concurrent.FutureTask.run(FutureTask.java:166)
←[36m2014-01-15T11:02:17.943114+00:00 app[web.1]:←[0m   at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2586)
←[36m2014-01-15T11:02:17.943114+00:00 app[web.1]:←[0m   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1811)
←[36m2014-01-15T11:02:17.943313+00:00 app[web.1]:←[0m   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
←[36m2014-01-15T11:02:17.943313+00:00 app[web.1]:←[0m   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2725)
←[36m2014-01-15T11:02:17.943313+00:00 app[web.1]:←[0m   ... 5 more
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m   at java.util.concurrent.FutureTask.run(FutureTask.java:166)
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m 2014-01-15 11:02:17,950 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing Grails: Could not execute JDBC batch update
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m   at java.lang.Thread.run(Thread.java:679)
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into user (version, cognome, data_registrazione, data_ultima_visita, email, nome, password, id) values ('0', 'pagliaro', '2014-01-15 11:02:02.721000 +00:00:00', '2014-01-15 11:02:02.721000 +00:00:00', '[email protected]', 'carmine', 'carmine', '13') was aborted.  Call getNextException to see the cause.
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m   at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2586)
←[36m2014-01-15T11:02:17.951250+00:00 app[web.1]:←[0m   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1811)
←[36m2014-01-15T11:02:17.951453+00:00 app[web.1]:←[0m   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
←[36m2014-01-15T11:02:17.951453+00:00 app[web.1]:←[0m   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2725)
←[36m2014-01-15T11:02:17.951453+00:00 app[web.1]:←[0m   ... 5 more
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:18 AM org.apache.catalina.core.StandardContext listenerStart
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m   at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:125)
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
←[36m2014-01-15T11:02:18.123014+00:00 app[web.1]:←[0m   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   at java.util.concurrent.FutureTask.run(FutureTask.java:166)
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   at java.lang.Thread.run(Thread.java:679)
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   ... 5 more
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into user (version, cognome, data_registrazione, data_ultima_visita, email, nome, password, id) values ('0', 'pagliaro', '2014-01-15 11:02:02.721000 +00:00:00', '2014-01-15 11:02:02.721000 +00:00:00', '[email protected]', 'carmine', 'carmine', '13') was aborted.  Call getNextException to see the cause.
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2586)
←[36m2014-01-15T11:02:18.123199+00:00 app[web.1]:←[0m   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1811)
←[36m2014-01-15T11:02:18.123376+00:00 app[web.1]:←[0m   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
←[36m2014-01-15T11:02:18.123376+00:00 app[web.1]:←[0m   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2725)
←[36m2014-01-15T11:02:18.123376+00:00 app[web.1]:←[0m   ... 5 more
←[36m2014-01-15T11:02:18.137665+00:00 app[web.1]:←[0m SEVERE: Error listenerStart
←[36m2014-01-15T11:02:18.137665+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:18 AM org.apache.catalina.core.StandardContext startInternal
←[36m2014-01-15T11:02:18.899520+00:00 app[web.1]:←[0m INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [255] milliseconds.
←[36m2014-01-15T11:02:18.899520+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:18 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
←[36m2014-01-15T11:02:18.951493+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:18 AM org.apache.catalina.core.StandardContext startInternal
←[36m2014-01-15T11:02:18.951493+00:00 app[web.1]:←[0m SEVERE: Context [] startup failed due to previous errors
←[36m2014-01-15T11:02:19.312325+00:00 app[web.1]:←[0m SEVERE: Context [] failed in [org.apache.catalina.core.StandardContext] lifecycle. Allowing Tomcat to shutdown.
←[36m2014-01-15T11:02:19.372549+00:00 app[web.1]:←[0m INFO: Closing Spring root WebApplicationContext
←[36m2014-01-15T11:02:19.372549+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:19 AM org.apache.catalina.core.ApplicationContext log
←[36m2014-01-15T11:02:20.339546+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:20 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
←[36m2014-01-15T11:02:20.340004+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:20 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
←[36m2014-01-15T11:02:20.340004+00:00 app[web.1]:←[0m SEVERE: The web application [] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
←[36m2014-01-15T11:02:20.339546+00:00 app[web.1]:←[0m SEVERE: The web application [] registered the JDBC driver [org.h2.Driver] but failed to unregister it when
the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
←[36m2014-01-15T11:02:20.529184+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:20 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
←[36m2014-01-15T11:02:20.529808+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:20 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
←[36m2014-01-15T11:02:20.529808+00:00 app[web.1]:←[0m SEVERE: The web application [] appears to have started a thread named [net.sf.ehcache.CacheManager@6e6bb83] but has failed to stop it. This is very likely to create a memory leak.
←[36m2014-01-15T11:02:20.529184+00:00 app[web.1]:←[0m SEVERE: The web application [] appears to have started a thread named [PoolCleaner[1190000432:1389783669731]] but has failed to stop it. This is very likely to create a memory leak.
←[36m2014-01-15T11:02:22.895509+00:00 app[web.1]:←[0m Jan 15, 2014 11:02:22 AM org.apache.coyote.AbstractProtocol start
←[36m2014-01-15T11:02:22.895509+00:00 app[web.1]:←[0m INFO: Starting ProtocolHandler ["http-nio-27068"]
 ←[36m2014-01-15T11:02:24.607697+00:00 heroku[web.1]:←[0m Process exited with status 0
←[36m2014-01-15T11:02:24.621923+00:00 heroku[web.1]:←[0m State changed from up to crashed
←[33m2014-01-15T11:02:23.547203+00:00 heroku[router]:←[0m at=error code=H13 desc="Connection closed without response" method=GET path=/favicon.ico host=quiet-mountain-7475.herokuapp.com fwd="212.189.150.207" dyno=web.1 connect=1ms service=10043ms status=503 bytes=0
←[36m2014-01-15T11:03:35.509975+00:00 heroku[web.1]:←[0m State changed from crashed to starting
←[36m2014-01-15T11:03:41.997055+00:00 heroku[web.1]:←[0m Starting process with command `java -Xmx384m -Xss512k -XX:+UseCompressedOops -jar server/webapp-runner.jar $RUNNER_OPTS --port 9702 target/*.war`
←[36m2014-01-15T11:03:43.084014+00:00 app[web.1]:←[0m Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
←[36m2014-01-15T11:03:43.374328+00:00 app[web.1]:←[0m Adding Context  for target/smat-0.1.war
←[36m2014-01-15T11:03:43.969693+00:00 app[web.1]:←[0m INFO: Initializing ProtocolHandler ["http-nio-9702"]
←[36m2014-01-15T11:03:43.969693+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:43 AM org.apache.coyote.AbstractProtocol init
←[36m2014-01-15T11:03:43.997117+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:43 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
←[36m2014-01-15T11:03:43.997117+00:00 app[web.1]:←[0m INFO: Using a shared selector for servlet write/read
←[36m2014-01-15T11:03:43.999623+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:43 AM org.apache.catalina.core.StandardService startInternal
←[36m2014-01-15T11:03:43.999623+00:00 app[web.1]:←[0m INFO: Starting service Tomcat
←[36m2014-01-15T11:03:43.999801+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:43 AM org.apache.catalina.core.StandardEngine startInternal
←[36m2014-01-15T11:03:43.999801+00:00 app[web.1]:←[0m INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
←[36m2014-01-15T11:03:44.492597+00:00 heroku[web.1]:←[0m State changed from starting to up
←[36m2014-01-15T11:03:45.566828+00:00 app[web.1]:←[0m INFO: No global web.xml found
←[36m2014-01-15T11:03:45.566828+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:45 AM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
←[36m2014-01-15T11:03:57.632903+00:00 app[web.1]:←[0m INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
←[36m2014-01-15T11:03:57.632903+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:57 AM org.apache.catalina.startup.TaglibUriRule body
←[36m2014-01-15T11:03:57.721705+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:57 AM org.apache.catalina.startup.TaglibUriRule body
←[36m2014-01-15T11:03:57.721705+00:00 app[web.1]:←[0m INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
←[36m2014-01-15T11:03:58.264002+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:58 AM org.apache.catalina.startup.TaglibUriRule body
←[36m2014-01-15T11:03:58.263099+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:58 AM org.apache.catalina.startup.TaglibUriRule body
←[36m2014-01-15T11:03:58.263099+00:00 app[web.1]:←[0m INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
←[36m2014-01-15T11:03:58.264002+00:00 app[web.1]:←[0m INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
←[36m2014-01-15T11:03:59.457413+00:00 app[web.1]:←[0m INFO: No Spring WebApplicationInitializer types detected on classpath
←[36m2014-01-15T11:03:59.457413+00:00 app[web.1]:←[0m Jan 15, 2014 11:03:59 AM org.apache.catalina.core.ApplicationContext log
←[36m2014-01-15T11:04:00.319796+00:00 app[web.1]:←[0m Jan 15, 2014 11:04:00 AM org.apache.catalina.core.ApplicationContext log
←[36m2014-01-15T11:04:00.319796+00:00 app[web.1]:←[0m INFO: Initializing Spring root WebApplicationContext
←[36m2014-01-15T11:04:18.242112+00:00 app[web.1]:←[0m 2014-01-15 11:04:18,241 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport  - ERROR: syntax error at or near "user"
←[36m2014-01-15T11:04:18.242034+00:00 app[web.1]:←[0m 2014-01-15 11:04:18,231 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport  - Unsuccessful: create table user (id int8 not null, version int8 not null, cognome varchar(255) not null, data_registrazione timestamp not null, data_ultima_visita timestamp not null, email varchar(255) not null, nome varchar(255) not null, password varchar(255) not null, primary key (id))
←[36m2014-01-15T11:04:18.242112+00:00 app[web.1]:←[0m   Position: 14
←[36m2014-01-15T11:04:18.969316+00:00 app[web.1]:←[0m   Position: 92
←[36m2014-01-15T11:04:18.969316+00:00 app[web.1]:←[0m 2014-01-15 11:04:18,969 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport  - Unsuccessful: alter table ruolo_users add constraint FKA8A9FED8A0B81B3B foreign key (user_id) references user
←[36m2014-01-15T11:04:18.969316+00:00 app[web.1]:←[0m 2014-01-15 11:04:18,969 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport  - ERROR: syntax error at or near "user"

well, when I try to lunch my app on heroku with this code:

new Ruolo(nome:"user").save()
new User(cognome:"pagliaro", dataRegistrazione: new Date(), dataUltimaVisita: new    Date() ,email:"[email protected]", nome:"carmine", password:"carmine").save().addToRoles(ruolo)

I have got the problem above;

when i try it without that code it works fine.

Upvotes: 0

Views: 374

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75681

"user" is a reserved word in Postgres, see http://www.postgresql.org/docs/9.3/static/sql-keywords-appendix.html

Any table or column named "user" needs to be renamed or escaped. You can escape by using the backtick character, which will cause Hibernate to escape using the correct approach for the current database. So a domain class named User would need to escape the table name:

class User {
   ...
   static mapping = {
      table '`user`' // or 'users'
   }
}

and a property named "user" would need to escape the column name:

class SomeOtherClass {
   String user
   ...
   static mapping = {
      user column: '`user`'
   }
}

But note that in this class you don't need to escape the name:

class YetAnotherClass {
   User user
   ...
}

because this will use a foreign key and the column name will be "user_id".

Upvotes: 1

Related Questions