我的Grails部署到Tomcat容器有什么问题?

我的Grails部署到Tomcat容器有什么问题?,tomcat,grails,amazon-ec2,Tomcat,Grails,Amazon Ec2,我发现了一个问题,即我的Grails3Web应用程序无法在我们已成功部署Grails2Web应用程序的EC2实例上正确启动。这个Grails2应用程序已经升级到Grails3,现在正是这个问题的根源 我使用的Grails版本是3.2.4。EC2实例上使用的Tomcat版本是8.0.20。另外,JVM版本是1.8.031 war文件是使用Grails命令Grails package构建的(我不确定这和Grails-war是否有区别,因为其他Grails 3.2.4应用程序使用此命令可以很好地打包和

我发现了一个问题,即我的Grails3Web应用程序无法在我们已成功部署Grails2Web应用程序的EC2实例上正确启动。这个Grails2应用程序已经升级到Grails3,现在正是这个问题的根源

我使用的Grails版本是3.2.4。EC2实例上使用的Tomcat版本是8.0.20。另外,JVM版本是1.8.031

war文件是使用Grails命令
Grails package
构建的(我不确定这和
Grails-war
是否有区别,因为其他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模式下复制生产
数据源
配置。项目仍然使用qa模式正确启动,并具有相同的
数据源属性。我没有在Tomcat日志中看到这个问题

我还阅读了几次文档(特别是部署部分),并确保将
spring boot starter tomcat
依赖项的行更改为build.gradle中提供的
org.springframework.boot:spring boot starter tomcat
,因为我没有使用嵌入式tomcat


在做了更多的研究之后,我仍然不确定是什么导致了这个问题。也许我忽略了与Tomcat的某些不兼容之处。有人有什么想法吗?任何帮助都将不胜感激。谢谢。

这是grails v.3.2.4中的一个bug。
问题在于我的应用程序配置和不兼容的插件。application.yml和application.groovy都包含
hibernate
块。我还有一个旧版本的插件
数据库迁移
(1.4.0)。一旦我删除了application.yml中的
hibernate
块并删除了
数据库迁移
插件,应用程序就成功部署了。如果您想在Grails 3项目中使用
数据库迁移
插件,可以使用2.x版本,根据文档:。

我已经看到了这个问题。这看起来像是在嵌入式Tomcat上发生的。一位评论员提到,在将WAR部署到Tomcat时,它是有效的,但在为我将WAR部署到Tomcat时,它似乎失败了。我还没有在日志中看到FileNotFoundException。也许我可以尝试升级Spring Boot。你尝试升级grails了吗?我还没有尝试升级。我们还有另一个Grails3.2.4项目,我们已经成功地将其部署到Tomcat容器中,我们现在正在进行的特定项目已经在定制qa模式/环境中进行了端到端测试。当我们在这种定制模式下部署到qatomcat容器时,它可以工作。所以,我希望现在继续使用相同的版本,并弄清楚在生产模式下运行时会发生什么。