Serving static content using embedded tomcat 7

2012-02-07 Thread sanu
Hello,

I am working on embedding tomcat 7 into our application. We have a number of
web apps and the static content is located in a different directory, common
to all webapps.

I am not finding a way to serve this static content. Could somebody please
help me out.

Thanks,
Sandhya

--
View this message in context: 
http://tomcat.10.n6.nabble.com/Serving-static-content-using-embedded-tomcat-7-tp4375155p4375155.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

Re: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Konstantin Kolinko
2012/2/7 Andrew Kujtan :
> OS: Windows 7  32bit
>
> Ver.: Apache Tomcat/7.0.25
>
> Jvm: 1.6.0_14-b08
>
>
>
> I am attaching a shutdown hook from within my webapp to log some info
> after tomcat shuts down,
>
>
>    > Runtime.getRuntime().addShutdownHook(mythread, name +
> ":shutdownHook"));
>

1. Webapp classloader will be stopped when webapp stops. It happens
long before the hook runs. It would not be able to load any classes.
(and it will keep your web application classes in memory, which is
known as PermGen memory leak).

2. The contextClassLoader of your thread will reference Webapp
classloader, unless you explicitly set it to null.

Tomcat has some logic to detect and warn about some PermGen memory
leak patterns. You might have seen those warnings. It is better to
honour them seriously.


>From all of the above adding a shutdown hook from within a web
application is a bad idea.  The hook classes must be in
${catalina.base}/lib folder and you can add  to
conf/server.xml to manage the hook.

(Or better just replace the hook with a Listener).

>
> When I run shutdown.bat from the bin folder the hook runs fine and I get
> my output.
>
>
>
> In some cases however I am forced to shut down tomcat from within the
> webapp, in this case it calls,
>
>
>
>    > org.apache.catalina.startup.Bootstrap.main(new String[] { "stop"
> });
>

or you can get a reference to Context, than walk up its parents chain,
and call Engine.getService().getServer().stop().  I think its
destroy() method will be called automatically when await thread stops.

Anyway calling Bootstrap looks better than calling System.exit() that
someone suggested here.  When Tomcat is run as a service in Windows
you really must not use System.exit() as it will cause problems for
the service launcher.

You can also call stop() method through JMX.

>
>
> Which shuts down tomcat, but in this case the shutdown hook does not get
> fired.
>
>
>
> Can anyone tell me how to programmatically shut down tomcat such that
> the hooks will still fire?
>

As Javadoc for shutdown hooks says, when there are several hooks, they
all will be started at the same time and then run concurrently. The
order between them is random.

Note that the standard hook set by Tomcat shuts down the logging
framework. So if you try to log anything it is likely to be wasted.

>
> What is the difference between running shutdown.bat and calling stop
> programmatically?
>
>

>  java.lang.Thread.State: WAITING (on object monitor)
>   at java.lang.Object.wait(Native Method)
>   - waiting on <0x08bc3ac0> (a  
> org.apache.catalina.startup.Catalina$CatalinaShutdownHook)
>   at java.lang.Thread.join(Thread.java:1143)

Thread.join().

It looks like the calling thread (the one that called System.exit())
just waits until the target thread (CatalinaShutdownHook) finishes.

You should look in the logs to see what is printed there with regards
to the server shutdown sequence. Maybe it waits while some server
component shuts down?

Best regards,
Konstantin Kolinko

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



RE: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Andrew Kujtan
> -Original Message-
> From: Chema [mailto:demablo...@gmail.com]
> Sent: Tuesday, February 07, 2012 5:12 PM
> To: Tomcat Users List
> Subject: Re: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> >> Can I see ApplicationShutdownHooks source code ?
> >
> > That is located in java.lang, you can see the source online...
> >
> 
> Sorry, I meant about *your* app's shutdown hook.
> 

For debugging I'm only using this, and it does run successfully. The
shutdown hook is not blocking anything,

Runtime.getRuntime().addShutdownHook(
new Thread(new Runnable(){
@Override
public void run() {
System.out.println("HARI-KIRI SUCCESSFUL!");
}
}, "shutdownHook"));

> >> What 's com.evertz.registry.ServerRegistryListener ?
> 
> Right
> 
> >
> > This is just the listener that triggers the shutdown call.
> > That the trace shows it that I call System.exit(0), which then runs
> the shutdown hooks, but then gets stuck running the
> CatalinaShutdownHook. It looks like all CatalinaShutdownHook does is
> call catalina.stop, I don't really know how to figure out what it is
> waiting on though.
> >>


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



Re: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Chema
>> Can I see ApplicationShutdownHooks source code ?
>
> That is located in java.lang, you can see the source online...
>

Sorry, I meant about *your* app's shutdown hook.

