본문 바로가기
오류해결

[오류해결] jakarta.servlet.ServletException: Handler dispatch failed: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

by devthrive 2024. 1. 6.
SMALL

유튜브 서타몽님의

https://www.youtube.com/@jiraynorprogramming1589

 

서타몽

 

www.youtube.com

SpringBoot + Reactjs(ts) + MySQL] 로그인 API 구현을 따라하면서 마지막 PostMan으로 로그인을 했을시

아래와 같은 에러가 뜬다.

(jdk 17사용)

VSC에러

 

 

PostMan Error

에러를 검색 해보니 JAXB API가 java11에서부터는 완전히 제거 되었다고한다.

그래서 의존성 주입으로 인해 모듈을 추가를 해줘야 했다.

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.boot:spring-boot-starter-validation'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
	compileOnly 'org.projectlombok:lombok'
	runtimeOnly 'com.mysql:mysql-connector-j'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'org.springframework.security:spring-security-test'
}

기존 dependencies

 

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.boot:spring-boot-starter-validation'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
	implementation 'javax.xml.bind:jaxb-api:2.3.0'
	compileOnly 'org.projectlombok:lombok'
	runtimeOnly 'com.mysql:mysql-connector-j'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'org.springframework.security:spring-security-test'
}
implementation "javax.xml.bind:jaxb-api:2.3.0" 추가
 
 
PostMan확인후 잘됨.

참고

https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception

 

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

I have some code that uses JAXB API classes which have been provided as a part of the JDK in Java 6/7/8. When I run the same code with Java 9, at runtime I get errors indicating that JAXB classes ...

stackoverflow.com

 

LIST