Questions tagged [javaagents]

A Java agent allows for the instrumentation of a Java application by using another Java program that is specified on the command line.

All Java classes concerned with instrumentation are collected in the java.lang.instrument package. The package description defines the layout of a Java agent as follows:

An agent is deployed as a JAR file. An attribute in the JAR file manifest specifies the agent class which will be loaded to start the agent. For implementations that support a command-line interface, an agent is started by specifying an option on the command-line. Implementations may also support a mechanism to start agents some time after the VM has started. For example, an implementation may provide a mechanism that allows a tool to attach to a running application, and initiate the loading of the tool's agent into the running application. The details as to how the load is initiated, is implementation dependent.

538 questions
4
votes
1 answer

How to take the exception thrown by a constructor using a ByteBuddy agent?

I'm trying to log every call, returned objects and exceptions thrown in methods and constructors using a ByteBuddy (v1.7.9) java agent, without iterfering with the normal functioning of the instrumented code. My current instantiation of the agent…
4
votes
1 answer

Agent JAR not found or no Agent-Class attribute

// Fixed: This was not an Error because of code. It was because of the IDE. I just tried to make a injection for a game called Minecraft. But i have one Problem. It's not able to load Agent. Here is the Exception:Exception in thread "main"…
david
  • 53
  • 2
  • 6
4
votes
1 answer

Java javassist method calling

So I'm using java agent with javassist for purpose of injecting some small monitoring related code to different methods in different classes. My java agent code: public class ConverterAgent implements ClassFileTransformer { public static void…
stef
  • 99
  • 6
4
votes
1 answer

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

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…
segeon
  • 51
  • 3
4
votes
1 answer

Java agent : transform() not applied on all classes

I have been trying to use a Java agent to apply a bytecode transformation with ASM. I implemented an Agent with the premain method adding a transformer to the Instrumentation. I added the "Premain-Class" line in the .jar manifest Premain-Class:…
Jabis
  • 41
  • 6
4
votes
1 answer

Leiningen java-agents not working in uberjar

In my Leiningen project I have the following config: :java-agents [[com.newrelic.agent.java/newrelic-agent "3.19.2"]] When running my app as in lein repl the agent is being run, but when I create the uberjar and run it like: java -jar…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
4
votes
2 answers

Access servlet-api within javaagent

I'm trying to access classes from the servlet-api within a javaagent jar that is added to my application via the -javaagent:my-agent.jar flag. My application runs on Tomcat. The problem is that I get a ClassNotFoundException, because the agent jar…
Felix
  • 5,804
  • 4
  • 25
  • 37
4
votes
0 answers

Jolokia agent config using Spring

I am attempting to configure a Jolokia JVM agent in a Spring application by following the reference documentation for Jolokia Spring support given here. I have added jolokia-spring-1.3.1 as a maven dependency, and below is my spring application…
Stephen Hartley
  • 945
  • 1
  • 11
  • 17
4
votes
1 answer

Does a java agent run in a separate thread?

I feel that this is something I should know, but does a java agent (specified with -javaagent) run in a separate thread? I've read that a Java agent is a pluggable library that runs embedded in a JVM and intercepts the classloading process, but I…
Alix
  • 927
  • 7
  • 21
4
votes
2 answers

AttachNotSupportedException: no providers installed java agent

I'm having troubles to attach my java app to a remote java vm. I'm using java 8u45 on windows 7 and my attaching code is very simple import java.io.IOException; import java.util.List; import java.util.Scanner; import…
stylo
  • 496
  • 4
  • 12
4
votes
2 answers

Modify already loaded class with Java agent?

Currently I'm trying to modify method bodies residing in classes already loaded by the JVM. I'm aware of the JVM actually not allowing to change the definition of classes that have already been loaded. But my researches brought me to implementations…
pklndnst
  • 726
  • 2
  • 10
  • 27
4
votes
1 answer

Gradle Application Plugin : How can I run jvm application with -javaagent options?

I use application plugin in gradle (v1.10) to package and to run my apps. So, now I need to use aspects (aspectj), and I dont want to use aspectj-compiler (ajc). Is it possible to tweak gradle application run scripts, so my app could be run with…
head_thrash
  • 1,623
  • 1
  • 21
  • 26
4
votes
1 answer

Bytecode manipulation manifest entries

I'm having fun doing some Java bytecode modification tutorials. All of them state that I need to have the following manifest attirbutes set: Can-Redefine-Classes: true Can-Retransform-Classes: true Can-Set-Native-Method-Prefix: true It's completely…
maslan
  • 2,078
  • 16
  • 34
4
votes
2 answers

New Relic not collecting data from Play 2.2.1 Scala App

I'm trying to use New Relic's Java Agent 3.1.0 to monitor a Scala based Play 2.2.1 web app, however the NR Web UI doesn't seem to be collecting any data from my server. I've verified that my newrelic.yml config file is correct, and the Agent appears…
dbau
  • 16,009
  • 2
  • 21
  • 31
4
votes
1 answer

Pass command-line argument javaagent with maven exec plugin

I have a caching app in Java and I need to put objects of different size in cache. The problem is that I didn't really know how to count the size of a custom object and I've found the solution - to use the library:…
PAcan
  • 871
  • 2
  • 15
  • 32