byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

Cannot locate class file for Byte Buddy installer

Open PaoDeK opened this issue 2 years ago • 1 comments

I use byte-buddy(byte-buddy-agent-1.12.18.jar) to hot update the class. Sometimes the hot update succeeds, sometimes it fails. (java version "1.8.0_121") code:

private static void hotswapClassByByteBuddy(Class<?> clazz, byte[] bytes) {
    try {
	// Byte Buddy hot update
	Instrumentation instrumentation = ByteBuddyAgent.install();
	instrumentation.redefineClasses(new ClassDefinition(clazz, bytes));
	logger.info("ByteBuddy hot update [{}] succeeded", clazz);
    } catch (Throwable t) {
	logger.error("ByteBuddy hot update [{}] failed", clazz, t);
    }
}

Error:

[2023-06-06 20:37:04,040] [ERROR] [HotSwapUtils] - ByteBuddy hot update [class com.bballh5.gameserver.service.TeamPropService] failed 
 java.lang.IllegalStateException: Cannot locate class file for Byte Buddy installer
	at net.bytebuddy.agent.ByteBuddyAgent$AgentProvider$ForByteBuddyAgent.createJarFile(ByteBuddyAgent.java:1500) ~[FTXSoccerGameServer.jaz:build202306051143]
	at net.bytebuddy.agent.ByteBuddyAgent$AgentProvider$ForByteBuddyAgent.resolve(ByteBuddyAgent.java:1539) ~[FTXSoccerGameServer.jaz:build202306051143]
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:633) ~[FTXSoccerGameServer.jaz:build202306051143]
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:611) ~[FTXSoccerGameServer.jaz:build202306051143]
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:563) ~[FTXSoccerGameServer.jaz:build202306051143]
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:540) ~[FTXSoccerGameServer.jaz:build202306051143]
	at com.bballh5.datasystem.hotswap.HotSwapUtils.hotswapClassByByteBuddy(HotSwapUtils.java:126) ~[FTXSoccerGameServer.jaz:build202306051143]
	at com.bballh5.datasystem.hotswap.HotSwapUtils.hotswapClassByJavassist(HotSwapUtils.java:100) ~[FTXSoccerGameServer.jaz:build202306051143]
	at com.bballh5.datasystem.hotswap.HotSwapUtils.hotswapClass(HotSwapUtils.java:73) ~[FTXSoccerGameServer.jaz:build202306051143]
	at com.bballh5.datasystem.hotswap.HotSwapUtils.hotSwapClassesFromDir(HotSwapUtils.java:46) ~[FTXSoccerGameServer.jaz:build202306051143]
	at com.bballh5.datasystem.hotswap.HotSwapUtils.startHotSwap(HotSwapUtils.java:30) ~[FTXSoccerGameServer.jaz:build202306051143]
	at com.bballh5.gameserver.GameServerPushMessageHandler.pushCallback(GameServerPushMessageHandler.java:224) ~[FTXSoccerGameServer.jaz:build202306051143]
	at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
	at jazmin.core.thread.ThreadWorker.run(ThreadWorker.java:83) [jazmin.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

If the hot update appears the above error message, restart the application and hot update successfully. I really can't find the cause of the problem. How to solve this problem?

PaoDeK avatar Jun 05 '23 09:06 PaoDeK

Might there be an issue of file handles not being available? This often hints that there is a resource leak somewhere.

raphw avatar Jun 06 '23 06:06 raphw