Re: How to enable Native Memory Tracking(NMT) in Tomcat?

2017-03-02 Thread Suvendu Sekhar Mondal
Mark,
I am running Tomcat as a Windows service.

Thanks!
Suvendu

On Thu, Mar 2, 2017 at 8:08 PM, Mark Thomas  wrote:
> On 02/03/17 10:54, Suvendu Sekhar Mondal wrote:
>> Hello Everyone,
>>
>> I am new here. :)
>>
>> Environment:
>> Java Version: Java HotSpot(TM) 64-Bit Server VM version 25.91-b15
>> (Java version 1.8.0_91-b15)
>> Tomcat Version: Tomcat 8.0.20
>> OS Version: Microsoft Windows 8.1 Enterprise
>>
>> I am trying to enable Native Memory Tracking(NMT) to get internal
>> memory usage deatils about Tomcat process which is running on my
>> system. I have added following flags to Tomcat's Java options:
>> -XX:+UnlockDiagnosticVMOptions
>> -XX:NativeMemoryTracking=summary
>> -XX:NativeMemoryTracking=detail
>>
>> After that I restarted Tomcat. When I tried to use "VM.native_memory"
>> command either from JCMD or JMC, I am getting "Native memory tracking
>> is not enabled" message. When I shutdown Tomcat, following message is
>> getting printed on STDERR log:
>> "Java HotSpot(TM) 64-Bit Server VM warning: Native Memory Tracking did
>> not setup properly, using wrong launcher?".
>>
>> I found this article which discussed about NMT problem in custom JVM 
>> launcher:
>> https://blogs.oracle.com/poonam/entry/using_nmt_with_custom_jvm
>>
>> My question is, does that stands true for Tomcat also? Is there any
>> other way to enable NMT in Tomcat?
>
> No idea. How did you start Tomcat?
>
> Mark
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>

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



Re: ELContext no longer available to tagfiles

2017-03-02 Thread Mike Strauch
On Thu, Mar 2, 2017 at 1:02 PM, Mark Thomas  wrote:
>
> I think you have correctly identified the commits responsible for the
> change of behaviour you see.
>
> Of the two solutions you propose, I agree the latter solution is not viable.
>
> The former solution looks possible and - based on a fairly quick review
> of the specs - should be happening anyway.
>
> What would be very helpful would be if you could put together the
> simplest possible web application that demonstrates this problem and
> attach it a new Bugzilla issue.
>
> I have some initial ideas for how to fix this but it would be helpful to
> have a test case to confirm any proposed fix.
>
> Thanks,
>
> Mark
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>

Hey Mark,

Thanks for the quick reply.  We do have a work around for the problem,
but I will create a webapp that replicates it as soon as I can.

Thanks again!

-- 
Mike Strauch
Lead Software Engineer, Hannon Hill
e mike.stra...@hannonhill.com

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



Re: logging.properties vs catalina.properties

2017-03-02 Thread Mark Thomas
On 02/03/17 00:08, John Zhuge wrote:
> Hi Tomcat gurus,
> 
> Do you know which file is loaded first? e.g. in 6.0.48.
> I guess logging.properties is loaded first, does it mean it should not use
> any system property defined in catalina.properties?

Correct on both counts.

Mark


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



Re: Error when performing parallel deployment of contexts that exposes a resource dir (org.apache.catalina.webresources.DirResourceSet)

2017-03-02 Thread Tiago Oliveira
Mark,

you where right. I was able to track down the root cause: race condition
between copy the .war and the .xml, when the .xml finishes copying first,
the context wont start (.war not found).



Thanks.

2017-03-02 11:58 GMT-03:00 Mark Thomas :