>> What 's com.evertz.registry.ServerRegistryListener ?

Right

>
> This is just the listener that triggers the shutdown call.
> That the trace shows it that I call System.exit(0), which then runs the 
> shutdown hooks, but then gets stuck running the CatalinaShutdownHook. It 
> looks like all CatalinaShutdownHook does is call catalina.stop, I don't 
> really know how to figure out what it is waiting on though.
>>
>> -
>> 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
>

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



RE: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Andrew Kujtan


> -Original Message-
> From: Chema [mailto:demablo...@gmail.com]
> Sent: Tuesday, February 07, 2012 4:51 PM
> To: Tomcat Users List
> Subject: Re: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> > "Asynchronous Notification 'interface
> com.evertz.registry.ServerRegistryListener: masterChanged'" daemon
> prio=6 tid=0x28c77000 nid=0x16d8 in Object.wait() [0x2899f000]
> >   java.lang.Thread.State: WAITING (on object monitor)
> >        at java.lang.Object.wait(Native Method)
> >        - waiting on <0x08bc3ac0> (a
> org.apache.catalina.startup.Catalina$CatalinaShutdownHook)
> >        at java.lang.Thread.join(Thread.java:1143)
> >        - locked <0x08bc3ac0> (a
> org.apache.catalina.startup.Catalina$CatalinaShutdownHook)
> >        at java.lang.Thread.join(Thread.java:1196)
> >        at
> java.lang.ApplicationShutdownHooks.runHooks(ApplicationShutdownHooks.ja
> va:79)
> >        at
> java.lang.ApplicationShutdownHooks$1.run(ApplicationShutdownHooks.java:
> 24)
> >        at java.lang.Shutdown.runHooks(Shutdown.java:79)
> >        at java.lang.Shutdown.sequence(Shutdown.java:123)
> >        at java.lang.Shutdown.exit(Shutdown.java:168)
> >        - locked <0x23c8bf68> (a java.lang.Class for
> java.lang.Shutdown)
> >        at java.lang.Runtime.exit(Runtime.java:90)
> >        at java.lang.System.exit(System.java:904)
> 
> Can I see ApplicationShutdownHooks source code ?

That is located in java.lang, you can see the source online...

> What 's com.evertz.registry.ServerRegistryListener ?

This is just the listener that triggers the shutdown call. 
That the trace shows it that I call System.exit(0), which then runs the 
shutdown hooks, but then gets stuck running the CatalinaShutdownHook. It looks 
like all CatalinaShutdownHook does is call catalina.stop, I don't really know 
how to figure out what it is waiting on though.
> 
> -
> 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: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Chema
> "Asynchronous Notification 'interface 
> com.evertz.registry.ServerRegistryListener: masterChanged'" daemon prio=6 
> tid=0x28c77000 nid=0x16d8 in Object.wait() [0x2899f000]
>   java.lang.Thread.State: WAITING (on object monitor)
>        at java.lang.Object.wait(Native Method)
>        - waiting on <0x08bc3ac0> (a 
> org.apache.catalina.startup.Catalina$CatalinaShutdownHook)
>        at java.lang.Thread.join(Thread.java:1143)
>        - locked <0x08bc3ac0> (a 
> org.apache.catalina.startup.Catalina$CatalinaShutdownHook)
>        at java.lang.Thread.join(Thread.java:1196)
>        at 
> java.lang.ApplicationShutdownHooks.runHooks(ApplicationShutdownHooks.java:79)
>        at 
> java.lang.ApplicationShutdownHooks$1.run(ApplicationShutdownHooks.java:24)
>        at java.lang.Shutdown.runHooks(Shutdown.java:79)
>        at java.lang.Shutdown.sequence(Shutdown.java:123)
>        at java.lang.Shutdown.exit(Shutdown.java:168)
>        - locked <0x23c8bf68> (a java.lang.Class for java.lang.Shutdown)
>        at java.lang.Runtime.exit(Runtime.java:90)
>        at java.lang.System.exit(System.java:904)

Can I see ApplicationShutdownHooks source code ?
What 's com.evertz.registry.ServerRegistryListener ?

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



RE: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Andrew Kujtan
> -Original Message-
> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> Sent: Tuesday, February 07, 2012 3:09 PM
> To: Tomcat Users List
> Subject: Re: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Andrew,
> 
> On 2/7/12 2:40 PM, Andrew Kujtan wrote:
> > When I call System.exit() tomcat doesn't actually shutdown
> 
> That's weird.
> 
> > it looks like it just is deadlocking or something as I am getting
> > a timeout on the call that runs it.
> 
> What does a thread dump show you?
> 
Yikes, It is showing it is waiting on the Catalina shutdown hook. What is that 
hook doing?

