[증상]

JDK24에서 mvn 실행시 아래와 같은 경고가 발생하고 프로젝트 빌드에 실패함

$ mvn clean spring-boot:run -Dspring-boot.run.profiles=local
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper (file:/opt/homebrew/Cellar/maven/3.9.9/libexec/lib/guava-33.2.1-jre.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------< com.demo:sample >----------------
[INFO] Building sample 3.4.3-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] Could not transfer metadata com.soundicly:jnanoid-enhanced:main-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [kpc-private (http://nexus.kpcard.co.kr/repository/maven-kpc-private-repositories/, default, releases+snapshots), kpc-public (http://nexus.kpcard.co.kr/repository/maven-public/, default, releases+snapshots)]
[WARNING] com.soundicly:jnanoid-enhanced:main-SNAPSHOT/maven-metadata.xml failed to transfer from http://0.0.0.0/ during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: Could not transfer metadata com.soundicly:jnanoid-enhanced:main-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [kpc-private (http://nexus.kpcard.co.kr/repository/maven-kpc-private-repositories/, default, releases+snapshots), kpc-public (http://nexus.kpcard.co.kr/repository/maven-public/, default, releases+snapshots)]
[INFO] 
[INFO] --- clean:3.4.1:clean (default-clean) @ sample ---
[INFO] Deleting /Users/deepfree/development/workspace-java/sample/target
[INFO] 
[INFO] >>> spring-boot:3.4.3:run (default-cli) > test-compile @ sample >>>
[INFO] 
[INFO] --- spring-boot:3.4.3:build-info (build-info) @ sample ---
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ sample ---
[INFO] Copying 19 resources from src/main/resources to target/classes
[INFO] Copying 71 resources from src/main/resources to target/classes
[INFO] 
[INFO] --- compiler:3.13.0:compile (default-compile) @ sample ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 101 source files with javac [debug parameters release 21] to target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.145 s
[INFO] Finished at: 2025-04-02T17:57:08+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project sample: Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTag :: UNKNOWN -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

 

[원인]

경고내용은 maven 3.9.9가 guava 33.2.1-jre.jar를 사용하는데 해당 버전의 guava가 terminally deprecated된 sun.misc.Unsafe를 호출한다는 내용입니다

 

guava에는 이미 이슈 "Migrate off Unsafe (guava-jre)"(https://github.com/google/guava/issues/6806)가 보고되어 guava-jre에처 처리되었는데 maven 3.9.9가 오래된 guava를 사용해서 발생하는 문제로 보입니다

 

해당 maven의 이슈도 Apache에 보고되어 https://issues.apache.org/jira/browse/MNG-8399?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&focusedCommentId=17939366 에서 찾을 수 있고, 4일전에 아래와 같은 댓글이 달려있고 maven에서 사용하는 guava 종속성을 업드레이드 할것으로 보입니다

 

[해결]

현재는 maven 하위의 file:/opt/homebrew/Cellar/maven/3.9.9/libexec/lib/guava-33.2.1-jre.jar 에 있는 guava library를 최신 버전으로 교체해볼수 있겠지만, maven 도구가 JDK 24에서 문제가 없게 라이브러리 종속성을 업데이트하면 maven을 업그레이드하면 될것으로 판단됩니다

 

추후 mavan 3.3.9에서 3.3.10이 릴리즈되면 확인해보고 이 게시물을 수정해 놓아야 겠습니다

 

 

[증상]

maven으로 잘 빌드되던 프로젝트에서 JDK 24를 설치후 빌드시 아래와 같은 경고가 발생하고 빌드에 실패함

$ mvn clean install -U -Dmaven.test.skip=true
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by org.fusesource.jansi.internal.JansiLoader in an unnamed module (file:/opt/homebrew/Cellar/maven/3.9.9/libexec/lib/jansi-2.4.1.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper (file:/opt/homebrew/Cellar/maven/3.9.9/libexec/lib/guava-33.2.1-jre.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------< com.demo:sample >--------------
[INFO] Building sample 3.4.3-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- clean:3.4.1:clean (default-clean) @ sample ---
[INFO] Deleting /Users/deepfree/development/workspace-java/sample/target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.171 s
[INFO] Finished at: 2025-04-02T17:40:52+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.4.1:clean (default-clean) on project sample: Failed to clean project: Failed to delete /Users/deepfree/development/workspace-java/sample/target/generated-sources/annotations -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

 

뿐만 아니라 mvn의 버전만 확인해도 동일한 경고 발생

// mvn 도구에서 제한된 메소드 java.lang.System이 호출되었다는 경고
$ mvn --version                                                                                          1 ↵  10037  17:35:22
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by org.fusesource.jansi.internal.JansiLoader in an unnamed module (file:/opt/homebrew/Cellar/maven/3.9.9/libexec/lib/jansi-2.4.1.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec
Java version: 24, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-24.jdk/Contents/Home
Default locale: ko_KR, platform encoding: UTF-8
OS name: "mac os x", version: "15.3.2", arch: "aarch64", family: "mac"

// root 권한으로 실행시 정상
$ sudo mvn --version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec
Java version: 23.0.2, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: ko_KR, platform encoding: UTF-8
OS name: "mac os x", version: "15.3.2", arch: "aarch64", family: "mac"

 

[원인]

maven 도구의 jansi가 console에서 Ansi를 사용하기 위해 시스템에 접근해서 해당 이슈가 발생하는 것으로 판단됨

maven/3.9.9/libexec/lib/jansi-2.4.1.jar

 

[해결방안]

maven 3에서:

# MAVEN_OPTS 지정
export MAVEN_OPTS="--enable-native-access=ALL-UNNAMED"

 

zsh에 기본으로 적용하려면 ~/.zshrc 에 위의 설정을 적용하면 기본 쉘환경에 적용됨

현재 열려있는 쉘에 적용하려면 source ~/.zshrc 를 실행하여 적용

 

maven 4에서:

해당 이슈가 Apache Maven 프로젝트에 보고되어 https://issues.apache.org/jira/browse/MNG-8399?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&focusedCommentId=17939366 에서 찾을 수 있고, jansi는 maven 4에서 더이상 이슈가 되지 않는다는 4일전에 작성된 댓글에서 확인이 가능합니다

 

maven 4에서는 "--enable-native-access=ALL-UNNAMED" 옵션 지정이 필요없을 것으로 보입니다

하지만 아직 brew에는 maven 3.9.9까지만 배포되고 있습니다

[증상]

IDE (vscode, sts, eclipse)가 아닌 cli에서 maven compile시 annotationProcessor가 적용되지 않아 compile error가 발생하는 경우

$ mvn clean compile

 

공식홈페이지에는 아래와 같이 설정하면 된다고 나와 있는데, 해당 방식으로 동작하지 않음

Adding lombok to your pom file

To include lombok as a 'provided' dependency, add it to your <dependencies> block like so:

<dependencies>
	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<version>1.18.36</version>
		<scope>provided</scope>
	</dependency>
</dependencies>

JDK9+ with module-info.java

The configuration of the compiler plug-in should contain the following:

<annotationProcessorPaths>
	<path>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<version>1.18.36</version>
	</path>
</annotationProcessorPaths>

 

공식사이트: https://projectlombok.org/setup/maven

 

[해결방안]

pom.xml의 maven-compiler-plugin에 명시적으로 annotationProcessorPaths를 적용

<project>
  <build>
    <plugins>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
          <annotationProcessorPaths>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${lombok.version}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>
      
    <plugins>      
  <build>
<project>

[증상]

"Spring Boot 3.4"로 업데이트 후 "java.lang.IllegalStateException: No target Validator set" 에러가 발생

Caused by: java.lang.IllegalStateException: No target Validator set
	at org.springframework.util.Assert.state(Assert.java:79) ~[spring-core-6.2.3.jar:6.2.3]
Assert.java:79
	at org.springframework.validation.beanvalidation.SpringValidatorAdapter.forExecutables(SpringValidatorAdapter.java:402) ~[spring-context-6.2.3.jar:6.2.3]
SpringValidatorAdapter.java:402
	at org.springframework.validation.beanvalidation.MethodValidationAdapter.invokeValidatorForArguments(MethodValidationAdapter.java:259) ~[spring-context-6.2.3.jar:6.2.3]
	at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:168) ~[spring-context-6.2.3.jar:6.2.3]
MethodValidationInterceptor.java:168
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.2.3.jar:6.2.3]
ReflectiveMethodInvocation.java:184
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:727) ~[spring-aop-6.2.3.jar:6.2.3]
CglibAopProxy.java:727

 

 

[분석]

Spring Boot 3.4에서 Configuration Properties의 Bean Validation이 변화됨


https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.4-Release-Notes#bean-validation-of-configuration-properties

 

[해결]

기존에 포함되어 있던 org.hibernate.validator:hibernate-validator 종속성에 

추가로 org.apache.tomcat.embed:tomcat-embed-el 종속성을 추가하여 해결함

    <dependency>
      <groupId>org.hibernate.validator</groupId>
      <artifactId>hibernate-validator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat.embed</groupId>
      <artifactId>tomcat-embed-el</artifactId>
    </dependency>

 

[참고]

spring-boot-starter-validation의 소스를 참고 했음

https://github.com/spring-projects/spring-boot/blob/3.4.x/spring-boot-project/spring-boot-starters/spring-boot-starter-validation/build.gradle

 

 

+ Recent posts