2016-05-09 16 views
1

を開始できませんでしたが、私はこのエラーを乗り越えることができません:これはGrails run-app:タスク ':bootRun'の実行に失敗しました。エラー:GradleのでbootRunをやろうとしているサーバー

buildscript { 
    ext { 
     grailsVersion = project.grailsVersion 
    } 
    repositories { 
     mavenLocal() 
     maven { url "http://localhost:8081/nexus/content/groups/public/" } 
    } 
    dependencies { 
     classpath "org.grails:grails-gradle-plugin:$grailsVersion" 
     classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.7.4" 
     classpath "org.grails.plugins:hibernate4:5.0.2" 
    classpath "org.grails.plugins:database-migration:2.0.0.RC4" 
    } 
} 

version "1.0.0-SNAPSHOT" 
group "qotd" 

apply plugin:"eclipse" 
apply plugin:"idea" 
apply plugin:"war" 
apply plugin:"org.grails.grails-web" 
apply plugin:"org.grails.grails-gsp" 
apply plugin:"asset-pipeline" 
apply plugin:"base" 
apply plugin:"java" 
apply plugin:"maven" 

ext { 
    grailsVersion = project.grailsVersion 
    gradleWrapperVersion = project.gradleWrapperVersion 
} 

repositories { 
    mavenLocal() 
     maven { url "http://localhost:8081/nexus/content/groups/public/" } 
} 

dependencyManagement { 
    imports { 
     mavenBom "org.grails:grails-bom:$grailsVersion" 
    } 
    applyMavenExclusions false 
} 

dependencies { 
    compile "org.springframework.boot:spring-boot-starter-logging" 
    compile "org.springframework.boot:spring-boot-autoconfigure" 
    compile "org.grails:grails-core" 
    compile "org.springframework.boot:spring-boot-starter-actuator" 
    compile "org.springframework.boot:spring-boot-starter-tomcat" 
    compile "org.grails:grails-dependencies" 
    compile "org.grails:grails-web-boot" 
    compile "org.grails.plugins:cache" 
    compile "org.grails.plugins:scaffolding" 
    compile "org.grails.plugins:hibernate4" 
    compile "org.hibernate:hibernate-ehcache" 
    console "org.grails:grails-console" 
    profile "org.grails.profiles:web:3.1.4" 
    runtime "org.grails.plugins:asset-pipeline" 
    runtime "com.h2database:h2" 
    runtime "org.grails.plugins:database-migration:2.0.0.RC4" 
    testCompile "org.grails:grails-plugin-testing" 
    testCompile "org.grails.plugins:geb" 
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" 
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18" 
} 
uploadArchives{ 
    repositories{ 
     mavenDeployer{ 
      repository(
      url: "${nexusUrl}/content/repositories/releases"){ 
       authentication(userName: nexusUsername, 
          password: nexusPassword) 
      } 
      snapshotRepository(
      url: "${nexusUrl}/content/repositories/snapshots"){ 
       authentication(userName: nexusUsername, 
          password: nexusPassword) 
      } 
     } 
    } 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = gradleWrapperVersion 
} 

assets { 
    minifyJs = true 
    minifyCss = true 
} 

sourceSets{ 
    main{ 
     resources{ 
      srcDir 'grails-app/migrations' 
    } 
    } 
} 

| Running application... 
objc[1566]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined. 
INFO 5/9/16 4:10 PM: liquibase: Successfully acquired change log lock 
INFO 5/9/16 4:10 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG 
SEVERE 5/9/16 4:10 PM: liquibase: changelog.groovy: week-5A.groovy::1462469938896-1::Marco (generated): Change Set week-5A.groovy::1462469938896-1::Marco (generated) failed. Error: Table "QUOTE" already exists; SQL statement: 
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))] 
liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement: 
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))] 
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:301) 
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55) 
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:107) 
    at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1251) 
    at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1234) 
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:554) 
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51) 
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) 
    at liquibase.Liquibase.update(Liquibase.java:212) 
    at liquibase.Liquibase.update(Liquibase.java:192) 
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434) 
    at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:80) 
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) 
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:55) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:365) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:354) 
    at grails.boot.GrailsApp$run.call(Unknown Source) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) 
    at qotd.Application.main(Application.groovy:8) 
Caused by: org.h2.jdbc.JdbcSQLException: Table "QUOTE" already exists; SQL statement: 
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] 
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) 
    at org.h2.message.DbException.get(DbException.java:179) 
    at org.h2.message.DbException.get(DbException.java:155) 
    at org.h2.command.ddl.CreateTable.update(CreateTable.java:115) 
    at org.h2.command.CommandContainer.update(CommandContainer.java:98) 
    at org.h2.command.Command.executeUpdate(Command.java:258) 
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:184) 
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158) 
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:299) 
    ... 35 more 
INFO 5/9/16 4:10 PM: liquibase: week-5A.groovy::1462469938896-1::Marco (generated): Successfully released change log lock 
ERROR org.springframework.boot.SpringApplication - Application startup failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springLiquibase_dataSource': Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set week-5A.groovy::1462469938896-1::Marco (generated): 
    Reason: liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement: 
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) 
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:55) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:365) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:354) 
    at grails.boot.GrailsApp$run.call(Unknown Source) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) 
    at qotd.Application.main(Application.groovy:8) 
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set week-5A.groovy::1462469938896-1::Marco (generated): 
    Reason: liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement: 
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))] 
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:590) 
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51) 
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) 
    at liquibase.Liquibase.update(Liquibase.java:212) 
    at liquibase.Liquibase.update(Liquibase.java:192) 
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434) 
    at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:80) 
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) 
    ... 21 common frames omitted 