here is the relevant trace,

"Asynchronous Notification 'interface 
com.evertz.registry.ServerRegistryListener: masterChanged'" daemon prio=6 
tid=0x28c77000 nid=0x16d8 in Object.wait() [0x2899f000]
   java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x08bc3ac0> (a 
org.apache.catalina.startup.Catalina$CatalinaShutdownHook)
at java.lang.Thread.join(Thread.java:1143)
- locked <0x08bc3ac0> (a 
org.apache.catalina.startup.Catalina$CatalinaShutdownHook)
at java.lang.Thread.join(Thread.java:1196)
at 
java.lang.ApplicationShutdownHooks.runHooks(ApplicationShutdownHooks.java:79)
at 
java.lang.ApplicationShutdownHooks$1.run(ApplicationShutdownHooks.java:24)
at java.lang.Shutdown.runHooks(Shutdown.java:79)
at java.lang.Shutdown.sequence(Shutdown.java:123)
at java.lang.Shutdown.exit(Shutdown.java:168)
- locked <0x23c8bf68> (a java.lang.Class for java.lang.Shutdown)
at java.lang.Runtime.exit(Runtime.java:90)
at java.lang.System.exit(System.java:904)
at 
com.evertz.web.worker.ShutdownManager.shutDown(ShutdownManager.java:27)
at com.evertz.WebShutdownWrapper.stop(WebShutdownWrapper.java:40)
at com.evertz.WebShutdownWrapper.run(WebShutdownWrapper.java:30)
at com.evertz.util.boot.ShutdownAction.run(ShutdownAction.java:57)
at 
com.evertz.redirect.ClientRedirectionManager.handleNewMaster(ClientRedirectionManager.java:71)
at 
com.evertz.redirect.ClientRedirectionManager.masterChanged(ClientRedirectionManager.java:94)
at 
com.evertz.redirect.ClientRedirectionManager.access$300(ClientRedirectionManager.java:20)
at 
com.evertz.redirect.ClientRedirectionManager$MasterChangeMonitor.masterChanged(ClientRedirectionManager.java:136)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
com.evertz.prod.util.notifier.NotifierInvocationHandler.issueNotification(NotifierInvocationHandler.java:119)
at 
com.evertz.prod.util.notifier.async.AsynchronousInvocationHandler.access$000(AsynchronousInvocationHandler.java:16)
at 
com.evertz.prod.util.notifier.async.AsynchronousInvocationHandler$1.run(AsynchronousInvocationHandler.java:38)
at java.lang.Thread.run(Thread.java:619)

   Locked ownable synchronizers:
- None

> > On the bright side System.exit() does trigger the shutdown hook to
> > be called, even though the server doesn't shut down, it just
> > becomes unresponsive but the process remains and is still bound to
> > all of its ports.
> 
> Again, that seems weird. Do you have some kind of deadlock occurring
> in your shutdown code? It sounds like:
> 
> System.exit: calls your shutdown hook, JVM does not stop
> Bootstrap.main({"stop"}): avoids your shutdown hook, JVM stops
> 
> Maybe you should check your shutdown hook. :)

The shutdown hook is just a sysout now. And that runs successfully.

> 
> > If I call both,
> >
> > org.apache.catalina.startup.Bootstrap.main(new String[] {
> > "stop"}); System.exit(0);
> >
> > Tomcat shuts down, and my hook gets called, but I don't know how
> > ridiculous I want to take this already hacky thing...
> 
> It's a pretty ridiculous hack in any case, right?

