scouter icon indicating copy to clipboard operation
scouter copied to clipboard

Spring boot에서 실행하면 java.lang.NoClassDefFoundError: scouter/agent/trace/TraceMain Error 발생해요.

Open catius-io opened this issue 1 year ago • 4 comments

java version : java 11 spring boot : 2.2.0

intelliJ vm 설정

image

error stack trace

 ____                  _            
 / ___|  ___ ___  _   _| |_ ___ _ __ 
 \___ \ / __/   \| | | | __/ _ \ '__|
  ___) | (_| (+) | |_| | ||  __/ |   
 |____/ \___\___/ \__,_|\__\___|_|                                      
 Open Source S/W Performance Monitoring  
 Scouter version 2.17.1
 
20230406 19:23:56 [SCOUTER] Version 2.17.1 2022-03-27 04:35 GMT_ENV_java8plus
20230406 19:23:56 [SCOUTER] loaded by app classloader 
20230406 19:23:56 [SCOUTER] jar:file:/D:/dev/git/dialog-admin-service/scouter/scouter-agent.jar
20230406 19:23:56 [SCOUTER] objType:java
20230406 19:23:56 [SCOUTER] objName:/LAPTOP-VEDMAAF7/WAS-01
20230406 19:23:56 [A113] Counter Collector Started (#19)
20230406 19:23:56 [A113] InteractionCounter Collector Started (#19)
20230406 19:23:56 [SCOUTER] Configure -Dscouter.config=scouter\scouter.conf
20230406 19:23:56 [A100] agent boot seed=x4g7tb1gafs
20230406 19:23:57 [A119] Agent UDP local.port=0
19:24:00.438 [restartedMain] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/D:/dev/git/dialog-admin-service/build/classes/java/main/, file:/D:/dev/git/dialog-admin-service/build/resources/main/]
19:24:00.443 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoClassDefFoundError: scouter/agent/trace/TraceMain
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java)
	at java.base/java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:719)
	at org.springframework.cloud.commons.util.InetUtils.convertAddress(InetUtils.java:163)
	at org.springframework.cloud.commons.util.InetUtils.findFirstNonLoopbackHostInfo(InetUtils.java:66)
	at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.getFirstNonLoopbackHostInfo(HostInfoEnvironmentPostProcessor.java:66)
	at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.postProcessEnvironment(HostInfoEnvironmentPostProcessor.java:51)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:188)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:206)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)

catius-io avatar Apr 06 '23 10:04 catius-io

시키는 대로 넣었던거 같은데....안됩니다 ㅠㅠ

catius-io avatar Apr 06 '23 10:04 catius-io

참고로 jboss 관련 param은 =souter가 없이 했을때도 같은 에러가 발생했습니다.

catius-io avatar Apr 06 '23 10:04 catius-io

java version : java 11 spring boot : 2.2.0

intelliJ vm 설정

image

error stack trace

 ____                  _            
 / ___|  ___ ___  _   _| |_ ___ _ __ 
 \___ \ / __/   \| | | | __/ _ \ '__|
  ___) | (_| (+) | |_| | ||  __/ |   
 |____/ \___\___/ \__,_|\__\___|_|                                      
 Open Source S/W Performance Monitoring  
 Scouter version 2.17.1
 
20230406 19:23:56 [SCOUTER] Version 2.17.1 2022-03-27 04:35 GMT_ENV_java8plus
20230406 19:23:56 [SCOUTER] loaded by app classloader 
20230406 19:23:56 [SCOUTER] jar:file:/D:/dev/git/dialog-admin-service/scouter/scouter-agent.jar
20230406 19:23:56 [SCOUTER] objType:java
20230406 19:23:56 [SCOUTER] objName:/LAPTOP-VEDMAAF7/WAS-01
20230406 19:23:56 [A113] Counter Collector Started (#19)
20230406 19:23:56 [A113] InteractionCounter Collector Started (#19)
20230406 19:23:56 [SCOUTER] Configure -Dscouter.config=scouter\scouter.conf
20230406 19:23:56 [A100] agent boot seed=x4g7tb1gafs
20230406 19:23:57 [A119] Agent UDP local.port=0
19:24:00.438 [restartedMain] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/D:/dev/git/dialog-admin-service/build/classes/java/main/, file:/D:/dev/git/dialog-admin-service/build/resources/main/]
19:24:00.443 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoClassDefFoundError: scouter/agent/trace/TraceMain
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java)
	at java.base/java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:719)
	at org.springframework.cloud.commons.util.InetUtils.convertAddress(InetUtils.java:163)
	at org.springframework.cloud.commons.util.InetUtils.findFirstNonLoopbackHostInfo(InetUtils.java:66)
	at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.getFirstNonLoopbackHostInfo(HostInfoEnvironmentPostProcessor.java:66)
	at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.postProcessEnvironment(HostInfoEnvironmentPostProcessor.java:51)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:188)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:206)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)

Windows 환경에서는 아래와 같이 Double Quote로 감싸서 VM option을 지정하니 잘되던데요.. -javaagent:"D:\scouter\agent.java\scouter.agent.jar" -Dscouter.config="D:\scouter\agent.java\conf\scouter.conf" -Dobj_name=LOCAL-TEST

Nickkun avatar May 14 '23 23:05 Nickkun

jboss.modules.system.pkgs는 jboss에만 적용할 수 있는 옵션입니다. jboss eap 처럼 osgi 모델일 경우 system.pkg에 클래스명을 정의해주면 됩니다. 최근에 제가 경험한 케이스는 jira 솔루션에서 동일 에러가 발생했습니다. jira의 경우 tomcat + osgi 모델을 사용하고 있어서 위와 같은 에러가 발생했는데요. 이 경우는 jira에서 제공하는 jboss.modules.system.pkgs와 유사한 옵션이 있어서 그걸 사용해서 해결했습니다.

위 로그를 보다보니

19:24:00.438 [restartedMain] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/D:/dev/git/dialog-admin-service/build/classes/java/main/, file:/D:/dev/git/dialog-admin-service/build/resources/main/]

classpath가 build path인데 개발툴에서 에이전트를 실행하시 것 같네요. 개발하시는 코드를 jar로 묶은 후에 실행하시거나 개발툴에서 scouter 에이전트를 부트 클래스 로더로 기동할 수 있는 방법을 찾으셔야 할 것 같습니다.

gaiajeon avatar May 24 '23 07:05 gaiajeon