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
6
votes
1 answer

Remote debug javaagent jar file

I created a javaagent jar file and attached it with a web application (by using -javaagent keyword on the startup of web application). How can i possible to remote debug this javaagent with eclipse
Anish Antony
  • 875
  • 3
  • 17
  • 35
6
votes
0 answers

does premain class of javaagent work for Web application deployed in tomcat

i'm learning about javaagent and i created a simple profiler http://www.javabeat.net/2012/06/introduction-to-java-agents/ I profiled a java application and it works fine. can i use this profiler to profile an web application deployed in tomcat. i…
Raj
  • 440
  • 2
  • 6
  • 22
6
votes
1 answer

Javaagent reports "redefineClasses is not supported in this environment"

I'm newbie on java agents. I created a simple HotswapAgent class (sniffing from Play! Framework): public class HotswapAgent { static Instrumentation instrumentation; public static boolean enabled = false; public static…
g.annunziata
  • 3,118
  • 1
  • 24
  • 25
5
votes
1 answer

What are some interesting uses for Java Agents?

Starting with Java 5 there's an option to add Java Agents to the class loader. Have you written any Agents? have you used any Agents? What are interesting uses of Agents?
carrier
  • 32,209
  • 23
  • 76
  • 99
5
votes
3 answers

Make a Java class visible from any ClassLoader

I'm using a Java Agent (Agent.class) to transform a method in a program (Program.class) in a way that includes a call to the Agent class. public Program.getMultiplier()F: ALOAD 1 ALOAD 2 FDIV + INVOKESTATIC…
user7401478
  • 1,372
  • 1
  • 8
  • 25
5
votes
1 answer

"Error opening zip file or JAR manifest missing" when configuring javaagent in IntelliJ

This one took me way too long to figure out. I was trying to configure a Java agent for a test execution in IntelliJ by configuring the following VM option in the Run/Debug…
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
5
votes
3 answers

How to embed a javaagent in spring boot app using boot gradle plugin

I am using a javaagent for my spring boot app and currently I am running it via java -javaagent:agent.jar -jar app.jar My project is a gradle project and I want to embed the agent.jar inside the app.jar so that I can run it as java…
Anindya Chatterjee
  • 5,824
  • 13
  • 58
  • 82
5
votes
1 answer

Use -javaagent without packaging agent into a jar

Is it possible to run java -javaagent:myagent.jar some.package.Main without having agent packaged to a jar? Something like java agent.MyAgent some.package.Main I have a source code for an agent and would like to be able to debug it and later change…
Artur
  • 3,284
  • 2
  • 29
  • 35
5
votes
2 answers

Specify -javaagent Option in Manifest

To tell the JVM to invoke a Java Instrumentation agent before the main class of a Jar file, you usually have to invoke it with a command option: java -javaagent:agent.jar program.jar Having to type this out every time is pretty inconvenient, so is…
Clashsoft
  • 11,553
  • 5
  • 40
  • 79
5
votes
1 answer

How to instrument classes loaded by a custom class loader?

I was trying to modify the byte code of several classes whose packaging jar files are not in class path - they are loaded by a custom ClassLoader during runtime given an URL. I tried to use a java agent with ClassFileTransformer hoping to intercept…
leshiv l
  • 53
  • 1
  • 4
5
votes
3 answers

LogManager Exception in JBOSS AS 7.1 with java.util.Logger

I created a java application and initialize a java.util.Logger with that application and run that application as -javaagent with jboss AS 7 server and i got IllegalStateException (i am using eclipse IDE).Here follows my logger initialization…
Anish Antony
  • 875
  • 3
  • 17
  • 35
5
votes
1 answer

How to configure JVM Argument -javaagent with two jars

To use the spring AOP, I have to configure -javaagent:C:/spring-agent-2.5.6.jar as JVM argument. But there is a jar that is already configured i.e. -javaagent:C:/other.jar Now how can I configure both jars with -javaagent so that both jars should…
Narendra Verma
  • 2,372
  • 6
  • 34
  • 61
5
votes
4 answers

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

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…
Tahir Akhtar
  • 11,385
  • 7
  • 42
  • 69
4
votes
1 answer

Why can't I load resources which are appended to the bootstrap class loader search?

When adding a jar to the bootstrap class loader via java.lang.instrument.Instrumentation#appendToBootstrapClassLoaderSearch, I can't load any of it's resources…
Felix
  • 5,804
  • 4
  • 25
  • 37
4
votes
1 answer

How to add vm option to jetty?

How it is available to specify vm option like -javaagent to start jetty or it is available only thru MAVEN_OPTS variable? I need it to enable load-time-weaving of aspects. This plugin seems like doesn't work.
Shikarn-O
  • 3,337
  • 7
  • 26
  • 27
1 2
3
35 36