Indeed :(

> 
> > Probably stupid question, but is calling System.exit() from a
> > webapp supposed to be able to kill tomcat?
> 
> Yes. It should kill the JVM, which should shut down everything. If you
> want to protect your JVM from webapps that might call System.exit(),
> then you need to run under a SecurityManager.
> 
> - -chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk8xhMEACgkQ9CaO5/Lv0PBXCgCgmM81JJasiDH1rD3lx5yHJTa6
> 8dsAnii8qNVXOpPbSVNJCfRGnZmPoyV/
> =Xsi4
> -END PGP SIGNATURE-
> 
> -
> To unsubscribe, e-mai

Re: Running Tomcat on Port 80 with Fedora 16 without IP tables redirect

2012-02-07 Thread Mark H. Wood
On Tue, Feb 07, 2012 at 12:06:12PM -0600, Ole Ersoy wrote:
> Thanks Andre and John.  I used jsvc to run tomcat before.  Maybe
> that's what got me around the root user restriction.

That is exactly what it is for, and I can't imagine why every distro
doesn't use it instead of the arcane scripting that I've seen employed.

-- 
Mark H. Wood, Lead System Programmer   mw...@iupui.edu
Asking whether markets are efficient is like asking whether people are smart.


pgp77CHMbG39e.pgp
Description: PGP signature


Re: Question regarding mappings for CVE-2005-4836

2012-02-07 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Christopher,

On 2/7/12 3:01 PM, Christopher Restorff wrote:
> I have a question regarding CVE-2005-4836: 
> http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-4836

Wow. Blast from the past.

> The security bulletin, http://tomcat.apache.org/security-4.html, 
> mentions that it will not be fixed in 4.x. However, there is no 
> indication as to whether it affects 5.x or beyond.

Sure there is: look at the section on the page above titled
"Vulnerable software and versions". It clearly says that certain
versions of Tomcat 5.0.x and 5.0.x are affected.

> Is this issue persistent in the 5, 6, and 7 versions? If not,
> which versions are not affected.

If you carefully read the security report for Tomcat 4, you'll see
that the bug exists in a deprecated connector. If you are using the
standard Coyote connector, then you are safe.

For completeness, these are the connectors that are vulnerable to this
issue:
org.apache.coyote.tomcat4.CoyoteConnector
org.apache.catalina.connector.http.HttpConnector

Neither of these classes are included in the current 5.5 line
(5.5.35), nor are they included in the current 6.0 line (6.0.35), nor
are they included in the current 7.0 line (7.0.25).

If you are using a currently-supported version of Tomcat and you are
up to date, then you are not vulnerable to this ancient vulnerability.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8xiEwACgkQ9CaO5/Lv0PDf0wCgqqpipQWaqzK6WiFzM6VYxphD
MFwAoI/ehmi+V/K9XUSJSReMxiFGjuTQ
=5uIJ
-END PGP SIGNATURE-

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



Re: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Andrew,

On 2/7/12 2:40 PM, Andrew Kujtan wrote:
> When I call System.exit() tomcat doesn't actually shutdown

That's weird.

> it looks like it just is deadlocking or something as I am getting
> a timeout on the call that runs it.

What does a thread dump show you?

> On the bright side System.exit() does trigger the shutdown hook to
> be called, even though the server doesn't shut down, it just
> becomes unresponsive but the process remains and is still bound to 
> all of its ports.

Again, that seems weird. Do you have some kind of deadlock occurring
in your shutdown code? It sounds like:

System.exit: calls your shutdown hook, JVM does not stop
Bootstrap.main({"stop"}): avoids your shutdown hook, JVM stops

Maybe you should check your shutdown hook. :)

> If I call both,
> 
> org.apache.catalina.startup.Bootstrap.main(new String[] {
> "stop"}); System.exit(0);
> 
> Tomcat shuts down, and my hook gets called, but I don't know how 
> ridiculous I want to take this already hacky thing...

It's a pretty ridiculous hack in any case, right?

> Probably stupid question, but is calling System.exit() from a
> webapp supposed to be able to kill tomcat?

Yes. It should kill the JVM, which should shut down everything. If you
want to protect your JVM from webapps that might call System.exit(),
then you need to run under a SecurityManager.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8xhMEACgkQ9CaO5/Lv0PBXCgCgmM81JJasiDH1rD3lx5yHJTa6
8dsAnii8qNVXOpPbSVNJCfRGnZmPoyV/
=Xsi4
-END PGP SIGNATURE-

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



Re: Question regarding mappings for CVE-2005-4836

2012-02-07 Thread Au, Leon
On 2/7/12 12:01 PM, "Christopher Restorff"
 wrote:

>Hello,
>
>I have a question regarding CVE-2005-4836:
>http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-4836
>
>The security bulletin, http://tomcat.apache.org/security-4.html,
>mentions that it will not be fixed in 4.x. However, there is no
>indication as to whether it affects 5.x or beyond. Is this issue
>persistent in the 5, 6, and 7 versions? If not, which versions are not
>affected.

The link that you posted has a section on vulnerable software and
versions.  My guess is that it has the complete list of all versions
affected.

Leon

>
>Any help will be greatly appreciated. Thank you for your time.
>
>Sorry if this is a repost. I think I sent it to the wrong address and
>never got any responses/confirmation that it went through.
>
>
>-
>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



Question regarding mappings for CVE-2005-4836

2012-02-07 Thread Christopher Restorff

Hello,

I have a question regarding CVE-2005-4836:
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-4836

The security bulletin, http://tomcat.apache.org/security-4.html,
mentions that it will not be fixed in 4.x. However, there is no
indication as to whether it affects 5.x or beyond. Is this issue
persistent in the 5, 6, and 7 versions? If not, which versions are not
affected.

Any help will be greatly appreciated. Thank you for your time.

Sorry if this is a repost. I think I sent it to the wrong address and 
never got any responses/confirmation that it went through.



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



