简体   繁体   English

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

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

I am working on a spring boot application with latest Angular 7. I have created a build and generated war file. 我正在使用最新的Angular 7开发Spring Boot应用程序。我已经创建了一个构建并生成了war文件。

I have configured a folder in this the structure is : 我已经在其中配置了一个文件夹,其结构为:

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

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

I have created Oracle database instance on AWS and put the configuration in application-prod.yml. 我已经在AWS上创建了Oracle数据库实例,并将配置放在application-prod.yml中。

Then I have run this project using the war file on Windows OS, it works fine. 然后,我已经在Windows OS上使用war文件运行了该项目,效果很好。

I have to run this war file on Amazon EC2 instance. 我必须在Amazon EC2实例上运行此war文件。 So I have uploaded this folder on EC2 medium instance. 因此,我已将此文件夹上传到EC2中型实例上。 As I run this, it throws an error : 当我运行它时,它抛出一个错误:

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

I also have another instance and other project working (spring and angularJS) fine in a similar manner. 我也有另一个实例和其他项目(spring和angularJS)以类似的方式很好地工作。 But why this not working, is there any issue with the command or with angular? 但是为什么这不起作用,命令或角度有问题吗?

How to work it on Amazon EC2? 如何在Amazon EC2上工作?

the your problem here reading your error stack trace is the database connection. 您在这里读取错误堆栈跟踪的问题是数据库连接。 Pay attention to the core error message Failed to initialize pool: IO Error: The Network Adapter could not establish the connection 请注意核心错误消息无法初始化池:IO错误:网络适配器无法建立连接

I don't know how the oracle database is configured but probably you have a problem with database listener configuration or more simply whit the network communication between your EC2 and Oracle Database instance i can suggest to try to see on the security group and network configuration. 我不知道oracle数据库的配置方式,但是您可能在数据库侦听器配置方面遇到了问题,或者更简单地说,我可以建议尝试在安全组和网络配置上查看EC2和Oracle Database实例之间的网络通信。 The problem is not Angular but the database link between your app and the database. 问题不是Angular,而是您的应用程序与数据库之间的数据库链接。

I hope that this can help you 希望对您有所帮助

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

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