我看到一个问题,即我们的Grails 3 Web应用程序在我们成功部署了Grails 2 Web应用程序的EC2实例上未正确启动。这个相同的Grails 2应用程序已经升级到Grails 3,现在正在引发这个问题。我的Grails部署到Tomcat容器时出了什么问题?
我正在使用的Grails版本是3.2.4。在EC2实例上使用的Tomcat版本是8.0.20。另外,JVM版本是1.8.0_31。
战争文件是使用Grails命令grails package
(我不确定是否与其他Grails 3.2.4应用程序使用此命令打包并部署得很好)之间存在差异,然后该文件是随后的放入Tomcat webapps目录。
这是我看到的启动Tomcat的时候问题:
Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsCacheFilter': Cannot create inner bean '(inner bean)#2fb114b8' 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)#2fb114b8': 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 java.lang.NullPointerException
这发生在我打包,部署和使用唯一的生产模式下启动应用程序。我尝试在本地设置Tomcat 8容器中的项目,在不同的EC2实例上以qa模式设置项目,并且在从我尝试部署的生产实例生成的映像启动的EC2实例上以qa模式设置项目至。我无法重现这些问题。
我认为application.groovy生产环境块中的dataSource
可能导致问题。由于此特定项目不依赖于数据库,因此我尝试删除该项目并再次以生产模式在生产实例上部署Web应用程序,但我仍面临同样的问题。
我也尝试在qa模式下复制生产dataSource
配置。该项目仍使用qa模式正确启动,具有相同的dataSource
属性。我没有看到问题出现在Tomcat日志中。
我也读了几次文档(特别是部署部分),并且确保将spring-boot-starter-tomcat
依赖关系的行更改为build.gradle中的provided "org.springframework.boot:spring-boot-starter-tomcat"
,因为我没有使用嵌入式Tomcat。
在做了一些更多的研究之后,我仍然不确定可能导致此问题的原因。也许有一些与Tomcat不兼容,我忽略了。有没有人有任何想法?任何帮助将不胜感激。谢谢。
我看到过这个问题。这看起来像嵌入式Tomcat一样。一位评论者提到它在WAR部署到Tomcat时有效,但是在为我部署WAR到Tomcat时似乎失败了。我也没有在我的日志中看到FileNotFoundException。也许我可以尝试升级Spring Boot。 – Nick
您是否尝试升级Grails? –
我还没有尝试过升级。我们有另一个Grails 3.2。4项目,我们已经成功部署到Tomcat容器,并且我们正在开发的特定项目现在已经在自定义qa模式/环境中进行了端对端测试。当我们在此自定义模式下部署到qa Tomcat容器时,它可以正常工作。因此,我希望现在能够坚持使用相同的版本,并在生产模式下运行时了解正在发生的事情。 – Nick