繁体   English   中英

无法在Amazon EC2实例上运行war文件

[英]Unable to run war file on Amazon EC2 instance

我正在使用最新的Angular 7开发Spring Boot应用程序。我已经创建了一个构建并生成了war文件。

我已经在其中配置了一个文件夹,其结构为:

project-tool.war
config/application-prod.yml
config/application-dev.yml
config/application.yml
run.sh 
run.bat

在run.sh/run.bat中,这些命令写为-> java -jar project-tool.war --spring.profiles.active = prod --spring.config.location = config \\ application-prod.yml

我已经在AWS上创建了Oracle数据库实例,并将配置放在application-prod.yml中。

然后,我已经在Windows OS上使用war文件运行了该项目,效果很好。

我必须在Amazon EC2实例上运行此war文件。 因此,我已将此文件夹上传到EC2中型实例上。 当我运行它时,它抛出一个错误:

2019-03-02 06:50:53.489 ERROR 3082 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService' defined in URL [jar:file:/home/ec2-user/theProject/project-tool.war!/WEB-INF/classes!/com/myProject/security/DomainUserDetailsService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'auditLogService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'auditLogService' defined in URL [jar:file:/home/ec2-user/theProject/project-tool.war!/WEB-INF/classes!/com/myProject/service/AuditLogService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'auditLogRepository': Cannot create inner bean '(inner bean)#44dbafd9' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#44dbafd9': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: IO Error: The Network Adapter could not establish the connection
2019-03-02 06:50:53.551  WARN 3082 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [oracle.jdbc.driver.BlockSource.ThreadedCachingBlockSource.BlockReleaser] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaser.run(BlockSource.java:327)
2019-03-02 06:50:53.556  WARN 3082 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

我也有另一个实例和其他项目(spring和angularJS)以类似的方式很好地工作。 但是为什么这不起作用,命令或角度有问题吗?

如何在Amazon EC2上工作?

您在这里读取错误堆栈跟踪的问题是数据库连接。 请注意核心错误消息无法初始化池:IO错误:网络适配器无法建立连接

我不知道oracle数据库的配置方式,但是您可能在数据库侦听器配置方面遇到了问题,或者更简单地说,我可以建议尝试在安全组和网络配置上查看EC2和Oracle Database实例之间的网络通信。 问题不是Angular,而是您的应用程序与数据库之间的数据库链接。

希望对您有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM