daifuku1011
@daifuku1011

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

Spring Bootフレームワークを使用したWebアプリケーションでエラーが出る

解決したいこと

デプロイしたWebアプリケーションが正常に動作するようにしたい。

AmazonなどのECサイトに自分が出品している商品を管理するWebアプリを作っています。
Eclipse上で実行すると正常に動作しますが、デプロイ後、「localhost:8080/App名/」にアクセスしてもWhitelabel Error Pageが表示されてしまいます。
解決方法を教えていただけませんでしょうか。

当方初心者のため、情報に不足等あるかと思いますので、ぜひご指摘いただけますと幸いです。

言語:Java (jdk20)
フレームワーク:SpringBoot(ver.3.1.2) + Thymeleaf
ORマッパー:Mybatis
ビルド:Gradle
IDE:Eclipse
デプロイ環境(ローカル):Docker(Ubuntu) tomcatコンテナを立てて.warファイルを配置
tomcat:10.1-jdk21

発生している問題・エラー

エラーが発生した際のDocker Logsを添付します。

2023-10-15T10:24:39.811Z ERROR 1 --- [nio-8080-exec-1] o.s.b.w.servlet.support.ErrorPageFilter  : Forwarding to error page from request [/] due to exception [Class com.fasterxml.jackson.core.JsonGenerator$Feature does not have member field 'com.fasterxml.jackson.core.JsonGenerator$Feature WRITE_HEX_UPPER_CASE']

java.lang.NoSuchFieldError: Class com.fasterxml.jackson.core.JsonGenerator$Feature does not have member field 'com.fasterxml.jackson.core.JsonGenerator$Feature WRITE_HEX_UPPER_CASE'
        at com.fasterxml.jackson.core.json.JsonWriteFeature.<clinit>(JsonWriteFeature.java:86) ~[jackson-core-2.15.2.jar:na]
        at org.thymeleaf.standard.serializer.StandardJavaScriptSerializer$JacksonStandardJavaScriptSerializer.<init>(StandardJavaScriptSerializer.java:161) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.standard.serializer.StandardJavaScriptSerializer.<init>(StandardJavaScriptSerializer.java:118) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.standard.StandardDialect.getJavaScriptSerializer(StandardDialect.java:310) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.standard.StandardDialect.getExecutionAttributes(StandardDialect.java:398) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.spring6.dialect.SpringStandardDialect.getExecutionAttributes(SpringStandardDialect.java:325) ~[thymeleaf-spring6-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.DialectSetConfiguration.build(DialectSetConfiguration.java:263) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.EngineConfiguration.<init>(EngineConfiguration.java:123) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.TemplateEngine.initialize(TemplateEngine.java:341) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.TemplateEngine.getConfiguration(TemplateEngine.java:411) ~[thymeleaf-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.spring6.view.ThymeleafView.renderFragment(ThymeleafView.java:263) ~[thymeleaf-spring6-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.thymeleaf.spring6.view.ThymeleafView.render(ThymeleafView.java:192) ~[thymeleaf-spring6-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1415) ~[spring-webmvc-6.0.11.jar:6.0.11]
        at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1159) ~[spring-webmvc-6.0.11.jar:6.0.11]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1098) ~[spring-webmvc-6.0.11.jar:6.0.11]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974) ~[spring-webmvc-6.0.11.jar:6.0.11]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) ~[spring-webmvc-6.0.11.jar:6.0.11]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) ~[spring-webmvc-6.0.11.jar:6.0.11]
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) ~[servlet-api.jar:6.0]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.0.11.jar:6.0.11]
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) ~[servlet-api.jar:6.0]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[catalina.jar:10.1.13]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-websocket.jar:10.1.13]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[catalina.jar:10.1.13]
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.0.11.jar:6.0.11]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.11.jar:6.0.11]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[catalina.jar:10.1.13]
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.0.11.jar:6.0.11]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.11.jar:6.0.11]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[catalina.jar:10.1.13]
        at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:124) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:99) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.11.jar:6.0.11]
        at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:117) ~[spring-boot-3.1.2.jar:3.1.2]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[catalina.jar:10.1.13]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-6.0.11.jar:6.0.11]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.11.jar:6.0.11]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[catalina.jar:10.1.13]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[catalina.jar:10.1.13]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[catalina.jar:10.1.13]
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673) ~[catalina.jar:10.1.13]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[catalina.jar:10.1.13]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) ~[catalina.jar:10.1.13]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) ~[tomcat-coyote.jar:10.1.13]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-coyote.jar:10.1.13]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894) ~[tomcat-coyote.jar:10.1.13]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1740) ~[tomcat-coyote.jar:10.1.13]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-coyote.jar:10.1.13]
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-util.jar:10.1.13]
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-util.jar:10.1.13]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:10.1.13]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]

エラーの内容からロジックというよりは、依存関係やJavaのバージョンなどの問題ではないかと考えました。
念のため、build.gradleの内容を記載します。

plugins {
	id 'java'
	id 'org.springframework.boot' version '3.1.2'
	id 'io.spring.dependency-management' version '1.1.2'
	id 'war'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
	sourceCompatibility = '20'
}

configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
    mavenCentral()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
	compileOnly 'org.projectlombok:lombok'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
	implementation ('org.springframework.boot:spring-boot-starter-web') {
  		exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
	}

	// https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java
	implementation group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'

	// https://mvnrepository.com/artifact/org.apache.poi/poi
	implementation 'org.apache.poi:poi-ooxml:5.2.2'

    // https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter
	implementation group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '3.0.1'
	runtimeOnly 'org.postgresql:postgresql'
	
	implementation files('/lib/amazon/sellingpartnerapi-aa-java-1.0.jar')
	implementation files('/lib/amazon/Sellers_JavaCL-1.0.jar')
	implementation files('/lib/amazon/productPricingV0_JavaCL-1.0.jar')
	implementation files('/lib/amazon/catalogItems_2022-04-01-1.0.jar')
	                   
	// https://mvnrepository.com/artifact/org.threeten/threetenbp
	implementation group: 'org.threeten', name: 'threetenbp', version: '1.5.0'

	// https://mvnrepository.com/artifact/io.gsonfire/gson-fire
	implementation group: 'io.gsonfire', name: 'gson-fire', version: '1.8.0'
	
	// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
	implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
	
	// https://mvnrepository.com/artifact/com.alibaba/fastjson
	implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.83'
}

tasks.named('test') {
	useJUnitPlatform()
}

自分で試したこと

①どのファイルに問題があるのかを切り分けるため、新規プロジェクトを作成し、ファイルを一つずつ移してデプロイし、正常に動作するかを検証
 ・entity、resources(html,cssなど)、controllerはすべてに問題がないことを確認
 ・Service、DAOの一部は問題ないことを確認しているが、まだすべてを切り分けられていない(対応中)
②Dockerのtomcatのバージョンを変えて正常に動作するかを確認
 ・ver.9 以下はSpringBoot ver.3 以上非対応(?)のため、ver.10以上に変更
 ・10.1-jdk17でデプロイ後実行すると404エラーが発生
③build.gradleの依存関係で指定していたjackson-databaindのバージョンを2.12.5に変更⇒エラー解消なし
 バージョン指定削除(SpringBootデフォルト利用)⇒エラー解消なし

implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.2'
0

No Answers yet.

Your answer might help someone💌