RE: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Andrew Kujtan
> -Original Message-
> From: Caldarale, Charles R [mailto:chuck.caldar...@unisys.com]
> Sent: Tuesday, February 07, 2012 1:39 PM
> To: Tomcat Users List
> Subject: RE: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> > From: Andrew Kujtan [mailto:akuj...@evertz.com]
> > Subject: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> > OS: Windows 7  32bit
> > Ver.: Apache Tomcat/7.0.25
> > Jvm: 1.6.0_14-b08
> 
> Thanks for that.
> 
> > I am attaching a shutdown hook from within my webapp to log
> > some info after tomcat shuts down,
> 
> That really doesn't sound like a good idea at all.  I would think you
> should be using a ServletContextListener.
Unfortunately the actions need to happen after tomcat has shutdown, not
just my webapp.
> 
> > Can anyone tell me how to programmatically shut down tomcat
> > such that the hooks will still fire?
> 
> There's no real provision for doing so, since that's not a decision a
> webapp should be making. 

I agree, but I don't have a choice, boss says it must kill itself if
some scenario happens.

> There's always System.exit()...
> 
When I call System.exit() tomcat doesn't actually shutdown, it looks
like it just is deadlocking or something as I am getting a timeout on
the call that runs it. On the bright side System.exit() does trigger the
shutdown hook to be called, even though the server doesn't shut down, it
just becomes unresponsive but the process remains and is still bound to
all of its ports.

If I call both,

org.apache.catalina.startup.Bootstrap.main(new String[] { "stop"});
System.exit(0);

Tomcat shuts down, and my hook gets called, but I don't know how
ridiculous I want to take this already hacky thing...

Probably stupid question, but is calling System.exit() from a webapp
supposed to be able to kill tomcat?

>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
> PROPRIETARY MATERIAL and is thus for use only by the intended
> recipient. If you received this in error, please contact the sender
and
> delete the e-mail and its attachments from all computers.
> 
> 
> -
> 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: Web app calls JMS over SSL - certificates

2012-02-07 Thread Caldarale, Charles R
> From: Peter Kleczka [mailto:pklec...@gmail.com] 
> Subject: Re: Web app calls JMS over SSL - certificates

> What I would like to do is tell my application where my keystore 
> files are located rather than load them through the JVM.

So what stops you from doing that?  There are numerous ways to communicate 
configuration information to a webapp; read the servlet spec and the Tomcat doc 
for the  element.

> My Tomcat specific question then is, will the Tomcat container
> let me do that from the app level

Let you do what, exactly?  You have too many potential antecedents of "that" to 
figure out what you're referring to.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


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



RE: Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Caldarale, Charles R
> From: Andrew Kujtan [mailto:akuj...@evertz.com] 
> Subject: Shutdown Hooks not firing when tomcat is shutdown from within a 
> webapp

> OS: Windows 7  32bit
> Ver.: Apache Tomcat/7.0.25
> Jvm: 1.6.0_14-b08

Thanks for that. 

> I am attaching a shutdown hook from within my webapp to log 
> some info after tomcat shuts down,

That really doesn't sound like a good idea at all.  I would think you should be 
using a ServletContextListener.
 
> Can anyone tell me how to programmatically shut down tomcat 
> such that the hooks will still fire? 

There's no real provision for doing so, since that's not a decision a webapp 
should be making.  There's always System.exit()...

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


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



Shutdown Hooks not firing when tomcat is shutdown from within a webapp

2012-02-07 Thread Andrew Kujtan
OS: Windows 7  32bit

Ver.: Apache Tomcat/7.0.25

Jvm: 1.6.0_14-b08

 

I am attaching a shutdown hook from within my webapp to log some info
after tomcat shuts down,

 

> Runtime.getRuntime().addShutdownHook(mythread, name +
":shutdownHook"));

 

When I run shutdown.bat from the bin folder the hook runs fine and I get
my output. 

 

In some cases however I am forced to shut down tomcat from within the
webapp, in this case it calls,

 

> org.apache.catalina.startup.Bootstrap.main(new String[] { "stop"
});

 

Which shuts down tomcat, but in this case the shutdown hook does not get
fired. 

 

Can anyone tell me how to programmatically shut down tomcat such that
the hooks will still fire? 

What is the difference between running shutdown.bat and calling stop
programmatically?

 

Regards,

Andrew Kujtan

 



Re: Running Tomcat on Port 80 with Fedora 16 without IP tables redirect

2012-02-07 Thread Mark Eggers
- Original Message -

