我試圖重新在威爾的blog post描述的行爲,但收到以下異常儀表上試圖通過運行它:異常的Java代理的調用通過ByteBuddy
$ java -javaagent:agent/target/securityfixer-agent-1.0-SNAPSHOT.jar=bootstrap/target/securityfixer-bootstrap-1.0-SNAPSHOT.jar -jar example/target/securi
tyfixer-example-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: net/bytebuddy/implementation/Implementation$Context$Factory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethod(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: net.bytebuddy.implementation.Implementation$Context$Factory
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
FATAL ERROR in native method: processing of -javaagent failed
的structure是在描述威爾的博客 - 三個獨立的罐子,一個與代理人,一個與攔截器和一個與主類。
我也試着運行它通過將mainClass節到securityfixer-例子的清單可執行的JAR,但是,這似乎是完全繞過儀表:
$ java -jar example/target/securityfixer-example-1.0-SNAPSHOT.jar -javaagent:agent/target/securityfixer-agent-1.0-SNAPSHOT.jar=bootstrap/target/securityfixer-bootstrap-1.0-SNAPSHOT.jar
Security manager is set!
ATTACK SUCCEEDED: Security manager was reset!
什麼可能我在這裏失去了?提前致謝。
對於那些遇到此問題的用戶,請務必使用Byte Buddy版本1.4.1或更低版本。從1.4.2開始,它不再有效......仍然試圖追查爲什麼! –
你用ver獲得的錯誤是什麼。 1.4.2? –