2017-04-08 214 views
1

我試圖將Grails 3應用程序部署到Elastic Beanstalk上的Tomcat 8實例,並嘗試了一些我在Google和Stack Exchange上找到的東西,包括將「org.springframework.boot:spring-boot-starter-tomcat」依賴從「compile」更改爲「provided」,這不起作用。 Elastic Beanstalk將接受戰爭文件,但只是顯示一個空白頁面。在Elastic Beanstalk上將Grails 3應用程序部署到Tomcat 8

我打開了Grails製作的war文件,發現WEB-INF下的基本目錄或web.xml文件中沒有index.jsp文件。這兩個存在於我使用Maven web-app原型製作的簡單war文件中,這個文件很有用,所以我有兩個問題:

1)是否有其他人從最新版本的Grails部署應用程序到Tomcat 8?特別是在Elastic Beanstalk上,特別是最近呢?我從谷歌搜索中發現的大多數答案都很舊,所以我想可能是新版本發生了變化。

2)打開一個WAR文件並加載它時,Tomcat 8經歷的過程的最佳參考是什麼?我想如果我能深入研究這個過程,我可以找出缺失的部分在哪裏。

+0

我們在eB上部署了grails 3,但我們只是使用獨立的jar和java的EB配置文件。 – erichelgeson

+0

我發現同樣的問題不知道如何使它工作 – Denny

+0

我結束了剛剛恢復到Grails 2.3.7,似乎工作正常。 –

回答

0

@約翰斯坦福,我發現了同樣的問題,我的Grails的版本是3.2.3

我已經測試部署到我的地方tomcat8,發現我的數據源配置的原因這個問題,我的Grails應用就是虛擬應用程序,無需數據庫連接,

日誌/var/lib/tomcat8/logs/catalina.2017-xx-xx.log顯示如下

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsCacheFilter': Cannot create inner bean '(inner bean)#7cbf54fc' of type [grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter] while setting bean property 'filter'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#7cbf54fc': Unsatisfied dependency expressed through method 'setUrlMappingsHandlerMapping' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'urlMappingsHandlerMapping': Unsatisfied dependency expressed through method 'setWebRequestInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openSessionInViewInterceptor': Cannot resolve reference to bean 'hibernateDatastore' while setting bean property 'hibernateDatastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313) 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1486) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1231) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 
     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:202) 

所以我註釋掉production.dataSource。 application.yml的網址

environments: 
    development: 
     dataSource: 
      dbCreate: create-drop 
      url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE 
    test: 
     dataSource: 
      dbCreate: update 
      url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE 
    production: 
     grails: 
      serverURL: http://xxx-evn-yyy-zzzz-aws-zone-2.elasticbeanstalk.com 
     dataSource: 
      dbCreate: none 
      #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 

並最終部署到AWS Beanstalk,它的工作原理!

+0

看來tomcat8上的AWS beanstalk可能並不完全支持H2數據庫,所以部署進程被破壞,結果返回爲空白頁 – Denny

相關問題