> From: Ole Ersoy 
> To: Tomcat Users List 
> Cc: 
> Sent: Tuesday, February 7, 2012 10:06 AM
> Subject: Re: Running Tomcat on Port 80 with Fedora 16 without IP tables 
> redirect
> 
>T hanks Andre and John.  I used jsvc to run tomcat before.  Maybe that's what 
> got me around the root user restriction.  Seems the simplest solution is to 
> just 
> use NAT.  There are instructions at the bottom of this post for anyone else 
> interested.
> 
> http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos
> 
> Cheers,
> - Ole
> 
> On 02/07/2012 11:38 AM, John Renne wrote:
>> 
>>  On Feb 7, 2012, at 6:14 PM, Ole Ersoy wrote:
>> 
>>>  Hi,
>>> 
>>>  In the past I have been able to run tomcat on port 80 under a 
> "tomcat" user.  It seems like the latest versions of Fedora require 
> that tomcat either be run as root or requests to 8080 have to be redirected 
> using iptables.   Can anyone confirm this?
>>> 
>>  On each unix you will need root privileges to bind to a socket below 1024. 
> Tomcat is no different so it will need either root privileges, or a port over 
> 1024 (default indeed 8080)


apache-commons-daemon-jsvc appears to still be available for Fedora 16. Just 
looking at the package contents, it looks like you'll be on your own for 
writing the scripts though.


. . . . just my two cents.
/mde/

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



Re: Running Tomcat on Port 80 with Fedora 16 without IP tables redirect

2012-02-07 Thread Ole Ersoy

Thanks Andre and John.  I used jsvc to run tomcat before.  Maybe that's what 
got me around the root user restriction.  Seems the simplest solution is to 
just use NAT.  There are instructions at the bottom of this post for anyone 
else interested.

http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos

Cheers,
- Ole

On 02/07/2012 11:38 AM, John Renne wrote:


On Feb 7, 2012, at 6:14 PM, Ole Ersoy wrote:


Hi,

In the past I have been able to run tomcat on port 80 under a "tomcat" user.  
It seems like the latest versions of Fedora require that tomcat either be run as root or 
requests to 8080 have to be redirected using iptables.   Can anyone confirm this?


On each unix you will need root privileges to bind to a socket below 1024. 
Tomcat is no different so it will need either root privileges, or a port over 
1024 (default indeed 8080)

John


-
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: Running Tomcat on Port 80 with Fedora 16 without IP tables redirect

2012-02-07 Thread John Renne

On Feb 7, 2012, at 6:14 PM, Ole Ersoy wrote:

> Hi,
> 
> In the past I have been able to run tomcat on port 80 under a "tomcat" user.  
> It seems like the latest versions of Fedora require that tomcat either be run 
> as root or requests to 8080 have to be redirected using iptables.   Can 
> anyone confirm this?
> 
On each unix you will need root privileges to bind to a socket below 1024. 
Tomcat is no different so it will need either root privileges, or a port over 
1024 (default indeed 8080)

John


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



Re: Running Tomcat on Port 80 with Fedora 16 without IP tables redirect

2012-02-07 Thread André Warnier

Ole Ersoy wrote:

Hi,

In the past I have been able to run tomcat on port 80 under a "tomcat" 
user.  It seems like the latest versions of Fedora require that tomcat 
either be run as root or requests to 8080 have to be redirected using 
iptables.   Can anyone confirm this?


What you probably mean is that the Fedora repackaged distribution of Tomcat installs it 
that way by default, no ?

Tomcat itself does not require that.
So, before someone else here tells you to install a genuine official Tomcat from the 
Tomcat website, have you checked on the Fedora support list ?
Otherwise, it should be quite simple to change the port by modifying the corresponding 
 tag in Tomcat's server.xml.

But then of course you might have to fight with SE-Linux and such things.
For which you may need the Fedora support list anyway, so why not start there ?

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



Re: Web app calls JMS over SSL - certificates

2012-02-07 Thread Peter Kleczka
Chuck

Thanks, but my question really does have to do with Tomcat. The ActiveMQ is
actually on another server and my application hosted on Tomcat needs to
pull messages off of ActiveMQ over SSL.  What I would like to do is tell my
application where my keystore files are located rather than load them
through the JVM. Another list member asked me how the message broker loads
its keystore files, perhaps as a general hint to how I might load them from
my web app. My Tomcat specific question then is, will the Tomcat container
let me do that from the app level, and if not, can I configure it on the
Tomcat server other than setting the keystore properties in the JVM VM
startup parameters.

On Tue, Feb 7, 2012 at 9:10 AM, Caldarale, Charles R <
chuck.caldar...@unisys.com> wrote:

> > From: Peter Kleczka [mailto:pklec...@gmail.com]
> > Subject: Re: Web app calls JMS over SSL - certificates
>
> > I am using ActiveMQ and its activemq.xml file has a section where the
> > keystore and truststore point to those files. So I assume that means that
> > there is a way to set these at runtime.
>
> That would be a topic for the ActiveMQ group; nothing to do with Tomcat.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail and
> its attachments from all computers.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Running Tomcat on Port 80 with Fedora 16 without IP tables redirect

