You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Fredrik <fr...@sitevision.se> on 2014/04/29 10:28:48 UTC
javaagent initialization (premain-method) not triggered by tomcat
7.0.52
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?
Regards
/Fredrik
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat
7.0.52
Posted by Fredrik <fr...@sitevision.se>.
Christopher Schultz skrev 2014-04-29 17:38:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Fredrik,
>
> On 4/29/14, 4:28 AM, Fredrik wrote:
>> 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?
> How are you configuring the agent (to run on the command-line)?
>
> Can you run a 'ps' to verify that the command-line arguments are in
> fact being passed-into the JVM launch command?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJTX8dtAAoJEBzwKT+lPKRYWnoP/0Eznux5f8MEi5s3eJZ0O2AE
> 3ZR+c0ZOyagIsA/LIplyKL46KQHomjJUGcXfjB3I8r35dlLlIEZh57uk0a5vVoF2
> v7sOnt+lTmcymO5+0Ewg3jCS0MEl1248FZccMl58Q5v4jlfvAP8GhPCQeOgzYToS
> lVTPVEvTrotJqQHLiy1UFjWsnEpf3NXWhFChKWDXtMNjfsHIzSAMnIoLvp7Iquef
> ATsJNaxb3ocInincsLIpIlTO5IfuId51MZIvoOpbhXCyiw3Ar4HC7nV6/Vr8NSF/
> A0D0Xn9XT0gjygtXwZHfabEfCYKU2QA+w+4UyCyysEKIyjLWIAgslXbGyO+c20ep
> r5tAl2UIrAcicAKYEd2N+/zBh7bjdpfDca+GkPjCKB5MGy/ytqIxt5CBmS55pv16
> S3FuTG3YCSPEdzUcqwuK1253IbZ35BHZ5H9kunOiwubwBW5o6Z/F/cx4vQbAInOa
> uvQ++/ScSZegw6Za+YYgh8+k1HrWw7V1dza0Nqbx6svMNLPm6cdWSHHnHKk8BYuO
> ou/3TH8mqGtwr9R7hyLJnelsWH+4ZDGeQ9MxFk0AJQ9RW/v5MgafwsmOjU3y9KEO
> jMFXezWjIlkmCaXj5b5uAGUoIIDqJRq7uZ0CXrih/Hskc0H9fioLwZBV1bgkx2kY
> pFTjjSibvOQgsru633A1
> =roc7
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
Yes, I can see that the arguments are being passed to the jvm both by ps
and with jconsole.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat
7.0.52
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Fredrik,
On 4/29/14, 4:28 AM, Fredrik wrote:
> 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?
How are you configuring the agent (to run on the command-line)?
Can you run a 'ps' to verify that the command-line arguments are in
fact being passed-into the JVM launch command?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBCAAGBQJTX8dtAAoJEBzwKT+lPKRYWnoP/0Eznux5f8MEi5s3eJZ0O2AE
3ZR+c0ZOyagIsA/LIplyKL46KQHomjJUGcXfjB3I8r35dlLlIEZh57uk0a5vVoF2
v7sOnt+lTmcymO5+0Ewg3jCS0MEl1248FZccMl58Q5v4jlfvAP8GhPCQeOgzYToS
lVTPVEvTrotJqQHLiy1UFjWsnEpf3NXWhFChKWDXtMNjfsHIzSAMnIoLvp7Iquef
ATsJNaxb3ocInincsLIpIlTO5IfuId51MZIvoOpbhXCyiw3Ar4HC7nV6/Vr8NSF/
A0D0Xn9XT0gjygtXwZHfabEfCYKU2QA+w+4UyCyysEKIyjLWIAgslXbGyO+c20ep
r5tAl2UIrAcicAKYEd2N+/zBh7bjdpfDca+GkPjCKB5MGy/ytqIxt5CBmS55pv16
S3FuTG3YCSPEdzUcqwuK1253IbZ35BHZ5H9kunOiwubwBW5o6Z/F/cx4vQbAInOa
uvQ++/ScSZegw6Za+YYgh8+k1HrWw7V1dza0Nqbx6svMNLPm6cdWSHHnHKk8BYuO
ou/3TH8mqGtwr9R7hyLJnelsWH+4ZDGeQ9MxFk0AJQ9RW/v5MgafwsmOjU3y9KEO
jMFXezWjIlkmCaXj5b5uAGUoIIDqJRq7uZ0CXrih/Hskc0H9fioLwZBV1bgkx2kY
pFTjjSibvOQgsru633A1
=roc7
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat 7.0.52
Posted by Konstantin Kolinko <kn...@gmail.com>.
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
>> <fr...@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat
7.0.52
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Konstantin,
On 4/29/14, 7:17 PM, Konstantin Kolinko wrote:
> 2014-04-29 12:28 GMT+04:00 Fredrik
> <fr...@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.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBCAAGBQJTYQIIAAoJEBzwKT+lPKRY3WUP/3y/rRw6Bd+bvHm8SY/t1fHh
4cnCvjbjTSluRNNl0/QrwpSev0NrTtyGn40aTSP5OM7QQfhK3DK70uBrlwZENAiY
zcsCTXRe9IuVSlQPdvXLnq59E3ZXYyUVIRlge5Wh9ucg6onYFmCFQPmOBpBYppix
MWKrbAkaxeTxY2iD73DQeX02cda9N9YeC0FtGI+i3p3x9gGQ/1BcJZAH3sV7gz9s
T/zgZ72WYnRQJ5h5zBhCIGQCUKiA6uR7DzPAuB5L8JXybnQ5OvKjrJS03169G3AX
PEMFCzLbImaKy8sttJNWNb4JyjKAZE26lmPWHK7Hop27FWGAobjogb5vEQ5XDJWh
exV+VRpT2OyWFUfJWF5scM23iKR1JzZz/S433YpAXQC2g/8Q+qbZLB//q0D7T8TW
VbmHxBjYPFcN2DkGYtm8uFGVRxDbNNJMvUG+7+oCX3B3bF4sr3roD2FGVrkN4qlL
HEG0pCxPmiZ8wEQWHem/9VPCMHKNW36eX7KllW8M+35GAQURXKgayxGPGn20zDc7
Nn1exxKzcFjawTKt1LlR3aHEsGYKyXbsEOb1Ivgmm7YYz5vGiIunkYS1V1jfdUGz
68NwB67EZg93cA4BVpEjsorxAlWYg0vvmlwa2/poFKJGG3XRABRPe6PWIvoz23Yg
9TlEwIFdtBlMbQoY71NN
=ZgaK
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat
7.0.52
Posted by Fredrik <fr...@sitevision.se>.
Konstantin Kolinko skrev 2014-04-30 01:17:
> 2014-04-29 12:28 GMT+04:00 Fredrik <fr...@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.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
Now I get what you mean (I guess). Specifying the javaagent option will
automagically add the jar to the system classloader but when the webapp
is loaded it's also added to the webapp classloader. since it resides in
webapps/ROOT/WEB-INF/lib/. In < 7.0.50 tomcat will load the jar in the
system classloader, but in > 7.0.52 it loads it into the webapp
classloader which means we'll have a conflict (same jar in different
classloaders).
Thanks.
/Fredrik
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat
7.0.52
Posted by Fredrik <fr...@sitevision.se>.
Konstantin Kolinko skrev 2014-04-30 01:17:
> 2014-04-29 12:28 GMT+04:00 Fredrik <fr...@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.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
I only have one jar which is placed at
(webapps/ROOT/WEB-INF/lib/jamm-0.2.3.jar).
A little bit strange but when I moved the jar to tomcat/lib then the
agent starts working as expected.
Regards
/Fredrik
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat
7.0.52
Posted by Fredrik <fr...@sitevision.se>.
Konstantin Kolinko skrev 2014-04-30 01:17:
> 2014-04-29 12:28 GMT+04:00 Fredrik <fr...@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.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
Now I get what you mean (I guess). Specifying the javaagent option will
automagically add the jar to the system classloader but when the webapp
is loaded it's also added to the webapp classloader. since it resides in
webapps/ROOT/WEB-INF/lib/. In < 7.0.50 tomcat will load the jar in the
system classloader, but in > 7.0.52 it loads it into the webapp
classloader which means we'll have a conflict (same jar in different
classloaders).
Thanks.
/Fredrik
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: javaagent initialization (premain-method) not triggered by tomcat 7.0.52
Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-04-29 12:28 GMT+04:00 Fredrik <fr...@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.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org