> On 02/03/17 13:13, Tiago Oliveira wrote:
> > Hello,
> >
> > i guess the title describes our situation. I pasted the stack trace from
> > catalina.out in a gist:
> > https://gist.github.com/tiagojco/2e05203095e262c559d2f679dd6b42ff
>
> That stack trace is a failure to clean up properly. The real error
> occurred earlier. What is in the logs before that?
>
> Mark
> >
> > While performing "hot deployment", the second context does not start (see
> > stack trace). After restarting the enviroment, both goes up.
> >
> > My Host @ server.xml is declared with both unpackWARs="true" and
> > undeployOldVersions="true"
> >
> > My environment is:
> > OS: Ubuntu 16.04 Xenial Xeros
> > TOMCAT: 8.0.33 manually instaled in /opt/tomcat
> >
> > I'm deploying both the contexts via XML in
> > /opt/tomcat/conf/Catalina/domain/ROOT##VERSION.xml
> >
> > Version 1.2.13: ROOT##20170217_090754.xml
> > https://gist.github.com/tiagojco/2d9ca99281355b218d4d14386bad7459
> >
> > Version 1.2.14: ROOT##20170302_092302.xml
> > https://gist.github.com/tiagojco/f43d509e06febd3d735df92467610f73
> >
> > Maybe relevant:
> > - context XML and .war file in partition A
> > (/opt/tomcat/conf/Catalina/domain and /apps/wars/domain)
> > - Resource dir in partition B (/apps/pd)
> >
> > Sorry for being too succint and/or for the grammar errors. English is not
> > my first language.
> >
> >
> > Thanks in advance.
> >
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
[image: Tiago Oliveira] Tiago OliveiraAnálise de sistemas[image: Contato]+55
83 99331.5541 <+5583993315541>/ 83 3506.8310 <+558335068310>[image: Email]
tiago.olive...@behoh.com 
[image: BeHOH]
[image: Facebook] [image: Twitter]
[image: Instagram]

  [image: Website]behoh.com [image: Localização]
goo.gl/FtUZdn 


Re: ELContext no longer available to tagfiles