2012-02-07 Thread Ole Ersoy

Hi,

In the past I have been able to run tomcat on port 80 under a "tomcat" user.  
It seems like the latest versions of Fedora require that tomcat either be run as root or 
requests to 8080 have to be redirected using iptables.   Can anyone confirm this?

TIA,
- Ole

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



RE: Web app calls JMS over SSL - certificates

2012-02-07 Thread Caldarale, Charles R
> From: Peter Kleczka [mailto:pklec...@gmail.com] 
> Subject: Re: Web app calls JMS over SSL - certificates

> I am using ActiveMQ and its activemq.xml file has a section where the
> keystore and truststore point to those files. So I assume that means that
> there is a way to set these at runtime.

That would be a topic for the ActiveMQ group; nothing to do with Tomcat.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


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



Re: Web app calls JMS over SSL - certificates

2012-02-07 Thread Peter Kleczka
I am using ActiveMQ and its activemq.xml file has a section where the
keystore and truststore point to those files. So I assume that means that
there is a way to set these at runtime. Still leaves me with the question
of whether I can set these at runtime from my app on Tomcat.

On Mon, Feb 6, 2012 at 11:50 PM, Pid *  wrote:

> On 6 Feb 2012, at 23:10, Peter Kleczka  wrote:
>
> > Hello
> >
> > I have a web app on Tomcat 6.0.24. The app needs to call a JMS app on
> > another server over SSL. I installed the keystore/truststore files in
> > $CatalinaHome/conf/certs and set VM arguments so that the JVM knows where
> > to find the certs. The server administrator says that I should
> encapsulate
> > these certs within the WAR file and that we should not have to set the VM
> > arguments.
> >
> > The documentation that I have read so far seems to only discuss how to
> set
> > up SSL on Tomcat.
> >
> > Is there a way that Tomcat or my web app can automatically load the certs
> > without setting VM arguments?
>
> How are you configuring JMS now?
>
> Which JMS provider/lib are you using?
>
>
> p
>
>
>
> >
> > Thanks kindly in advance.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: How can I access tomcat's logs using my jsp?

2012-02-07 Thread André Warnier

André Warnier wrote:

Pid wrote:

On 07/02/2012 09:07, André Warnier wrote:

For once, it may be best to top-post.

Anyone feels like making a FAQ out of this thread ?
It looks like a generic-enough question and answer.


I don't think I want to encourage publishing logs via the same
container.  I've seen all sorts of private data published in log files.


I wasn't talking about "logs" per se (I agree on that one).
What I meant was more like :

How-To : create a simple "webapp" which publishes the content of an 
arbitrary directory containing static documents, without having to write 
a special-purpose JSP page or servlet, and without compromising security.


At the same time, it is almost a book-perfect example of what can be 
done with the normal webapp deployment rules, where to put a context 
file, what the default servlet does, etc..




Now one more question about this :
Suppose someone follows exactly the steps outlined by Chuck before.
And then suppose that through the Manager, one triggers an "un-deploy" of this 
application.
Will Tomcat then delete all the files inside that directory ?
And if yes, is there a way to prevent that ?

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



Re: How can I access tomcat's logs using my jsp?

2012-02-07 Thread André Warnier

Pid wrote:

On 07/02/2012 09:07, André Warnier wrote:

For once, it may be best to top-post.

Anyone feels like making a FAQ out of this thread ?
It looks like a generic-enough question and answer.


I don't think I want to encourage publishing logs via the same
container.  I've seen all sorts of private data published in log files.


I wasn't talking about "logs" per se (I agree on that one).
What I meant was more like :

How-To : create a simple "webapp" which publishes the content of an arbitrary directory 
containing static documents, without having to write a special-purpose JSP page or 
servlet, and without compromising security.


At the same time, it is almost a book-perfect example of what can be done with the normal 
webapp deployment rules, where to put a context file, what the default servlet does, etc..




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



Re: How can I access tomcat's logs using my jsp?

2012-02-07 Thread Pid
On 07/02/2012 09:07, André Warnier wrote:
> For once, it may be best to top-post.
> 
> Anyone feels like making a FAQ out of this thread ?
> It looks like a generic-enough question and answer.

I don't think I want to encourage publishing logs via the same
container.  I've seen all sorts of private data published in log files.


p

