2014-04-30 18:00 GMT+04:00 Christopher Schultz <ch...@christopherschultz.net>:
>
> Konstantin,
>
> On 4/29/14, 7:17 PM, Konstantin Kolinko wrote:
>> 2014-04-29 12:28 GMT+04:00 Fredrik
>> <fredrik.l.stigb...@sitevision.se>:
>>> Hello. We're using jamm (https://github.com/jbellis/jamm) a java
>>> agent for measuring object memory usage, passing the javaagent
>>> argument to tomcat as
>>> "-javaagent:../../tomcat/webapps/ROOT/WEB-INF/lib/jamm-0.2.3.jar".
>>>
>>>
> When running 7.0.50 everything works as expected but after upgrading to
>>> 7.0.52 the initialization code of the agent (premain-method)
>>> isn't called anymore. Any ideas?
>>
>>
>> I understand that that means that you have the same jar present in
>> both the System classloader and the Webapp classloader.
>>
>> You should remove that jar from WEB-INF/lib directory of that
>> webapp.
>>
>> IIRC, in 7.0.50 and earlier Tomcat preferred the class from the
>> system classloader (effectively ignoring the webapp's jar).
>>
>> In 7.0.52 it does load the class provided by web application.
>
> Actually, I'd like an explanation of the above. I'm not saying it's
> wrong or makes no sense, but I don't quite understand how it could
> interfere:
>
> The javaagent should be loaded at JVM launch, which is before any web
> applications exist, so no ClassLoader conflict should occur.
>
> When a remote process connects to the agent, it should do so out of
> context of any web application (that is, the thread that handles the
> connection should not have its ClassLoader set to the
> WebappClassLoader of any deployed web application), so no classes
> should be loaded from the WebappClassLoader.

It boils down to why OP thinks that "the initialization code of the
agent (premain-method) isn't called anymore.".

There is no diagnostic logging to prove that. The only thing that that
method does is remembering something in a static field. [1, line 17]

As Web application has a  different copy of MemoryMeter class loaded
by different class loader,  it has its own copy of that static field,
which is null

To this web application it looks as if the premain has not been
called. [1, line 102]

[1] 
https://github.com/jbellis/jamm/blob/master/src/org/github/jamm/MemoryMeter.java

BTW,
https://issues.apache.org/bugzilla/show_bug.cgi?id=55943#c13

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to