Caused by: liquibase.exception.DatabaseException: Table "QUOTE" already exists; SQL statement: 
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))] 
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:301) 
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55) 
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:107) 
    at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1251) 
    at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1234) 
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:554) 
    ... 30 common frames omitted 
Caused by: org.h2.jdbc.JdbcSQLException: Table "QUOTE" already exists; SQL statement: 
CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] 
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) 
    at org.h2.message.DbException.get(DbException.java:179) 
    at org.h2.message.DbException.get(DbException.java:155) 
    at org.h2.command.ddl.CreateTable.update(CreateTable.java:115) 
    at org.h2.command.CommandContainer.update(CommandContainer.java:98) 
    at org.h2.command.Command.executeUpdate(Command.java:258) 
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:184) 
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158) 
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:299) 
    ... 35 common frames omitted 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':bootRun'. 
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
| Error Failed to start server (Use --stacktrace to see the full trace) 

これは私のbuild.gradleファイルです毎週段階的に構築されるクラスのプロジェクトです。今週は、ドメインオブジェクトモデルを更新し、データベースの移行を実行します。私が試した

--- 
hibernate: 
    cache: 
     queries: false 
     use_second_level_cache: true 
     use_query_cache: false 
     region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory' 

dataSource: 
    pooled: true 
    jmxExport: true 
    driverClassName: org.h2.Driver 
    username: sa 
    password: 

environments: 
    development: 
     dataSource: 
      dbCreate: "" 
      url: jdbc:h2:./quoteDB;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=TRUE 
     grails: 
      plugin: 
       databasemigration: 
        updateOnStart: true 
        updateOnStartFileNames: [changelog.groovy] 
    test: 
     dataSource: 
      dbCreate: update 
      url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE 
    production: 
     dataSource: 
      dbCreate: update 
      url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE 
      properties: 
       jmxEnabled: true 
       initialSize: 5 
       maxActive: 50 
       minIdle: 5 
       maxIdle: 25 
       maxWait: 10000 
       maxAge: 600000 
       timeBetweenEvictionRunsMillis: 5000 
       minEvictableIdleTimeMillis: 60000 
       validationQuery: SELECT 1 
       validationQueryTimeout: 3 
       validationInterval: 15000 
       testOnBorrow: true 
       testWhileIdle: true 
       testOnReturn: false 
       jdbcInterceptors: ConnectionState 
       defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED 

--- 
--- 
grails: 
    profile: web 
    codegen: 
     defaultPackage: qotd 
    spring: 
     transactionManagement: 
      proxies: false 
info: 
    app: 
     name: '@[email protected]' 
     version: '@[email protected]' 
     grailsVersion: '@[email protected]' 
spring: 

    groovy: 
     template: 
      check-template-location: false 

--- 
grails: 
    mime: 
     disable: 
      accept: 
       header: 
        userAgents: 
         - Gecko 
         - WebKit 
         - Presto 
         - Trident 
     types: 
      all: '*/*' 
      atom: application/atom+xml 
      css: text/css 
      csv: text/csv 
      form: application/x-www-form-urlencoded 
      html: 
       - text/html 
       - application/xhtml+xml 
      js: text/javascript 
      json: 
       - application/json 
       - text/json 
      multipartForm: multipart/form-data 
      pdf: application/pdf 
      rss: application/rss+xml 
      text: text/plain 
      hal: 
       - application/hal+json 
       - application/hal+xml 
      xml: 
       - text/xml 
       - application/xml 
    urlmapping: 
     cache: 
      maxsize: 1000 
    controllers: 
     defaultScope: singleton 
    converters: 
     encoding: UTF-8 
    views: 
     default: 
      codec: html 
     gsp: 
      encoding: UTF-8 
      htmlcodec: xml 
      codecs: 
       expression: html 
       scriptlets: html 
       taglib: none 
       staticparts: none 
endpoints: 
    jmx: 
     unique-names: true 

物事:

この

は、アプリケーションファイルである

  1. gradle clean assemble
  2. 再起動するコンピュータ
  3. 必ず私の$ JAVA_HOME変数が正しく設定された作り
  4. データベースファイルの削除(教授による)
  5. ないすでに使用中のアドレスの場合(手動pidを使用して確認してください)外観を取るための

ありがとう! Hibernateは、フローとしてのSQL文 を実行しようとすると、

+1

スタックトレースを読んでください。何が起きているのかははっきりしています。 –

+0

私にヒントを教えてもらえますか?おそらく 'エラー:テーブル"クォート "既に存在する" – mmera

+0

@BurtBeckwithこれは入門コースなので、スタックトレースを読む方法はわかりません。どんな助けもありがとうございます。ありがとう! – mmera

答えて

2

問題は、私のchangelogスクリプトとweek-5aスクリプトの両方が同じことをしてデータベースを作成していたことでした。 changelogの中には、include file: 'week-5A.groovy'というコード行がありました。したがって、changelogが実行されると、データベースが作成され、同じことを実行していた週5Aが実行され、例外がスローされました。

0

CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id)) [42101-191] [Failed SQL: CREATE TABLE PUBLIC.quote (id BIGINT AUTO_INCREMENT NOT NULL, version BIGINT NOT NULL, text VARCHAR(255) NOT NULL, CONSTRAINT quotePK PRIMARY KEY (id))] 

データベースは "PUBLIC.quote" という名前のこのテーブルを見つけた存在です。

「データベースの自動移行」オプションが正しくない可能性があります。開発環境の "dbCreate"オプションを "update"に設定する

+0

ありがとうございますが、どちらもうまくいきませんでした...問題は「エラー:テーブル」です。「既に存在しています」しかし、私はそれを修正する方法を知らないXD – mmera

関連する問題