This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize" Watch "com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize" New topic
Author

com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

Michel Legris
Greenhorn

Joined: Feb 21, 2012
Posts: 19
We are trying to make a **simple** hello World agent class but the agent cannot be initialized

ex:

ex: (the AgentClass)

The manifest look like this :
Manifest-Version: 1.0
Premain-Class: Com.MyAgent
Agent-Class: Com.MyAgent
Created-By: 1.6.0_06 (Sun Microsystems Inc.)

Note : I tried with premain, agentmain etc... any possible way and it's not working

We always get the error : com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

How the hell the loaded agent jar can be correctly initialized ??? I know there is many possible cause but we tried almost anything

Thanks

Michel
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Is the class in a package called Com? I don't see that in your class definition.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michel Legris
Greenhorn

Joined: Feb 21, 2012
Posts: 19
Thanks Rob for trying to help.

the "com" was an error for the posted example (sorry my bad)

We finally found the problem....we need to restart the application (the one to "inject" the agent) or the old jar (from a previous compilation) will be used instead.

I was not really comfortable with java packaging and even java in general so I had to learn a little bit more to make it work

Thanks again

Michel
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

You're welcome.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize