前提・実現したいこと
初学者です。Java(Spring Boot使用)のプログラムのwarファイルを作成し、
AWSのElastic Beanstalkにデプロイした後、リンクを開くと、しばらく時間が経過した後に、「このページを表示できません」と出ます。
ログのエラー中にDB接続関係に問題がありそうだと思うのですが、関係しそうなキーワードでググってもなかなか検討がつかないので、ご教示いただけると嬉しいです。
DBはMySQLを使用しています。
発生している問題・エラーメッセージ
web-1.log(var/log/)
2020-03-30 07:47:36.836 INFO 13488 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on ip-172-31-13-69 with PID 13488 (/var/app/current/application.jar started by webapp in /var/app/current) 2020-03-30 07:47:36.852 INFO 13488 --- [ main] com.example.demo.DemoApplication : The following profiles are active: aws_ebs 2020-03-30 07:47:39.360 INFO 13488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2020-03-30 07:47:39.784 INFO 13488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 392ms. Found 1 JPA repository interfaces. 2020-03-30 07:47:40.319 WARN 13488 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.example.demo]' package. Please check your configuration. 2020-03-30 07:47:41.135 INFO 13488 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$2bed8dad] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2020-03-30 07:47:41.221 INFO 13488 --- [ main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0] 2020-03-30 07:47:42.211 INFO 13488 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 5000 (http) 2020-03-30 07:47:42.241 INFO 13488 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2020-03-30 07:47:42.245 INFO 13488 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.31] 2020-03-30 07:47:42.491 INFO 13488 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2020-03-30 07:47:42.492 INFO 13488 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5529 ms 2020-03-30 07:47:43.918 INFO 13488 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2020-03-30 07:47:45.281 ERROR 13488 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.2.jar!/:na] at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) ~[HikariCP-3.4.2.jar!/:na] at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) ~[HikariCP-3.4.2.jar!/:na] ~一部省略~ Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_242] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_242] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_242] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_242] at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.19.jar!/:8.0.19] at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~ ... 59 common frames omitted 2020-03-30 07:47:45.401 INFO 13488 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2020-03-30 07:47:45.703 INFO 13488 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final 2020-03-30 07:47:46.071 INFO 13488 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final} 2020-03-30 07:47:46.348 INFO 13488 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
該当のソースコード
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.5.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> <vaadin.version>14.1.18</vaadin.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jersey</artifactId> </dependency> ~一部省略~ <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web-services</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>6.11.0</version> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-bom</artifactId> <version>${vaadin.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <executable>false</executable> </configuration> </plugin> </plugins> </build> </project>
試したこと
・EC2インスタンスの終了と新規作成
・該当のセキュリティグループのインバウンドルールをMYSQL/Auroraに変更し、ポート範囲を3306に変更
・application.ymlに「server: port: 5000」を追記
※ちなみに下記がdatesourceの記述です。
datasource: driver-class-name: "com.mysql.cj.jdbc.Driver" url: "jdbc:mysql://localhost:3306/hp_sample?serverTimezone=JST" username: "XXXXX" password: "XXXXX"
補足情報
Java: 1.8
Spring Boot: 2.2.5
OS: Windows7
IDE: Eclipse 2019-12 (4.14.0)
回答1件
あなたの回答
tips
プレビュー