javaagents

Unable to instrument apache httpclient using javaagent for spring boot uber jar application

旧城冷巷雨未停 提交于 2019-12-04 17:54:08
I'm trying to write a javaagent with Bytebuddy to intercept apache httpclient requests and I want to use this agent for spring boot application. The agent works fine when I start my test spring boot application from Idea (run the main method directly). However, when I package the application into a spring boot uber jar and run it using java -javaagent:myagent.jar -jar myapplication.jar , it throws the following exception. onError:org.apache.http.impl.client.AbstractHttpClient java.lang.NoClassDefFoundError: org/apache/http/HttpHost at java.lang.Class.getDeclaredMethods0(Native Method) at java

Check if aspectjweaver (or any javaagent) is loaded

て烟熏妆下的殇ゞ 提交于 2019-12-04 16:35:06
Is there a (pref portable) way to check if The JVM has been stated with a particular -javaagent ? In particular I'm interested to know if the aspectj load time weaver has loaded or not. (I'm trying to provide a helpful error msg in the case of incorrect startup). kriegaex The following code shows a way to determine any -javaagent:... JVM arguments, a way to check if the AspectJ weaving agent entry point class (the one mentioned in the manifest entry Premain-Class: of aspectjweaver.jar ) is loaded. The former just proves that the argument was given on the command line, not that the agent was

C++ jump to other method execution

浪尽此生 提交于 2019-12-04 01:35:25
In my C++ JNI-Agent project i am implementing a function which would be given a variable number of parameters and would pass the execution to the other function: // address of theOriginalFunction public static void* originalfunc; void* interceptor(JNIEnv *env, jclass clazz, ...){ // add 4 to the function address to skip "push ebp / mov ebp esp" asm volatile("jmp *%0;"::"r" (originalfunc+4)); // will not get here anyway return NULL; } The function above needs to just jump to the: JNIEXPORT void JNICALL Java_main_Main_theOriginalFunction(JNIEnv *env, jclass clazz, jboolean p1, jbyte p2, jshort

How to change static variable value using ASM?

那年仲夏 提交于 2019-12-02 12:25:13
I started learning Java Agent few days ago. But documentation is not very good and beginners like me struggling to understand the basics. I created a basic multiplier class and export it to runnable jar using eclipse. Here is the code snippet. Main jar file: public class Multiplier { public static void main(String[] args) { int x = 10; int y = 25; int z = x * y; System.out.println("Multiply of x*y = " + z); } } Bytecode for above class Now I want to manipulate the value of x from an agent. I tried to create the Agent class like this Agent: package myagent; import org.objectweb.asm.*; import

Is it possible to run Play Framework 2.0 server with a javaagent?

不羁岁月 提交于 2019-12-01 05:31:13
I would like to be able to run the Play Framework 2.0 server with a javaagent. Some resources on the web (see here and here ) suggest that this could be done simply by appending -javaagent:/path/to/agent.jar to play run but it doesn't seems to work for me. Any clues? There is no clean way to pass the -javaagent parameter to the java command invocation with play 2.0.1-2.0.4 without modifying a script. I was able to get a javaagent working using the following technique: # Modify the play/framework/build script to include an extra environment variable sed -i 's/^java\( \${PLAY_OPTS}\)\?/java $

Is it possible to run Play Framework 2.0 server with a javaagent?

半城伤御伤魂 提交于 2019-12-01 03:24:26
问题 I would like to be able to run the Play Framework 2.0 server with a javaagent. Some resources on the web (see here and here ) suggest that this could be done simply by appending -javaagent:/path/to/agent.jar to play run but it doesn't seems to work for me. Any clues? 回答1: There is no clean way to pass the -javaagent parameter to the java command invocation with play 2.0.1-2.0.4 without modifying a script. I was able to get a javaagent working using the following technique: # Modify the play

How to put classes for javaagent in the classpath

。_饼干妹妹 提交于 2019-11-30 12:52:03
I am trying to develop a javaagent that would instrument code with help of asm-4. For now I'm stucked with a pretty basic problem, the classloader for the javaagent doesn't see asm dependencies and therefor fails. Do I have to provide a jar-with-dependencies (aka maven build plugin) which contains all the needed classes by the agent, or is there another way to add classes to the java agent? Referencing the jar asm-all.jar directly in the classpath didn't help. Building jar-with-dependencies didn't help at first, because Premain-Class attribute couldn't be set with assembly plugin. Help is

Specify javaagent argument with Maven exec plugin

泄露秘密 提交于 2019-11-30 04:58:28
I have a similar question to: this previous question I am converting a Java project using Netbeans to Maven. In order to launch the program, one of the command-line arguments we need is the -javaagent setting. e.g. -javaagent:lib/eclipselink.jar I'm trying to get Netbeans to launch the application for development use (we will write custom launch scripts for final deployment) Since I'm using Maven to manage the Eclipselink dependencies, I may not know the exact filename of the Eclipselink jar file. It may be something like eclipselink-2.1.1.jar based on the version I have configured in the pom

Adding -javaagent to Tomcat 6 server, where do I put it and in what format?

微笑、不失礼 提交于 2019-11-28 20:48:57
I´m trying to install an application health monitoring application that can monitor J2EE web transactions and I need to put a javaagent into my Tomcat somehow but am not clear on exactly how to do this, I am using Linux and have been instructed by the software company that makes this product to do something like below: -javaagent:<Path to the WebTransactionAgent.jar> I have received further support from them and they basically said to put this into the appropriate .sh file (but they weren´t able to tell me which file that is for Tomcat) I tried putting this in the catalina.sh file but it does

JavaAgent in Lotus Notes 6.5 using axis api gives Exception “No implementation defined for org.apache.commons.logging.LogFactory”

柔情痞子 提交于 2019-11-28 06:16:36
问题 I needed to write a JavaAgent in a Lotus Notes 6.5 DB to access a web service. I used Axis Apache API for this purpose. I created A Java agent and added the jar files of axis in the agent by using Edit Project button. Below is the agent code: import lotus.domino.*; import javax.xml.*; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.namespace.QName; import java.net.URL; public class JavaAgent extends AgentBase { public void NotesMain() { try {