> Lev A KARATUN wrote:
>> Charles,
>>
>> I made the adjustments and it works now.
>>
>> Thank you!
>>
>> Best Regards, Karatun Lev,
>>
>>
>> "Caldarale, Charles R"  wrote on
>> 06.02.2012 18:41:18:
>>
>>> "Caldarale, Charles R"  06.02.2012 18:42
>>>
>>> Please respond to
>>> "Tomcat Users List" 
>>>
>>> To
>>>
>>> Tomcat Users List 
>>>
>>> cc
>>>
>>> Subject
>>>
>>> RE: How can I access tomcat's logs using my jsp?
>>>
 From: Lev A KARATUN [mailto:lev.kara...@raiffeisen.ru] Subject: RE:
 How can I access tomcat's logs using my jsp?
 when I'm copypasting the default servlet block to
 $CATALINA_BASE/logs/WEB-INF/web.xml, the application
 no longer works.
>>> There's an additional step required for Tomcat 6 that's not necessary
>>> for Tomcat 7.  So either upgrade, or do the following:
>>>
>>> Change the name of the DefaultServlet in logs/WEB-INF/web.xml to
>>> logsdefault (or some other unique label):
>>>
>>> logsdefault
>>>
>>> and add a  for it:
>>>
>>> 
>>> logsdefault
>>> /
>>> 
>>>
>>> Tomcat 6 does not allow you to override the  settings
>>> in the global conf/web.xml, but Tomcat 7 does.
>>>
 And one more question - if myapp's docBase is set to 
>> $CATALINA_BASE/logs ,
 does it matter what is in the webapps/myapp folder?
>>> Assuming the "myapp" you're referring to is the one for accessing
>>> Tomcat's logs, you should not risk problems by also having a
>>> webapps/myapp.  It shouldn't hurt, but...
>>>
>>> And, as usual, ignore Martin G's irrelevant ramblings.
>>>
>>>  - Chuck
>>>
>>>
>>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
>>> PROPRIETARY MATERIAL and is thus for use only by the intended
>>> recipient. If you received this in error, please contact the sender
>>> and delete the e-mail and its attachments from all computers.
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>>
>>
>>
>>
>> ---
>> This message and any attachment are confidential and may be privileged
>> or otherwise protected from disclosure. If you are not the intended
>> recipient any use, distribution, copying or disclosure is strictly
>> prohibited. If you have received this message in error, please notify
>> the sender immediately either by telephone or by e-mail and delete
>> this message and any attachment from your system. Correspondence via
>> e-mail is for information purposes only. ZAO Raiffeisenbank neither
>> makes nor accepts legally binding statements by e-mail unless
>> otherwise agreed. ---
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 


-- 

[key:62590808]



signature.asc
Description: OpenPGP digital signature


Re: How can I access tomcat's logs using my jsp?

2012-02-07 Thread André Warnier

For once, it may be best to top-post.

Anyone feels like making a FAQ out of this thread ?
It looks like a generic-enough question and answer.



Lev A KARATUN wrote:

Charles,

I made the adjustments and it works now.

Thank you!

Best Regards, 
Karatun Lev,



"Caldarale, Charles R"  wrote on 06.02.2012 
18:41:18:


"Caldarale, Charles R"  
06.02.2012 18:42


Please respond to
"Tomcat Users List" 

To

Tomcat Users List 

cc

Subject

RE: How can I access tomcat's logs using my jsp?

From: Lev A KARATUN [mailto:lev.kara...@raiffeisen.ru] 
Subject: RE: How can I access tomcat's logs using my jsp?
when I'm copypasting the default servlet block to 
$CATALINA_BASE/logs/WEB-INF/web.xml, the application

no longer works.
There's an additional step required for Tomcat 6 that's not 
necessary for Tomcat 7.  So either upgrade, or do the following:


Change the name of the DefaultServlet in logs/WEB-INF/web.xml to 
logsdefault (or some other unique label):


logsdefault

and add a  for it:


logsdefault
/


Tomcat 6 does not allow you to override the  settings 
in the global conf/web.xml, but Tomcat 7 does.


And one more question - if myapp's docBase is set to 
$CATALINA_BASE/logs , 

does it matter what is in the webapps/myapp folder?
Assuming the "myapp" you're referring to is the one for accessing 
Tomcat's logs, you should not risk problems by also having a 
webapps/myapp.  It shouldn't hurt, but...


And, as usual, ignore Martin G's irrelevant ramblings.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 
PROPRIETARY MATERIAL and is thus for use only by the intended 
recipient. If you received this in error, please contact the sender 
and delete the e-mail and its attachments from all computers.



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





---
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient any use, distribution, copying or disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately either by telephone or by e-mail and delete this message and any attachment from your system. Correspondence via e-mail is for information purposes only. ZAO Raiffeisenbank neither makes nor accepts legally binding statements by e-mail unless otherwise agreed. 
---



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