2017-03-02 Thread Mark Thomas
On 02/03/17 20:18, Mike Strauch wrote:
> Hello!
> 
> I’ve recently upgraded from Tomcat 8.0.23 to 8.0.41 and noticed that the EL
> context that is available to JSPs in my application is no longer available
> in tagfiles used inside those JSPs (which was the case in 8.0.23).
> 
> We have a servlet listener declared in our web.xml which reacts to
> contextInitialized events by adding an ElContextListener to the current
> JSPApplicationContext (accessed
> via JspFactory.getDefaultFactory().getJspApplicationContext()).  This
> ELContextListener populates the current ElContext (acquired via
> the ELContextEvent passed to the contextCreated method) with a number of
> static tools that we use in our EL expressions inside JSPs and tagfiles.
> 
> The contextCreated() calls to our ElContextListener appear to be the same
> between 8.0.23 and 8.0.41 when testing with the same JSP; but inside the
> tagfiles themselves, the classes that we are adding to the context are not
> available.  For example, we are adding an ArrayUtils class which we were
> previously accessing via an expression like
> ${ArrayUtils.contains(pageScope.someArray, pageScope.someValue}.  This
> expression works inside a JSP, but not in a tagfile.
> 
> I looked through the changelog entries between 8.0.23 and 8.0.41 and came
> across a couple items which may be related to this issue:
> 
> - 58178: Expressions in a tag file should use the tag file's PageContext
> rather than that of the containing page.
> - Following on from the fix for 58178, expressions in a tag file should use
> the tag file's imports rather than those of the containing page.
> 
> Is there some way to preserve the behavior we were relying on before?  It
> seems like either more contextCreated events should be firing (perhaps once
> per tagfile invocation?) to make up for the changes listed above or that
> the ElContext being used should be passed from the JSP “context” into the
> tagfiles.  Just reading above change entries, though, the latter solution
> seems like it’d require reverting those exact changes which doesn’t seem
> ideal.

I think you have correctly identified the commits responsible for the
change of behaviour you see.

Of the two solutions you propose, I agree the latter solution is not viable.

The former solution looks possible and - based on a fairly quick review
of the specs - should be happening anyway.

What would be very helpful would be if you could put together the
simplest possible web application that demonstrates this problem and
attach it a new Bugzilla issue.

I have some initial ideas for how to fix this but it would be helpful to
have a test case to confirm any proposed fix.

Thanks,

Mark


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



ELContext no longer available to tagfiles

2017-03-02 Thread Mike Strauch
Hello!

I’ve recently upgraded from Tomcat 8.0.23 to 8.0.41 and noticed that the EL
context that is available to JSPs in my application is no longer available
in tagfiles used inside those JSPs (which was the case in 8.0.23).

We have a servlet listener declared in our web.xml which reacts to
contextInitialized events by adding an ElContextListener to the current
JSPApplicationContext (accessed
via JspFactory.getDefaultFactory().getJspApplicationContext()).  This
ELContextListener populates the current ElContext (acquired via
the ELContextEvent passed to the contextCreated method) with a number of
static tools that we use in our EL expressions inside JSPs and tagfiles.

The contextCreated() calls to our ElContextListener appear to be the same
between 8.0.23 and 8.0.41 when testing with the same JSP; but inside the
tagfiles themselves, the classes that we are adding to the context are not
available.  For example, we are adding an ArrayUtils class which we were
previously accessing via an expression like
${ArrayUtils.contains(pageScope.someArray, pageScope.someValue}.  This
expression works inside a JSP, but not in a tagfile.

I looked through the changelog entries between 8.0.23 and 8.0.41 and came
across a couple items which may be related to this issue:

- 58178: Expressions in a tag file should use the tag file's PageContext
rather than that of the containing page.
- Following on from the fix for 58178, expressions in a tag file should use
the tag file's imports rather than those of the containing page.

Is there some way to preserve the behavior we were relying on before?  It
seems like either more contextCreated events should be firing (perhaps once
per tagfile invocation?) to make up for the changes listed above or that
the ElContext being used should be passed from the JSP “context” into the
tagfiles.  Just reading above change entries, though, the latter solution
seems like it’d require reverting those exact changes which doesn’t seem
ideal.

Thanks for the help!

--
Mike Strauch
w. www.hannonhill.com
e mike.stra...@hannonhill.com


Re: getRealPath is a bad idea?

2017-03-02 Thread Mark Thomas
On 02/03/17 19:59, Berneburg, Cris J. - US wrote:
> Chris
> 
> -Original Message-
> From: Christopher Schultz [mailto:chris@...]
> Sent: Friday, February 24, 2017 [multiple]
> To: Tomcat Users List
> Subject: Re: Getting application root path before servlet is initialized?
> 
> [SNIP]
> 
> Martin K> In order to avoid hard coding that path,
> Martin K> I need a programmatic to find that value.
> Martin K> Unfortunately the datasource is initialized
> Martin K> before the servlet, so "getRealPath()" is
> Martin K> not working yet.
> 
> chris S>>> getRealPath is a bad idea. <<<
> 
> For my education's sake, would you please explain that?  Or is your follow-up 
> below the explanation?

There is no guarantee it will return a non-null value. The typical
reason is if the app is running from a packed WAR. Using it reduces the
portability of your application.

Mark


> 
> chris S> would it be possible to store it *outside* of
> chris S> the web application's on-disk footprint? That
> chris S> will in fact make you more secure. Let's say
> chris S> for example that a vulnerability exists in the
> chris S> DefaultServlet, or one of your application's
> chris S> own servlets. It allows path-traversal or
> chris S> whatever. A file living in your application
> chris S> will then be potentially remotely-fetchable :(
> chris S> If you move that file outside of the web
> chris S> application, you have a better change of
> chris S> preventing that kind of thing.
> 
> --
> Cris Berneburg
> CACI Lead Software Engineer
> 
> 


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



getRealPath is a bad idea?

2017-03-02 Thread Berneburg, Cris J. - US
Chris

-Original Message-
From: Christopher Schultz [mailto:chris@...]
Sent: Friday, February 24, 2017 [multiple]
To: Tomcat Users List
Subject: Re: Getting application root path before servlet is initialized?

[SNIP]

Martin K> In order to avoid hard coding that path,
Martin K> I need a programmatic to find that value.
Martin K> Unfortunately the datasource is initialized
Martin K> before the servlet, so "getRealPath()" is
Martin K> not working yet.

chris S>>> getRealPath is a bad idea. <<<

For my education's sake, would you please explain that?  Or is your follow-up 
below the explanation?

chris S> would it be possible to store it *outside* of
chris S> the web application's on-disk footprint? That
chris S> will in fact make you more secure. Let's say
chris S> for example that a vulnerability exists in the
chris S> DefaultServlet, or one of your application's
chris S> own servlets. It allows path-traversal or
chris S> whatever. A file living in your application
chris S> will then be potentially remotely-fetchable :(
chris S> If you move that file outside of the web
chris S> application, you have a better change of
chris S> preventing that kind of thing.

--
Cris Berneburg
CACI Lead Software Engineer



RE: Debugging

2017-03-02 Thread Berneburg, Cris J. - US
Al

You may or may not find this helpful...

-Original Message-
From: Al Grant [mailto:bigal...@gmail.com] 
Sent: Sunday, February 26, 2017 8:34 PM
To: users@tomcat.apache.org
Subject: Debugging

> Hello,
>
> System: Windows 10
> Tomcat Var: 8.5.4
> IDE: Intellij Ultimate
> Java: v1.8
>
> I have started out creating war files. At the moment I am deploying by copying
> the war to the webapps directory and then using chrome to browse the URL.
>
> I am compling the war in Intellij, but starting tomcat seperately from the 
> command line.
>
> I need to start to debug.
>
> I can connect the Intellij debugger to 8000 and I get some output that I have 
> connected ok:
>
> Connected to server
> Connected to target VM, address localhost:8000 etc
>
> What is not clear to me is :
>
> 1. How would I use a breakpoint? Intelijlets me set one but this is not 
> honoured
> when I compile as war (in gradle) 2. Despite the servlet seeming doing the 
> right
> thing (redirect) when I hit a submit button the println statements do not 
> appear
> to write anything to either the CLI or the debugger.

I use IntelliJ Idea for one of my projects too.  The artifact generated is a 
JAR file, which is invoked from the command line in Windows.  However, when 
debugging, I run the application from inside IJ-Idea.

There may be a way to "attach to process" (similar to MS Visual Studio) in 
IJ-Idea, but I have no idea how.

Also, be sure to set javac debug=true when compiling.  ;-)

> Code snippet:
>
> @Override
> protected void doGet(HttpServletRequest request, HttpServletResponse response)
> throws ServletException, IOException {
> System.out.println("doGet hit");
> request.getRequestDispatcher("/index1.jsp").forward(request, response); }
>
>  ie - Index1.jsp gets loaded but the println statement doesnt seem to appear 
> anywhere.
>
> Cheers
>
> Al

--
Cris Berneburg
CACI Lead Software Engineer


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



Re: Error when performing parallel deployment of contexts that exposes a resource dir (org.apache.catalina.webresources.DirResourceSet)

2017-03-02 Thread Mark Thomas
On 02/03/17 13:13, Tiago Oliveira wrote:
> Hello,
> 
> i guess the title describes our situation. I pasted the stack trace from
> catalina.out in a gist:
> https://gist.github.com/tiagojco/2e05203095e262c559d2f679dd6b42ff

That stack trace is a failure to clean up properly. The real error
occurred earlier. What is in the logs before that?

Mark
> 
> While performing "hot deployment", the second context does not start (see
> stack trace). After restarting the enviroment, both goes up.
> 
> My Host @ server.xml is declared with both unpackWARs="true" and
> undeployOldVersions="true"
> 
> My environment is:
> OS: Ubuntu 16.04 Xenial Xeros
> TOMCAT: 8.0.33 manually instaled in /opt/tomcat
> 
> I'm deploying both the contexts via XML in
> /opt/tomcat/conf/Catalina/domain/ROOT##VERSION.xml
> 
> Version 1.2.13: ROOT##20170217_090754.xml
> https://gist.github.com/tiagojco/2d9ca99281355b218d4d14386bad7459
> 
> Version 1.2.14: ROOT##20170302_092302.xml
> https://gist.github.com/tiagojco/f43d509e06febd3d735df92467610f73
> 
> Maybe relevant:
> - context XML and .war file in partition A
> (/opt/tomcat/conf/Catalina/domain and /apps/wars/domain)
> - Resource dir in partition B (/apps/pd)
> 
> Sorry for being too succint and/or for the grammar errors. English is not
> my first language.
> 
> 
> Thanks in advance.
> 


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



Re: How to enable Native Memory Tracking(NMT) in Tomcat?

2017-03-02 Thread Mark Thomas
On 02/03/17 10:54, Suvendu Sekhar Mondal wrote:
> Hello Everyone,
> 
> I am new here. :)
> 
> Environment:
> Java Version: Java HotSpot(TM) 64-Bit Server VM version 25.91-b15
> (Java version 1.8.0_91-b15)
> Tomcat Version: Tomcat 8.0.20
> OS Version: Microsoft Windows 8.1 Enterprise
> 
> I am trying to enable Native Memory Tracking(NMT) to get internal
> memory usage deatils about Tomcat process which is running on my
> system. I have added following flags to Tomcat's Java options:
> -XX:+UnlockDiagnosticVMOptions
> -XX:NativeMemoryTracking=summary
> -XX:NativeMemoryTracking=detail
> 
> After that I restarted Tomcat. When I tried to use "VM.native_memory"
> command either from JCMD or JMC, I am getting "Native memory tracking
> is not enabled" message. When I shutdown Tomcat, following message is
> getting printed on STDERR log:
> "Java HotSpot(TM) 64-Bit Server VM warning: Native Memory Tracking did
> not setup properly, using wrong launcher?".
> 
> I found this article which discussed about NMT problem in custom JVM launcher:
> https://blogs.oracle.com/poonam/entry/using_nmt_with_custom_jvm
> 
> My question is, does that stands true for Tomcat also? Is there any
> other way to enable NMT in Tomcat?

No idea. How did you start Tomcat?

Mark


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



Error when performing parallel deployment of contexts that exposes a resource dir (org.apache.catalina.webresources.DirResourceSet)

2017-03-02 Thread Tiago Oliveira
Hello,

i guess the title describes our situation. I pasted the stack trace from
catalina.out in a gist:
https://gist.github.com/tiagojco/2e05203095e262c559d2f679dd6b42ff

While performing "hot deployment", the second context does not start (see
stack trace). After restarting the enviroment, both goes up.

My Host @ server.xml is declared with both unpackWARs="true" and
undeployOldVersions="true"

My environment is:
OS: Ubuntu 16.04 Xenial Xeros
TOMCAT: 8.0.33 manually instaled in /opt/tomcat

I'm deploying both the contexts via XML in
/opt/tomcat/conf/Catalina/domain/ROOT##VERSION.xml

Version 1.2.13: ROOT##20170217_090754.xml
https://gist.github.com/tiagojco/2d9ca99281355b218d4d14386bad7459

Version 1.2.14: ROOT##20170302_092302.xml
https://gist.github.com/tiagojco/f43d509e06febd3d735df92467610f73

Maybe relevant:
- context XML and .war file in partition A
(/opt/tomcat/conf/Catalina/domain and /apps/wars/domain)
- Resource dir in partition B (/apps/pd)

Sorry for being too succint and/or for the grammar errors. English is not
my first language.


Thanks in advance.

-- 
[image: Tiago Oliveira] Tiago OliveiraAnálise de sistemas[image: Contato]+55
83 99331.5541 <+5583993315541>/ 83 3506.8310 <+558335068310>[image: Email]
tiago.olive...@behoh.com 
[image: BeHOH]
[image: Facebook] [image: Twitter]
[image: Instagram]

  [image: Website]behoh.com [image: Localização]
goo.gl/FtUZdn 


How to enable Native Memory Tracking(NMT) in Tomcat?

2017-03-02 Thread Suvendu Sekhar Mondal
Hello Everyone,

I am new here. :)

Environment:
Java Version: Java HotSpot(TM) 64-Bit Server VM version 25.91-b15
(Java version 1.8.0_91-b15)
Tomcat Version: Tomcat 8.0.20
OS Version: Microsoft Windows 8.1 Enterprise

I am trying to enable Native Memory Tracking(NMT) to get internal
memory usage deatils about Tomcat process which is running on my
system. I have added following flags to Tomcat's Java options:
-XX:+UnlockDiagnosticVMOptions
-XX:NativeMemoryTracking=summary
-XX:NativeMemoryTracking=detail

After that I restarted Tomcat. When I tried to use "VM.native_memory"
command either from JCMD or JMC, I am getting "Native memory tracking
is not enabled" message. When I shutdown Tomcat, following message is
getting printed on STDERR log:
"Java HotSpot(TM) 64-Bit Server VM warning: Native Memory Tracking did
not setup properly, using wrong launcher?".

I found this article which discussed about NMT problem in custom JVM launcher:
https://blogs.oracle.com/poonam/entry/using_nmt_with_custom_jvm

My question is, does that stands true for Tomcat also? Is there any
other way to enable NMT in Tomcat?

Thanks!
Suvendu

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