Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Thomas Freitag
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Chuck,

On 06/09/2011 07:52 AM, Caldarale, Charles R wrote:
 Can you display the original request URL, or perhaps enable the 
 AccessLogValve?  (I'm not sure if that captures forwards, however.)

It does. The redirect URL set to the client can be logged with %{Location}o.

Regards,
- -- 
Thomas Freitag
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk3wZy8ACgkQGE5pHr3PKuVDfQCfVV8nB4w6hB0LTD+D7jh9I47B
kzEAoIEe01ttRrFab0MEuE13U7nkBy9u
=dz8u
-END PGP SIGNATURE-

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



Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread André Warnier

Thomas Freitag wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Chuck,

On 06/09/2011 07:52 AM, Caldarale, Charles R wrote:

Can you display the original request URL, or perhaps enable the AccessLogValve? 
 (I'm not sure if that captures forwards, however.)


It does. The redirect URL set to the client can be logged with %{Location}o.


I don't think we are talking about a redirect response sent to the client here.
That would definitely /not/ work without a scheme.

I think what Chuck meant, is that the /current/ request could be the result of a previous 
internal forward without a scheme.



By the way :

(Interface HttpServletResponse, Javaee 5)

encodeUrl

String encodeUrl(String url)

Deprecated. As of version 2.1, use encodeURL(String url) instead


Maybe it's worth replacing encodeUrl by encodeURL, and see if the problem still 
happens.

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



Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Felix Schumacher
Am Donnerstag, den 09.06.2011, 04:53 +0100 schrieb Jocelyn Ireson-Paine:
 Hi,
 
 I'm getting sporadic null-pointer exceptions from 'response.encodeUrl'. 
 This is with Tomcat 7.0.14, the latest stable version to which I upgraded 
 an hour ago, and Java 1.6.0_26, which again I upgraded to at the same 
 time, under Windows XP. I also got the error under Tomcat 5.5.33, which is 
 why I tried upgrading. I uninstalled old Tomcats and Javas before 
 upgrading.
 
 Here's a trace of the error:
java.lang.NullPointerException
   at 
 org.apache.catalina.connector.Response.toAbsolute(Response.java:1594)
   at 
 org.apache.catalina.connector.Response.encodeURL(Response.java:1198)
   at 
 org.apache.catalina.connector.ResponseFacade.encodeUrl(ResponseFacade.java:422)
   at sharesim.ValueGame.encodeUrl(ValueGame.java:468)
 The fourth line of the trace is my code.
 
 To get some diagnostics, I encapsulated 'response.encodeUrl' in the 
 following method, and used 'println' to print to Tomcat's log. This method 
You can use the servlet api's log method to log inside a web
application, or even better use a logging-framework.

 is the one mentioned on the fourth line of the above trace.
private final static String encodeUrl( HttpServletResponse response
 , String url
 )
{
  System.out.println( encodeUrl );
  System.out.println( response= + response );
  System.out.println( url= + url );
  String result = null;
  if ( response == null )
result = not on Web;
  else
result = response.encodeUrl( url );
  System.out.println( result= + result );
  return result;
}
 
 As mentioned above, the errors are sporadic. My redirection code gets 
 called on my server when I submit one of my forms. But sometimes, the 
 submit works; sometimes it doesn't. Here are two successive traces from 
 the above method:
encodeUrl
response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
url=/ResearcherValueGame1.jsp
result=/ResearcherValueGame1.jsp
 
encodeUrl
response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
url=/ResearcherValueGame1.jsp
 The first one worked; the second crashed rather than returning the encoded 
 URL. The URL to be encoded is the same in both cases, and 'response' is 
 evidently the same instance. I don't know how to dump 'response' in order 
 to show relevant fields (whichever they are), but am happy to try it if 
 someone can suggest how.
You haven't shown us the code, which calls your encodeUrl. Most of the
times someone reports sporadic errors while working with responses, he
is saving references to the responses in a class variable.

Could this be your problem?

Felix
 
 I've found a few mentions on Google of such errors, but nothing definite 
 about it happening in Tomcat 7. One discussion which I thought I'd seen, 
 but can't find again, seemed to suggest that the problem occurred on 
 version 5, possibly because of a missing 'synchronized'. I've not seen 
 anything in recent postings to this list.
 
 I wondered whether the problem might be caused by the browser creating 
 malformed cookies, or some such. (I'm using session-handling.) However, 
 this seems unlikely, as the error occurs regardless of whether I use 
 Firefox, Internet Explorer, or Google Chrome.
 
 Any ideas?
 
 Jocelyn Ireson-Paine
 http://www.j-paine.org
 
 Jocelyn's Cartoons:
 http://www.j-paine.org/blog/jocelyns_cartoons/
 
 
 -
 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: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Jocelyn Ireson-Paine

On Thu, 9 Jun 2011, André Warnier wrote:


...

By the way :

(Interface HttpServletResponse, Javaee 5)
encodeUrl
String encodeUrl(String url)
   Deprecated. As of version 2.1, use encodeURL(String url) instead

Maybe it's worth replacing encodeUrl by encodeURL, and see if the problem 
still happens.


Thanks for the suggestion, André. I've just tried that, and the problem 
still happens.


Jocelyn

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

Re: how to correct stop a thread and avoid leaks

2011-06-09 Thread Pid
On 07/06/2011 16:33, Bill Miller wrote:
 If you want to work with threads in tomcat you need to know about the Tomcat
 org.apache.catalina.LifecycleListener interface.

Eh?  Why would you need to put Tomcat specific dependencies in a spec
compliant Servlet container?  The above is simply not true.

The OP use of a ServletContextListener is perfectly valid, (even if the
rest of the code is a little odd).


p



signature.asc
Description: OpenPGP digital signature


Document of Tomcat 6.0.32.

2011-06-09 Thread Nash
Hi!
I want to know how I can get the API Document of Tomcat 6.0.32 so I can refer 
it regardless of Internet connection.
Thank you a lot!
Best wishes!

2011-06-09 



Nash 


Re: Tomcat 7.0.14 / 6.0.32 session gets obviously invalid after request / JSESSIONID changes

2011-06-09 Thread Pid
On 08/06/2011 10:18, Sascha Hesse wrote:
 Hello all,
 
 I'm hosting our spring mvc 3.0.5 application in tomcat 7.0.14 and also
 tried 6.0.32
 
 The server is hosting two webapps.
 
 The frontend: http://localhost:50012/frontend
 The backend: http://localhost:50012/backend
 
 The Request-Flow looks as following:
 
 User: http://localhost:50012/frontend/index.htm
 AJAX Frontend:
 http://localhost:50012/frontend/setFilter.htm
 AJAX Backend:
 http://localhost:50012/backend/setFilter.htm
 User: onClick()
  AJAX Frontend: http://localhost:50012/frontend/setFilter.htm
  AJAX Backend: http://localhost:50012/backend/setFilter.htm
 
 
 The corresponding request-pairs to frontend and backend should be
 identified via the sessionID.
 
 Tomcat is doing that via Cookie JSESSIONID. I configured Tomcat
 according to https://issues.apache.org/bugzilla/show_bug.cgi?id=48379
 Context sessionCookiePath=/ sessionCookieDomain=.localhost
 
 If I look into the cookies in request and response the following
 happens (note I shortened the sessionIds)
 
 
  User: http://localhost:50012/frontend/index.htm
  ResponseHeader: -
  RequestHeader: JSESSIONID=1
 AJAX Frontend: http://localhost:50012/frontend/setFilter.htm
  ResponseHeader: -
  RequestHeader: JSESSIONID=1
 AJAX Backend: http://localhost:50012/backend/setFilter.htm
  ResponseHeader: set JSESSIONID=2
  RequestHeader: JSESSIONID=1
 User: onClick()
 AJAX Frontend: http://localhost:50012/frontend/setFilter.htm
  ResponseHeader: setJSESSIONID=3
  RequestHeader: JSESSIONID=2
 AJAX Backend: http://localhost:50012/backend/setFilter.htm
  ResponseHeader: -
  RequestHeader: JSESSIONID=2
 
 ...the sessionID alsways changes when I'm requesting the other
 context. Has anyone a hint according to this?

Does the AJAX javascript set the session id in a cookie header, or
append it as a path attribute?

You can't rely on the browser to do this automagically for you in most
AJAX libs.


p




signature.asc
Description: OpenPGP digital signature


Re: Document of Tomcat 6.0.32.

2011-06-09 Thread Markus Schönhaber
09.06.2011 10:13, Nash:

 I want to know how I can get the API Document of Tomcat 6.0.32 so I can refer 
 it regardless of Internet connection.
 Thank you a lot!

Download the fulldocs package, which, as it seems, is not linked to from
the download page of 6.0.
The name of the package is apache-tomcat-6.0.32-fulldocs.tar.gz. You can
get it from the download mirrors, for example
http://ftp.fernuni-hagen.de/ftp-dir/pub/mirrors/www.apache.org/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32-fulldocs.tar.gz

-- 
Regards
  mks

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



Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Thomas Freitag
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi André,

On 09.06.11 um 09:07, André Warnier wrote:
 It does. The redirect URL set to the client can be logged with %{Location}o.

 I don't think we are talking about a redirect response sent to the client 
 here.
 That would definitely /not/ work without a scheme.

You're right.

Regards,
- -- 
Thomas Freitag
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk3wg+UACgkQGE5pHr3PKuXyDQCeO9d1x8ScRhVjpbWX+zJ7MVAh
b2EAnjv1dRtrD2GCjaiWL6pXn4QB0PSb
=K0td
-END PGP SIGNATURE-

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



Re: serving pre-compressed files

2011-06-09 Thread Pid
On 08/06/2011 16:03, Jesse Farinacci wrote:
 Greetings,
 
 I'm using Tomcat 7.0.14 and IBM Java 6. As part of my web
 application's bundling mechanism (via Maven) I have the ability to
 pre-gzip compress static resources. I'd like Tomcat to detect that a
 request for /path/to/resource has /path/to/resource.gz available, and
 serve the gzip'd content instead, if the user agent supports it.
 
 Is there anything like this available? If not, what suggestions do you
 have? Thanks,

Not quite the same, but similar, is the following:

If you're using Tomcat 7, you have Servlet 3 compatibility, which means
you can serve resources out of a specially* constructed jar.


p

* Put resources in: myresource.jar:/META-INF/resources and they will
appear as from the root of the webapp.

e.g.  /META-INF/resources/logo.gif - /logo.gif



signature.asc
Description: OpenPGP digital signature


RE: Auth in Context.xml

2011-06-09 Thread Umesh Bhatt
Hi,

Sorry I meant auth not Auth.  Thanks for correction.
I used getConnection(username, password) but it gives me an error as It is not 
supported and doesn't connect with DB.

Thanks,
Umesh

-Original Message-
From: Caldarale, Charles R [mailto:chuck.caldar...@unisys.com]
Sent: Thursday, June 09, 2011 10:44 AM
To: Tomcat Users List
Subject: RE: Auth in Context.xml

 From: Umesh Bhatt [mailto:umesh_bh...@mindtree.com]
 Subject: RE: Auth in Context.xml

 I am using Tomcat 6.0.

6.0.what?  There are 32 versions of 6.0; be precise.

 In Context.xml file

Again, if you have a file named Context.xml, it will be ignored.  Files must be 
named (and located) properly for Tomcat to use them.  Exactly what is the file 
name, where is it located, and what are the full contents of the file?

 I found JDBC resource configuration as below.

 Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource
maxActive=100 maxIdle=30 maxWait=1
username=javauser password=javadude 
 driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/javatest/

 It has Auth attribute

No, it has an auth attribute, not Auth; everything here is case-sensitive, so 
get it right.

 I don't want to use tomcat to setup connection rather want my
 application to setup connection with DB.

Still fooling yourself into thinking it's safer to bury the password in the 
application than in the configuration file?  Waste of time.  But if you insist 
on doing it, use the getConnection() method that has userid and password as 
arguments.

 - 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




http://www.mindtree.com/email/disclaimer.html

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



Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Jocelyn Ireson-Paine

On Thu, 9 Jun 2011, Felix Schumacher wrote:


Am Donnerstag, den 09.06.2011, 04:53 +0100 schrieb Jocelyn Ireson-Paine:

Hi,

I'm getting sporadic null-pointer exceptions from 'response.encodeUrl'.
This is with Tomcat 7.0.14, the latest stable version to which I upgraded
an hour ago, and Java 1.6.0_26, which again I upgraded to at the same
time, under Windows XP. I also got the error under Tomcat 5.5.33, which is
why I tried upgrading. I uninstalled old Tomcats and Javas before
upgrading.

Here's a trace of the error:
   java.lang.NullPointerException
at
org.apache.catalina.connector.Response.toAbsolute(Response.java:1594)
at
org.apache.catalina.connector.Response.encodeURL(Response.java:1198)
at
org.apache.catalina.connector.ResponseFacade.encodeUrl(ResponseFacade.java:422)
at sharesim.ValueGame.encodeUrl(ValueGame.java:468)
The fourth line of the trace is my code.

To get some diagnostics, I encapsulated 'response.encodeUrl' in the
following method, and used 'println' to print to Tomcat's log. This method

You can use the servlet api's log method to log inside a web
application, or even better use a logging-framework.


is the one mentioned on the fourth line of the above trace.
   private final static String encodeUrl( HttpServletResponse response
, String url
)
   {
 System.out.println( encodeUrl );
 System.out.println( response= + response );
 System.out.println( url= + url );
 String result = null;
 if ( response == null )
   result = not on Web;
 else
   result = response.encodeUrl( url );
 System.out.println( result= + result );
 return result;
   }

As mentioned above, the errors are sporadic. My redirection code gets
called on my server when I submit one of my forms. But sometimes, the
submit works; sometimes it doesn't. Here are two successive traces from
the above method:
   encodeUrl
   response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
   url=/ResearcherValueGame1.jsp
   result=/ResearcherValueGame1.jsp

   encodeUrl
   response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
   url=/ResearcherValueGame1.jsp
The first one worked; the second crashed rather than returning the encoded
URL. The URL to be encoded is the same in both cases, and 'response' is
evidently the same instance. I don't know how to dump 'response' in order
to show relevant fields (whichever they are), but am happy to try it if
someone can suggest how.


You haven't shown us the code, which calls your encodeUrl. Most of the
times someone reports sporadic errors while working with responses, he
is saving references to the responses in a class variable.

Could this be your problem?

Hi Felix, and thanks for the comment. What is it about saving references 
to the responses in a class variable that can cause problems? Is it to do 
with threading: for example, do different threads all see the same class 
variable, thus potentially interfering with one another? This is something 
I need to know.


More specifically, I'd like to understand why you want to know this in 
addition to the diagnostics I included with the mail. These showed two 
calls to 'response.encodeUrl'. In both, the URLs were the same. The 
response instances were presumably also the same, since they had the same 
instance ID, ResponseFacade@1a5ec6c. In particular, neither response 
instance was null. So although one call crashed, it wasn't because of a 
nulled response, caused perhaps by losing the contents of a class 
variable. I wondered whether you suspect that that might be my problem.


Although I suppose the response instances could have been interfered with 
by code that updates some of their fields. As it happens, my code 
doesn't do that (unless I remember wrongly), but you obviously wouldn't 
know that.


I'm not criticising your comment, by the way; just trying to understand 
why you asked. My code is quite long, but I can summarise the call chain 
and response assignments if we don't solve the problem before.



Felix


Jocelyn



I've found a few mentions on Google of such errors, but nothing definite
about it happening in Tomcat 7. One discussion which I thought I'd seen,
but can't find again, seemed to suggest that the problem occurred on
version 5, possibly because of a missing 'synchronized'. I've not seen
anything in recent postings to this list.

I wondered whether the problem might be caused by the browser creating
malformed cookies, or some such. (I'm using session-handling.) However,
this seems unlikely, as the error occurs regardless of whether I use
Firefox, Internet Explorer, or Google Chrome.

Any ideas?

Jocelyn Ireson-Paine
http://www.j-paine.org

Jocelyn's Cartoons:
http://www.j-paine.org/blog/jocelyns_cartoons/


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

RE: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Jocelyn Ireson-Paine

On Thu, 9 Jun 2011, Caldarale, Charles R wrote:

From: Jocelyn Ireson-Paine [mailto:p...@j-paine.org] Subject: 
Null-pointer exception from response.encodeUrl under Windows Tomcat 7



I'm getting sporadic null-pointer exceptions from
'response.encodeUrl'.


First off, let me say that it's an unexpected pleasure to read such a 
complete (and literate) problem description; this is a model of what 
we'd like to see in all enquiries.


Thanks for the compliment, Chuck. It's nice of you to say it publicly. 
There's an essay that I read whenever I want to remind myself how to ask 
for help, and I'll mention it here in case others find it useful. Some 
will already know it: How To Ask Questions The Smart Way, by Eric 
Raymond and Rick Moen, http://www.catb.org/~esr/faqs/smart-questions.html 
.



...

- Chuck


Jocelyn

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



Re: Auth in Context.xml

2011-06-09 Thread André Warnier

Umesh Bhatt wrote:

Hi,

Sorry I meant auth not Auth.  Thanks for correction.
I used getConnection(username, password) but it gives me an error as It is not 
supported and doesn't connect with DB.



Umesh,

you would help the people trying to help you, and thus help yourself get answers faster, 
by providing *precise* information about your problem.
If you do not provide precise information, and do not answer questions, it is more 
difficult to help you.  And since the people who try to help on this list do this on their 
free time, and also have other things to do (like another $$ job for instance), they will 
not feel very motivated to spend extra time getting the information out of you.


Something like an error as It is not supported does not help.  Copy and paste the 
*real* error messages.

And answer the questions of Charles below.

here is an example of a good post :
http://markmail.org/message/ik56qyngekis24bo



-Original Message-
From: Caldarale, Charles R [mailto:chuck.caldar...@unisys.com]
Sent: Thursday, June 09, 2011 10:44 AM
To: Tomcat Users List
Subject: RE: Auth in Context.xml


From: Umesh Bhatt [mailto:umesh_bh...@mindtree.com]
Subject: RE: Auth in Context.xml



I am using Tomcat 6.0.


6.0.what?  There are 32 versions of 6.0; be precise.


In Context.xml file


Again, if you have a file named Context.xml, it will be ignored.  Files must be 
named (and located) properly for Tomcat to use them.  Exactly what is the file 
name, where is it located, and what are the full contents of the file?


I found JDBC resource configuration as below.



Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource
   maxActive=100 maxIdle=30 maxWait=1
   username=javauser password=javadude 
driverClassName=com.mysql.jdbc.Driver
   url=jdbc:mysql://localhost:3306/javatest/



It has Auth attribute


No, it has an auth attribute, not Auth; everything here is case-sensitive, so 
get it right.


I don't want to use tomcat to setup connection rather want my
application to setup connection with DB.


Still fooling yourself into thinking it's safer to bury the password in the 
application than in the configuration file?  Waste of time.  But if you insist 
on doing it, use the getConnection() method that has userid and password as 
arguments.

 - 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




http://www.mindtree.com/email/disclaimer.html

-
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: Tomcat 7.0.14 / 6.0.32 session gets obviously invalid after request / JSESSIONID changes

2011-06-09 Thread Sascha Hesse
it was set in a header.
But I already figured out what the Problem was.
For the Browser (Firefox 4) .localhost is not a valid domain for a cookie.
Some documents on the web say, that for localhost domain has to be empty.
This also didn't work.
The solution was requesting the service with a full qualified hostname
and then setting the cookie according to the fqn.

Hope this helps everybody who runs in the same pitfall.

Regards Sascha

 Does the AJAX javascript set the session id in a cookie header, or
 append it as a path attribute?

 You can't rely on the browser to do this automagically for you in most
 AJAX libs.


 p




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



Re: Static resource mapping in web.xml

2011-06-09 Thread Pid
On 08/06/2011 17:48, falva...@geocom.com.uy wrote:
 Currently we do not have this kind of attacks because the app runs in an
 intranet. But I know that in this closed scenario we should beware of the
 users.

But if your network is penetrated, your server will be vulnerable and
therefore a resource which can be compromised  further used to launch
attacks.


p



signature.asc
Description: OpenPGP digital signature


Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Pid
On 09/06/2011 06:52, Caldarale, Charles R wrote:
 From: Jocelyn Ireson-Paine [mailto:p...@j-paine.org] 
 Subject: Null-pointer exception from response.encodeUrl under Windows Tomcat 
 7
 
 I'm getting sporadic null-pointer exceptions from 
 'response.encodeUrl'. 
 
 First off, let me say that it's an unexpected pleasure to read such a 
 complete (and literate) problem description; this is a model of what we'd 
 like to see in all enquiries.

Shame it was a thread-hijack (from 'war file deployment...').

Please start a new email, rather than replying to an existing on in future.


p



signature.asc
Description: OpenPGP digital signature


Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Felix Schumacher
Am Donnerstag, den 09.06.2011, 09:40 +0100 schrieb Jocelyn Ireson-Paine:
 On Thu, 9 Jun 2011, Felix Schumacher wrote:
 
  Am Donnerstag, den 09.06.2011, 04:53 +0100 schrieb Jocelyn Ireson-Paine:
  Hi,
 
  I'm getting sporadic null-pointer exceptions from 'response.encodeUrl'.
  This is with Tomcat 7.0.14, the latest stable version to which I upgraded
  an hour ago, and Java 1.6.0_26, which again I upgraded to at the same
  time, under Windows XP. I also got the error under Tomcat 5.5.33, which is
  why I tried upgrading. I uninstalled old Tomcats and Javas before
  upgrading.
 
  Here's a trace of the error:
 java.lang.NullPointerException
 at
  org.apache.catalina.connector.Response.toAbsolute(Response.java:1594)
 at
  org.apache.catalina.connector.Response.encodeURL(Response.java:1198)
 at
  org.apache.catalina.connector.ResponseFacade.encodeUrl(ResponseFacade.java:422)
 at sharesim.ValueGame.encodeUrl(ValueGame.java:468)
  The fourth line of the trace is my code.
 
  To get some diagnostics, I encapsulated 'response.encodeUrl' in the
  following method, and used 'println' to print to Tomcat's log. This method
  You can use the servlet api's log method to log inside a web
  application, or even better use a logging-framework.
 
  is the one mentioned on the fourth line of the above trace.
 private final static String encodeUrl( HttpServletResponse response
  , String url
  )
 {
   System.out.println( encodeUrl );
   System.out.println( response= + response );
   System.out.println( url= + url );
   String result = null;
   if ( response == null )
 result = not on Web;
   else
 result = response.encodeUrl( url );
   System.out.println( result= + result );
   return result;
 }
 
  As mentioned above, the errors are sporadic. My redirection code gets
  called on my server when I submit one of my forms. But sometimes, the
  submit works; sometimes it doesn't. Here are two successive traces from
  the above method:
 encodeUrl
 response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
 url=/ResearcherValueGame1.jsp
 result=/ResearcherValueGame1.jsp
 
 encodeUrl
 response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
 url=/ResearcherValueGame1.jsp
  The first one worked; the second crashed rather than returning the encoded
  URL. The URL to be encoded is the same in both cases, and 'response' is
  evidently the same instance. I don't know how to dump 'response' in order
  to show relevant fields (whichever they are), but am happy to try it if
  someone can suggest how.
 
  You haven't shown us the code, which calls your encodeUrl. Most of the
  times someone reports sporadic errors while working with responses, he
  is saving references to the responses in a class variable.
 
  Could this be your problem?
 
 Hi Felix, and thanks for the comment. What is it about saving references 
 to the responses in a class variable that can cause problems? Is it to do 
 with threading: for example, do different threads all see the same class 
 variable, thus potentially interfering with one another? This is something 
 I need to know.
Instances of servlets are used multi threaded inside the servlet
container. So every shared - instance or class wise - request/response
reference will cause trouble.

So don't do this (might 

class MyServlet extends HttpServlet {
 // DONOT DO THIS
 private Request req;

 public void doGet(HttpServletRequest req, HttpServletResponse res) {
// NEVER A GOOD IDEA
this.req = req;
...
myMethod();
 }

 private void myMethod() {
   // OHOH
   workWith(this.req);
 }
}

 
 More specifically, I'd like to understand why you want to know this in 
 addition to the diagnostics I included with the mail. These showed two 
 calls to 'response.encodeUrl'. In both, the URLs were the same. The 
 response instances were presumably also the same, since they had the same 
 instance ID, ResponseFacade@1a5ec6c. In particular, neither response 
 instance was null. So although one call crashed, it wasn't because of a 
 nulled response, caused perhaps by losing the contents of a class 
 variable. I wondered whether you suspect that that might be my problem.
Responses will get recycled and might be in an inconsistent state when
you (or the container) uses them multi threaded.

Felix
 
 Although I suppose the response instances could have been interfered with 
 by code that updates some of their fields. As it happens, my code 
 doesn't do that (unless I remember wrongly), but you obviously wouldn't 
 know that.
 
 I'm not criticising your comment, by the way; just trying to understand 
 why you asked. My code is quite long, but I can summarise the call chain 
 and response assignments if we don't solve the problem before.
 
  Felix
 
 Jocelyn
 
 
  I've found a few mentions on Google of such errors, but nothing 

Re: Auth in Context.xml

2011-06-09 Thread Konstantin Kolinko
2011/6/9 Umesh Bhatt umesh_bh...@mindtree.com:
 Sorry I meant auth not Auth.  Thanks for correction.
 I used getConnection(username, password) but it gives me an error as It is 
 not supported and doesn't connect with DB.

Sure.  Apache Commons DBCP connection pool does not support that method.

There are other connection pools that support it.

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



Re: War file deployment deletes configuration descriptor in Tomcat 6

2011-06-09 Thread Konstantin Kolinko
2011/6/8 Dharamshila Khandelwal dharmshil...@gmail.com:
 Every time I deploy war file in webapps, it deletes the configuration
 descriptor which is present at $CATALINA_BASE/conf/[enginename]/[hostname]
 directory.
 Tomcat auto deploys war file in my Tomcat 6 configuration.

1. What _exactly_ version of Tomcat 6.0.x ?

2. The behaviour regarding your issue is sometimes misunderstood.

Use the latest version of Tomcat and read the docs carefully.

http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic_Application_Deployment

Best regards,
Konstantin Kolinko

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



How to handle client disconnection in 'no timeout' async servlets?

2011-06-09 Thread Paul Cazan
Hello,
I am using Tomcat 7.0.14. I used to have a servlet implementing CometProcessor 
to process asynchronous streams, with timeout set very high 
(Integer.MAX_VALUE), and all worked fine. When I close the browser, the servlet 
is notified immediately about that (CometEvent.EventType.END) and I am happy to 
do the cleanup.
No, I have created an async servlet 3.0, and all works as I expected, except 
for notification when the browser is closed. I used request.startAsync(), I 
added AsyncListener, and none of the events get fired when the browser is 
suddenly closed. Since I set the timeout to a large value (Long.MAX_VALUE), 
AsyncListener.onTimeout will never get called.
As far as I understand, onComplete will get called only when I call 
AsyncContext.complete(), and I do not know when to call it. I tried to write on 
response.getWriter(), expecting to see an exception, but no exception was 
thrown after a couple of writes.
How can I handle this situation using servlet api 3.0, when the user closes the 
browser or hits the stop button? I need to do the cleanup for that 
client.Meanwhile, I reverted the source code to CometProcessor.
Thanks a lot,Paul

Re: serving pre-compressed files

2011-06-09 Thread Jesse Farinacci
Hello,

On Thu, Jun 9, 2011 at 4:27 AM, Pid p...@pidster.com wrote:

 Not quite the same, but similar, is the following:
 If you're using Tomcat 7, you have Servlet 3 compatibility, which means
 you can serve resources out of a specially* constructed jar.

 * Put resources in: myresource.jar:/META-INF/resources and they will
 appear as from the root of the webapp.
 e.g.  /META-INF/resources/logo.gif - /logo.gif

That is pretty cool! Thanks for sharing that tip.

I did not find anything with tuckey urlrewrite, so I just wrote a
quick javax.servlet.Filter. It sanity checks: 1) no ?gzip=false
parameter (a la Tomcat's compression filter), and 2) Accept-Encoding:
{,x-}gzip in any of the headers, and 3)  that  new
File(request.getContextPath().substring(1) +
DEFAULT_GZIP_FILE_EXTENSION)  exists.

On any FNFE / IOE, silently discard the exception and run the rest of
the chain; otherwise setting response header Content-Encoding: gzip
and copying the compressed version directly to the
response.outputStream before closing it.

It seems to work alright. My only concerns lay with: 1) malicious
contextPaths with ../../-style navigation, and 2) unpacked WARs which
contain the gzipped resource will take FNFE and not serve the
pre-compressed output as expected, and last and least 3) Accept-Range
is completely ignored.

For # 1: Is there some better way I should be obtaining the resource?
For # 2-3: Would it be better for me to just issue response.sendRedirect()?

Thanks,

-Jesse

-- 
There are 10 types of people in this world, those
that can read binary and those that can not.

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



Embedded tomcat contexts confusion

2011-06-09 Thread Benson Margulies
I'm using tomcat 7.0.14.

I create a org.apache.catalina.startup.Tomcat;.

I call 'addWebapp'

 lshContext = tomcat.addWebapp(/lsh, docBase.getCanonicalPath());.

The webapp in question has a Listener. The listener happens to belong to Spring.

contextInitialized has a try/catch block. In the catch, it call:

servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
ex);

and then rethrows the exception.

Out in my application, I am trying to find that attribute value. If I
ask lshContext (the context returned by addWebapp) for
servletContext(), I get a *different* object that has no attributes.

How can I navigate from the Context returned from addWebapp to the
context passed into the Listener?

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



Re: serving pre-compressed files

2011-06-09 Thread Pid
On 09/06/2011 13:34, Jesse Farinacci wrote:
 Hello,
 
 On Thu, Jun 9, 2011 at 4:27 AM, Pid p...@pidster.com wrote:

 Not quite the same, but similar, is the following:
 If you're using Tomcat 7, you have Servlet 3 compatibility, which means
 you can serve resources out of a specially* constructed jar.

 * Put resources in: myresource.jar:/META-INF/resources and they will
 appear as from the root of the webapp.
 e.g.  /META-INF/resources/logo.gif - /logo.gif
 
 That is pretty cool! Thanks for sharing that tip.
 
 I did not find anything with tuckey urlrewrite, so I just wrote a
 quick javax.servlet.Filter. It sanity checks: 1) no ?gzip=false
 parameter (a la Tomcat's compression filter), and 2) Accept-Encoding:
 {,x-}gzip in any of the headers, and 3)  that  new
 File(request.getContextPath().substring(1) +
 DEFAULT_GZIP_FILE_EXTENSION)  exists.

You don't need to use the File object:

 ServletContext.getResourceAsStream(/path/to/resource.ext)

which has the additional benefit that the container should prevent
access to resources outside of the context, as the path is relative to
the context.


p


 On any FNFE / IOE, silently discard the exception and run the rest of
 the chain; otherwise setting response header Content-Encoding: gzip
 and copying the compressed version directly to the
 response.outputStream before closing it.
 
 It seems to work alright. My only concerns lay with: 1) malicious
 contextPaths with ../../-style navigation, and 2) unpacked WARs which
 contain the gzipped resource will take FNFE and not serve the
 pre-compressed output as expected, and last and least 3) Accept-Range
 is completely ignored.
 
 For # 1: Is there some better way I should be obtaining the resource?
 For # 2-3: Would it be better for me to just issue response.sendRedirect()?
 
 Thanks,
 
 -Jesse
 




signature.asc
Description: OpenPGP digital signature


How to cluster two embedded tomcat 7 instances

2011-06-09 Thread Rüdiger Herrmann
Hi all,

I would like to programmatically set up two Tomcat engines and have
them form a basic cluster - all in the same VM. Creating and starting
the servlet engines already works
  Tomcat tomcat = new Tomcat()
  tomcat.setPort( 123 );
  // create context, add servlet, ...
  tomcat.start();

What I am struggling with is setting up the cluster. My first attempt
was to use the PersistentManager with Store that uses a shared
directory. But it seems that it only persists session in time
intervals. To enable failover, a session would need to be persisted
after each request. However, I didn't find out how to configure or
trigger the PersistentManager to do so.
Still, the PersistenceManager setup was straightforward and if anyone
knows how to form a cluster with this approach I would be grateful to
know.

I am aware of the SimpleTcpCluster, which I would try next. Just,
before transforming the XML configuration into API calls (without
known their meaning) I wanted to ask if there is an easier or even
pre-built solution.

Background:
I work on enabling RAP [1], a web framework, to work in failover
cluster environments. To ensure cluster-support, I have a set of JUnit
tests that issue requests against an embeded cluster of servlet
engines and then examine the state of sessions of the respective
nodes, etc.
Performance isn't important, neither is any advanced clustering
feature (e.g. DeltaManager) needed. My focus is on finding a
lightweight and purely programmatic solution.

Thanks in advance,
Rüdiger

[1] http://eclipse.org/rap

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



Tomcat 5.5 Clustering

2011-06-09 Thread Tauqir Akhtar
Hi 

I am running two Tomcat (5.5.27) Instances on two different machines deploying 
the same Java Application.

I have made changes in server.xml to specify the Port on which Tomcat should 
run on the two machines.

On Machine 1 : Connector port=8001

On Machine 12 : Connector port=8002

Both the Instances are running fine.

What other configuration changes (In which files) do I need to make to run 
these two Tomcat Instances in one Cluster?

I have following variables set in the machine environment:

CATALINA_OPTS : -Xms512m -Xmx1024m
JAVA_OPTS  : -Xmx768m
JAVA_HOME  : C:\Program Files\Java\jdk1.5.0_11

What other changes I need to make to run more Tomcat Instances from the same 
Installation on each machine?

For Example:
On Machine 1 :  Connector port=8001
Connector port=8003

On Machine 2 :  Connector port=8002
Connector port=8004

I want to run all these instances in a cluster.

Your help will be highly appreciated.

Thanks
Tauqir

##

NOTICE:
The contents of this e-mail and any attachments to it may contain privileged 
and confidential information from The Jones Group Inc. or its affiliates.  This 
information is only for the viewing or use of the intended recipient.  If you 
are not the intended recipient, you are hereby notified that any disclosure, 
copying, distribution or use of, or the taking of any action in reliance upon, 
the information contained in this e-mail, or any of the attachments to this 
e-mail, is strictly prohibited.  If you have received this e-mail in error, 
please immediately notify the sender by replying to this message and delete it 
from your system.

###



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



Re: How to cluster two embedded tomcat 7 instances

2011-06-09 Thread Martin Grotzke
Hi,

perhaps memcached-session-manager is an option for you:
http://code.google.com/p/memcached-session-manager/

It has integration tests that show how to configure it programatically:
https://github.com/magro/memcached-session-manager/blob/master/core/src/test/java/de/javakaffee/web/msm/integration/TestUtils.java#L440

Configuration options are described here:
http://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration

Cheers,
Martin


On 06/09/2011 03:15 PM, Rüdiger Herrmann wrote:
 Hi all,
 
 I would like to programmatically set up two Tomcat engines and have
 them form a basic cluster - all in the same VM. Creating and starting
 the servlet engines already works
   Tomcat tomcat = new Tomcat()
   tomcat.setPort( 123 );
   // create context, add servlet, ...
   tomcat.start();
 
 What I am struggling with is setting up the cluster. My first attempt
 was to use the PersistentManager with Store that uses a shared
 directory. But it seems that it only persists session in time
 intervals. To enable failover, a session would need to be persisted
 after each request. However, I didn't find out how to configure or
 trigger the PersistentManager to do so.
 Still, the PersistenceManager setup was straightforward and if anyone
 knows how to form a cluster with this approach I would be grateful to
 know.
 
 I am aware of the SimpleTcpCluster, which I would try next. Just,
 before transforming the XML configuration into API calls (without
 known their meaning) I wanted to ask if there is an easier or even
 pre-built solution.
 
 Background:
 I work on enabling RAP [1], a web framework, to work in failover
 cluster environments. To ensure cluster-support, I have a set of JUnit
 tests that issue requests against an embeded cluster of servlet
 engines and then examine the state of sessions of the respective
 nodes, etc.
 Performance isn't important, neither is any advanced clustering
 feature (e.g. DeltaManager) needed. My focus is on finding a
 lightweight and purely programmatic solution.
 
 Thanks in advance,
 Rüdiger
 
 [1] http://eclipse.org/rap
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 

-- 
Martin Grotzke
http://twitter.com/martin_grotzke



signature.asc
Description: OpenPGP digital signature


Re: Tomcat 5.5 Clustering

2011-06-09 Thread Pid
On 09/06/2011 15:02, Tauqir Akhtar wrote:
 Hi 
 
 I am running two Tomcat (5.5.27) Instances on two different machines 
 deploying the same Java Application.

If this is a new request for help, rather than a reply to Tomcat 6
Clustering vs. Tomcat 5.5 clustering please start a new thread, rather
than replying to an existing email  just editing the subject  body.

This is called thread hijacking.


p



signature.asc
Description: OpenPGP digital signature


Tomact 5.5 Clustering

2011-06-09 Thread Tauqir Akhtar
Hi

I am running two Tomcat (5.5.27) Instances on two different machines deploying 
the same Java Application.

I have made changes in server.xml to specify the Port on which Tomcat should 
run on the two machines.

On Machine 1 : Connector port=8001

On Machine 2 : Connector port=8002

Both the Instances are running fine.

What other configuration changes (In which files) do I need to make to run 
these two Tomcat Instances in one Cluster?

I have following variables set in the machine environment:

CATALINA_OPTS : -Xms512m -Xmx1024m
JAVA_OPTS  : -Xmx768m
JAVA_HOME  : C:\Program Files\Java\jdk1.5.0_11

What other changes I need to make to run more Tomcat Instances from the same 
Installation on each machine?

For Example:
On Machine 1 :Connector port=8001
  Connector port=8003

On Machine 2 :Connector port=8002
  Connector port=8004

I want to run all these instances in a cluster.

Your help will be highly appreciated.


Thanks

Tauqir Akhtar



##

NOTICE:
The contents of this e-mail and any attachments to it may contain privileged 
and confidential information from The Jones Group Inc. or its affiliates.  This 
information is only for the viewing or use of the intended recipient.  If you 
are not the intended recipient, you are hereby notified that any disclosure, 
copying, distribution or use of, or the taking of any action in reliance upon, 
the information contained in this e-mail, or any of the attachments to this 
e-mail, is strictly prohibited.  If you have received this e-mail in error, 
please immediately notify the sender by replying to this message and delete it 
from your system.

###



RE: Tomcat 5.5 Clustering

2011-06-09 Thread Tauqir Akhtar
Sorry abt that.
I have created a new request now.

Thanks 
 
Tauqir Akhtar

-Original Message-
From: Pid [mailto:p...@pidster.com] 
Sent: Thursday, June 09, 2011 10:27 AM
To: Tomcat Users List
Subject: Re: Tomcat 5.5 Clustering

On 09/06/2011 15:02, Tauqir Akhtar wrote:
 Hi 
 
 I am running two Tomcat (5.5.27) Instances on two different machines 
 deploying the same Java Application.

If this is a new request for help, rather than a reply to Tomcat 6
Clustering vs. Tomcat 5.5 clustering please start a new thread, rather
than replying to an existing email  just editing the subject  body.

This is called thread hijacking.


p


##

NOTICE:
The contents of this e-mail and any attachments to it may contain privileged 
and confidential information from The Jones Group Inc. or its affiliates.  This 
information is only for the viewing or use of the intended recipient.  If you 
are not the intended recipient, you are hereby notified that any disclosure, 
copying, distribution or use of, or the taking of any action in reliance upon, 
the information contained in this e-mail, or any of the attachments to this 
e-mail, is strictly prohibited.  If you have received this e-mail in error, 
please immediately notify the sender by replying to this message and delete it 
from your system.

###



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



Re: Tomact 5.5 Clustering

2011-06-09 Thread Pid
On 09/06/2011 15:30, Tauqir Akhtar wrote:
 Hi
 
 I am running two Tomcat (5.5.27) Instances on two different machines 
 deploying the same Java Application.
 
 I have made changes in server.xml to specify the Port on which Tomcat should 
 run on the two machines.
 
 On Machine 1 : Connector port=8001
 
 On Machine 2 : Connector port=8002
 
 Both the Instances are running fine.
 
 What other configuration changes (In which files) do I need to make to run 
 these two Tomcat Instances in one Cluster?
 
 I have following variables set in the machine environment:
 
 CATALINA_OPTS : -Xms512m -Xmx1024m
 JAVA_OPTS  : -Xmx768m
 JAVA_HOME  : C:\Program Files\Java\jdk1.5.0_11
 
 What other changes I need to make to run more Tomcat Instances from the same 
 Installation on each machine?
 
 For Example:
 On Machine 1 :Connector port=8001
   Connector port=8003
 
 On Machine 2 :Connector port=8002
   Connector port=8004
 
 I want to run all these instances in a cluster.
 
 Your help will be highly appreciated.

Have you added/enabled the Cluster element to/in your server.xml?

 http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html


p



signature.asc
Description: OpenPGP digital signature


RE: Tomact 5.5 Clustering

2011-06-09 Thread Tauqir Akhtar
Pid

I have uncommeneted the Cluster Element in server.xml on both the Instances..

Thanks 
 
Tauqir Akhtar

-Original Message-
From: Pid [mailto:p...@pidster.com] 
Sent: Thursday, June 09, 2011 10:36 AM
To: Tomcat Users List
Subject: Re: Tomact 5.5 Clustering

On 09/06/2011 15:30, Tauqir Akhtar wrote:
 Hi
 
 I am running two Tomcat (5.5.27) Instances on two different machines 
 deploying the same Java Application.
 
 I have made changes in server.xml to specify the Port on which Tomcat should 
 run on the two machines.
 
 On Machine 1 : Connector port=8001
 
 On Machine 2 : Connector port=8002
 
 Both the Instances are running fine.
 
 What other configuration changes (In which files) do I need to make to run 
 these two Tomcat Instances in one Cluster?
 
 I have following variables set in the machine environment:
 
 CATALINA_OPTS : -Xms512m -Xmx1024m
 JAVA_OPTS  : -Xmx768m
 JAVA_HOME  : C:\Program Files\Java\jdk1.5.0_11
 
 What other changes I need to make to run more Tomcat Instances from the same 
 Installation on each machine?
 
 For Example:
 On Machine 1 :Connector port=8001
   Connector port=8003
 
 On Machine 2 :Connector port=8002
   Connector port=8004
 
 I want to run all these instances in a cluster.
 
 Your help will be highly appreciated.

Have you added/enabled the Cluster element to/in your server.xml?

 http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html


p


##

NOTICE:
The contents of this e-mail and any attachments to it may contain privileged 
and confidential information from The Jones Group Inc. or its affiliates.  This 
information is only for the viewing or use of the intended recipient.  If you 
are not the intended recipient, you are hereby notified that any disclosure, 
copying, distribution or use of, or the taking of any action in reliance upon, 
the information contained in this e-mail, or any of the attachments to this 
e-mail, is strictly prohibited.  If you have received this e-mail in error, 
please immediately notify the sender by replying to this message and delete it 
from your system.

###



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



Re: ServletRequestListener and Expect-Header

2011-06-09 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Simon,

On 6/8/2011 1:47 PM, Simon Olofsson wrote:
 I have a ServletRequestListener that tries too access a Request Parameter:
  sre.getServletRequest().getParameter(x);
 
 When I send a POST-Request with the Expect: 100-continue HTTP Header
 it hangs waiting for the Request Body which isn't send because Tomcat
 didn't send a 100-continue Response. See the Stacktrace at [1]. This
 happens with a Tomcat built from SVN-Trunk.
 
 This problem only occurs in a ServletRequestListener. Accessing a
 Request Parameter from a Servlet works, because the Request is
 acknowledged beforehand (StandardWrapperValve:176).
 
 I would suggest to acknowledge the Request in
 catalina.connector.Request.parseParameters().
 
 Any ideas or help with submitting a patch is greatly appreciated.

First, log a bug in bugzilla. Then, get a copy of the source code
through svn. Edit the code, build it and test it (TC7 is much easier to
build than earlier versions).

Use svn diff to generate a patch file and attach that to the bug once
you've got something working.

Thanks in advance for any contributions you may have.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w8TYACgkQ9CaO5/Lv0PCTvgCght1KXfbE/PT0RsyEykwVpebU
Bs4An0w9PFrzh1rfIobqsB+m+Mz/V+wU
=us86
-END PGP SIGNATURE-

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



Re: serving pre-compressed files

2011-06-09 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jesse,

On 6/9/2011 8:34 AM, Jesse Farinacci wrote:
 I just wrote a
 quick javax.servlet.Filter. It sanity checks: 1) no ?gzip=false
 parameter (a la Tomcat's compression filter), and 2) Accept-Encoding:
 {,x-}gzip in any of the headers, and 3)  that  new
 File(request.getContextPath().substring(1) +
 DEFAULT_GZIP_FILE_EXTENSION)  exists.

You might want to check out how Apache httpd does the same type of
thing. It uses the Vary response header which may be a bit more polite.

 On any FNFE / IOE, silently discard the exception and run the rest of
 the chain; otherwise setting response header Content-Encoding: gzip
 and copying the compressed version directly to the
 response.outputStream before closing it.

You shouldn't have to catch any exceptions. The java.io.File constructor
won't throw an exception with a non-existent path, and you can call
File.exists to check if it exists. That might simplify your code, too.

 It seems to work alright. My only concerns lay with: 1) malicious
 contextPaths with ../../-style navigation

You can normalize the path and then check to see where it lives.

Note that by using java.io.File you are both circumventing the
container's protections against filesystem protection /and/ requiring
that your files actually be on a filesystem.

Instead, you might want to try something like
ServletContext.getResource() to see if it's null, and then forwarding to
it using the request dispatcher if it's not null.

 and 2) unpacked WARs which
 contain the gzipped resource will take FNFE and not serve the
 pre-compressed output as expected, and last and least 3) Accept-Range
 is completely ignored.

If you use the request dispatcher, Accept-Range might be handled for you
by the DefaultServlet.

 For # 1: Is there some better way I should be obtaining the resource?
 For # 2-3: Would it be better for me to just issue response.sendRedirect()?

It depends upon the size of the file. An HTTP request is not free,
especially over SSL. If the size of the response will be small, you may
as well do the work on the server during the first request, instead of
forcing the client to make a second request.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w8zwACgkQ9CaO5/Lv0PBcCwCgp2J8laDq5SaBLF0HNWaxHHJs
IrIAn0vOwZJ1QnmTrSTBJwFCZvd8FKrn
=quWt
-END PGP SIGNATURE-

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



Re: serving pre-compressed files

2011-06-09 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jesse,

On 6/9/2011 8:34 AM, Jesse Farinacci wrote:
 I just wrote a quick javax.servlet.Filter.

Oh, if you're willing to do so, please share your code with the list.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w82oACgkQ9CaO5/Lv0PC8DgCcCm090VMLHqQa/gETxRZnQmEi
eIcAn33AZveL9YtBoOyuByFFtUXfEY3s
=4/Cj
-END PGP SIGNATURE-

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



Re: My web application to use SSL (JSSE - RSA)

2011-06-09 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Charles,

On 6/8/2011 3:03 PM, Charles Van Damme wrote:
 1) I'm trying first with JSSE. Please see !-- Connectors ... in my
 server.xml file.

Attachments stripped again. Please copy/paste into the message.

 2) How can I prevent my NetBeans IDE to start a Tomcat server ?
 To run and stop Tomcat separately, I figure that you mean start  Cmd 
 C:\Program Files\apache-tomcat-7.0.11\bin\startup.bat and shutdown.bat

That is generally the proper way to start and stop Tomcat.

 3) What do I have to do to avoid that it grumbles when I try to use RSA ?

Can you post your log files from after an unsuccessful startup? Remember
that attaching them might not work well (though plain-text does tend to
get through).

There are many things that can go wrong when configuring SSL. We will
need to see your configuration and the actual error you get in order to
help diagnose.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w9GsACgkQ9CaO5/Lv0PBv8gCfVWGz7PygOoAsqzQt/PLBvHIj
5iwAn1S1+V6q02LmPskk8VCyg0ZSxkbJ
=sJdR
-END PGP SIGNATURE-

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



Re: Static resource mapping in web.xml

2011-06-09 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Federico,

On 6/8/2011 10:17 AM, falva...@geocom.com.uy wrote:
 servlet-mapping
   servlet-nameinvoker/servlet-name
   url-pattern/*/url-pattern
 /servlet-mapping

Why not map the invoker to /servlet/*?

Seems like that would fix your problem.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w9eEACgkQ9CaO5/Lv0PCgsgCdEDJd5bjOYnUcAlqIe0U9BsdT
mQMAn15kCAUKiir4Zlc8YV4VhOExn+nK
=+hEG
-END PGP SIGNATURE-

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



Re: Tomact 5.5 Clustering

2011-06-09 Thread János Löbb

On Jun 9, 2011, at 10:30 AM, Tauqir Akhtar wrote:

 Hi
 
 I am running two Tomcat (5.5.27) Instances on two different machines 
 deploying the same Java Application.
 
 I have made changes in server.xml to specify the Port on which Tomcat should 
 run on the two machines.
 
 On Machine 1 : Connector port=8001
 
 On Machine 2 : Connector port=8002
 
 Both the Instances are running fine.
 
 What other configuration changes (In which files) do I need to make to run 
 these two Tomcat Instances in one Cluster?
 
 I have following variables set in the machine environment:
 
 CATALINA_OPTS : -Xms512m -Xmx1024m
 JAVA_OPTS  : -Xmx768m
 JAVA_HOME  : C:\Program Files\Java\jdk1.5.0_11
 
 What other changes I need to make to run more Tomcat Instances from the same 
 Installation on each machine?
 
 For Example:
 On Machine 1 :Connector port=8001
  Connector port=8003
 
 On Machine 2 :Connector port=8002
  Connector port=8004
 
 I want to run all these instances in a cluster.
 
 Your help will be highly appreciated.
 
 
 Thanks
 
 Tauqir Akhtar
 

Are the two machines in the same subnet ?  Is multicasting work ?  What do you 
see in the logs ?  Are there any memberships established ?  Etc...
-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Static resource mapping in web.xml

2011-06-09 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Federico,

On 6/8/2011 2:04 PM, falva...@geocom.com.uy wrote:
 If this is the case I could make it weight-in in the matter of building a
 well formed web.xml.
 
 Although it could take some time.

How many servlets do you have?

 Mapping each servlet to an /* url-pattern will avoid us from using invoker
 and at the same time get rid of /servlet in the URL and keep images under
 /images.

Don't map to /* of course: instead map to a specific URL.

You can use some simple tools to generate the mappings. Something like this:

$ find -name *Servlet.java | sed -e 's/\(.*\)\.java/servlet\n
servlet-name\1\/servlet-name\n
servlet-class\1\/servlet-class\n\/servlet\n\nservlet-mapping\n
servlet-name\1\/servlet-name\n
url-pattern\1\/url-pattern\n\/servlet-mapping/'

Obviously, you'll have top massage some of that: the servlet-class needs
to be dot-separated the the above command will give you slash-separated
names.

You'll also have to separate the servlet and servlet-mapping
sections ... or just run two separate commands: one to generate the
servlet elements and the other to generate the servlet-mapping elements.

Removing the invoker servlet and just explicitly mapping everything is
only a /little/ tedious but much safer. Take the time to do this now.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w+CIACgkQ9CaO5/Lv0PAi+gCfYfLAaOJQIM0ziCbGOLN4eCno
4HYAoLLVVZQogmdMk1SzdXTpLEi9zbPm
=+1/1
-END PGP SIGNATURE-

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



Terminating long running request threads

2011-06-09 Thread Afkham Azeez
Hi folks,
We are using embedded Tomcat 7.0.14, and we have a requirement to somehow
terminate request threads that have been running for a 'long' time. Does
Tomcat provide any support to do this? Do we have access to the request
thread pool through JMX, and if so, is there a way to get hold of these long
running threads  terminate them?

Thanks
Azeez


Re: Terminating long running request threads

2011-06-09 Thread Afkham Azeez
For our requirement, it is even OK to detect to which webapp such a request
is coming, and unload that webapp.


On Thu, Jun 9, 2011 at 10:33 PM, Afkham Azeez afk...@gmail.com wrote:

 Hi folks,
 We are using embedded Tomcat 7.0.14, and we have a requirement to somehow
 terminate request threads that have been running for a 'long' time. Does
 Tomcat provide any support to do this? Do we have access to the request
 thread pool through JMX, and if so, is there a way to get hold of these long
 running threads  terminate them?

 Thanks
 Azeez



RE: Terminating long running request threads

2011-06-09 Thread Caldarale, Charles R
 From: Afkham Azeez [mailto:afk...@gmail.com] 
 Subject: Terminating long running request threads

 is there a way to get hold of these long running threads
  terminate them?

This is not an issue specific to Tomcat; there is no way to safely terminate a 
Java thread without the cooperation of that thread.  Best if you can code your 
webapp so that your request processors periodically check if they've been 
running too long and give up if so.

 - 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: Terminating long running request threads

2011-06-09 Thread Afkham Azeez
On Thu, Jun 9, 2011 at 10:51 PM, Caldarale, Charles R 
chuck.caldar...@unisys.com wrote:

  From: Afkham Azeez [mailto:afk...@gmail.com]
  Subject: Terminating long running request threads

  is there a way to get hold of these long running threads
   terminate them?

 This is not an issue specific to Tomcat; there is no way to safely
 terminate a Java thread without the cooperation of that thread.  Best if you
 can code your webapp so that your request processors periodically check if
 they've been running too long and give up if so.


Yes, it is not a Tomcat specific issue. The thing is, we don't have total
control over what type of webapps will be deployed. We do restrict certain
operations using a Java Security Manager, but I do not think we can restrict
the running time of a Thread using a security manager. Using
the ThreadMXBean we can monitor the time each thread takes, and get the
thread IDs of long running threads. It may be possible to get that thread to
terminate if we have some support for that from the Tomcat threadpool. Just
thinking out loud.

Thanks
Azeez



  - 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: how to correct stop a thread and avoid leaks

2011-06-09 Thread Calum
On 9 June 2011 09:11, Pid p...@pidster.com wrote:
 Eh?  Why would you need to put Tomcat specific dependencies in a spec
 compliant Servlet container?  The above is simply not true.

 The OP use of a ServletContextListener is perfectly valid, (even if the
 rest of the code is a little odd).

Is it better to have a separate class that implements the Listener,
and sets running = false in the Threads, or just have the thread class
implement the listener itself?

Or are there not really any pros or cons either way?

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



RE: Static resource mapping in web.xml

2011-06-09 Thread falvarez
Yes, we would probably use some tools to build the web.xml.

Currently our applications has something between 1 to 15000 servlets.

Mapping to /servlet/* how it works now, a normal URL is 
http://host:8080/webapp/servlet/myservlet;. But then I tried to remove the 
/servlet/ from the URL, that's when all this trouble began.

 Don't map to /* of course: instead map to a specific URL.

My intention is to map myservlet to /myservlet, for example. This 
removes any aditional string in the URL. So the UR becomes: 
http://host:8080/webapp/myservlet;.

The application works fine with this new invoker mapping, the only problem is 
that resources are served under /images/images/*. This impacts in many 
servlets that have hard-coded access to images, javascripts or css files (I 
know how bad this is), also others have relative links that now don't work. 
Most do have a parameter pointing to the right resource folder and work fine, 
but finding the ones causing trouble is not easy.

The excuse or reason I've been getting when this matter is addressed is the 
ease of deployment the invoker provides.

I will be building a testing environment a few days from now, using a proper 
web.xml and no invoker. Guess my job now will be to demonstrate the advantages 
of this (the URL improvement will be the easiest for them to see). Of course 
for this matter to succeed the creation of a fully automated web.xml building 
script will be required.

Thanks for the help.

Best regards,
Federico.

-Mensaje original-
De: Christopher Schultz [mailto:ch...@christopherschultz.net] 
Enviado el: jueves, 09 de junio de 2011 13:43
Para: Tomcat Users List
Asunto: Re: Static resource mapping in web.xml

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Federico,

On 6/8/2011 2:04 PM, falva...@geocom.com.uy wrote:
 If this is the case I could make it weight-in in the matter of building a
 well formed web.xml.
 
 Although it could take some time.

How many servlets do you have?

 Mapping each servlet to an /* url-pattern will avoid us from using invoker
 and at the same time get rid of /servlet in the URL and keep images under
 /images.

Don't map to /* of course: instead map to a specific URL.

You can use some simple tools to generate the mappings. Something like this:

$ find -name *Servlet.java | sed -e 's/\(.*\)\.java/servlet\n
servlet-name\1\/servlet-name\n
servlet-class\1\/servlet-class\n\/servlet\n\nservlet-mapping\n
servlet-name\1\/servlet-name\n
url-pattern\1\/url-pattern\n\/servlet-mapping/'

Obviously, you'll have top massage some of that: the servlet-class needs
to be dot-separated the the above command will give you slash-separated
names.

You'll also have to separate the servlet and servlet-mapping
sections ... or just run two separate commands: one to generate the
servlet elements and the other to generate the servlet-mapping elements.

Removing the invoker servlet and just explicitly mapping everything is
only a /little/ tedious but much safer. Take the time to do this now.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w+CIACgkQ9CaO5/Lv0PAi+gCfYfLAaOJQIM0ziCbGOLN4eCno
4HYAoLLVVZQogmdMk1SzdXTpLEi9zbPm
=+1/1
-END PGP SIGNATURE-

-
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: ServletRequestListener and Expect-Header

2011-06-09 Thread André Warnier

Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Simon,

On 6/8/2011 1:47 PM, Simon Olofsson wrote:

I have a ServletRequestListener that tries too access a Request Parameter:
 sre.getServletRequest().getParameter(x);

When I send a POST-Request with the Expect: 100-continue HTTP Header
it hangs waiting for the Request Body which isn't send because Tomcat
didn't send a 100-continue Response. See the Stacktrace at [1]. This
happens with a Tomcat built from SVN-Trunk.

This problem only occurs in a ServletRequestListener. Accessing a
Request Parameter from a Servlet works, because the Request is
acknowledged beforehand (StandardWrapperValve:176).

I would suggest to acknowledge the Request in
catalina.connector.Request.parseParameters().



Maybe slightly OT, and just a naive question for my own edification :


As I read the API for the ServletRequestListener, I understand that this thing is called 
very early in the cycle.  The spirit seems to be : provide a way to warn as soon as 
possible that a servlet request has come in.

Perhaps even, before we even know that it is really a /HTTP/ servlet request.

Now, /if/ it is a HTTP servlet request, (and particularly a POST request) then the fact of 
calling ServletRequest.getParameter(x) would force, at that point, the parsing of the 
request, headers and body, as a HTTP request.


But what if it is not a HTTP request ?

I guess that my question could be rephrased as : is Tomcat a Java servlet engine, or just 
a Java HTTP servlet engine ?



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



RE: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Martin Gainty

place servletapi-2.3.jar in $CATALINA_HOME/bin

$CATALINA_HOME/bin/servletapijavap ./javax/servlet/http/HttpServletResponse | 
grep encodeURL
public abstract java.lang.String encodeURL(java.lang.String);

Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




Date: Thu, 9 Jun 2011 09:06:52 +0100
From: p...@j-paine.org
To: users@tomcat.apache.org; users@tomcat.apache.org
Subject: Re: Null-pointer exception from response.encodeUrl under Windows 
Tomcat 7

On Thu, 9 Jun 2011, André Warnier wrote:
 
 ...

 By the way :

 (Interface HttpServletResponse, Javaee 5)
 encodeUrl
 String encodeUrl(String url)
Deprecated. As of version 2.1, use encodeURL(String url) instead

 Maybe it's worth replacing encodeUrl by encodeURL, and see if the problem 
 still happens.

Thanks for the suggestion, André. I've just tried that, and the problem 
still happens.
 
Jocelyn

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

RE: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Caldarale, Charles R
 From: Martin Gainty [mailto:mgai...@hotmail.com] 
 Subject: RE: Null-pointer exception from response.encodeUrl under Windows 
 Tomcat 7

 place servletapi-2.3.jar in $CATALINA_HOME/bin

Absolute rubbish.  Never, never do that.

 - 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: Null-pointer exception from response.encodeUrl under Windows Tomcat 7

2011-06-09 Thread Mark Thomas
On 09/06/2011 19:28, Martin Gainty wrote:
 
 place servletapi-2.3.jar in $CATALINA_HOME/bin

Monumentally bad advice. An unbelieveably stupid idea. You should *not*
do this.

Mark

 
 $CATALINA_HOME/bin/servletapijavap ./javax/servlet/http/HttpServletResponse 
 | grep encodeURL
 public abstract java.lang.String encodeURL(java.lang.String);
 
 Martin Gainty 
 __ 
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
  
 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
 sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
 oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich 
 dem Austausch von Informationen und entfaltet keine rechtliche 
 Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen 
 wir keine Haftung fuer den Inhalt uebernehmen.
 Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
 destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
 l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci 
 est interdite. Ce message sert à l'information seulement et n'aura pas 
 n'importe quel effet légalement obligatoire. Étant donné que les email 
 peuvent facilement être sujets à la manipulation, nous ne pouvons accepter 
 aucune responsabilité pour le contenu fourni.
 
 
 
 
 Date: Thu, 9 Jun 2011 09:06:52 +0100
 From: p...@j-paine.org
 To: users@tomcat.apache.org; users@tomcat.apache.org
 Subject: Re: Null-pointer exception from response.encodeUrl under Windows 
 Tomcat 7
 
 On Thu, 9 Jun 2011, André Warnier wrote:
  
 ...

 By the way :

 (Interface HttpServletResponse, Javaee 5)
 encodeUrl
 String encodeUrl(String url)
Deprecated. As of version 2.1, use encodeURL(String url) instead

 Maybe it's worth replacing encodeUrl by encodeURL, and see if the problem 
 still happens.

 Thanks for the suggestion, André. I've just tried that, and the problem 
 still happens.
  
 Jocelyn
 
 -
 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: RE: Static resource mapping in web.xml

2011-06-09 Thread Terence M. Bandoian


On 1:59 PM, falva...@geocom.com.uy wrote:

Yes, we would probably use some tools to build the web.xml.

Currently our applications has something between 1 to 15000 servlets.

Mapping to /servlet/* how it works now, a normal URL is 
http://host:8080/webapp/servlet/myservlet;. But then I tried to remove the /servlet/ 
from the URL, that's when all this trouble began.


Don't map to /* of course: instead map to a specific URL.

My intention is to map myservlet to /myservlet, for example. This removes any 
aditional string in the URL. So the UR becomes: http://host:8080/webapp/myservlet;.

The application works fine with this new invoker mapping, the only problem is that 
resources are served under /images/images/*. This impacts in many servlets that have 
hard-coded access to images, javascripts or css files (I know how bad this is), also others have 
relative links that now don't work. Most do have a parameter pointing to the right resource folder 
and work fine, but finding the ones causing trouble is not easy.

The excuse or reason I've been getting when this matter is addressed is the 
ease of deployment the invoker provides.

I will be building a testing environment a few days from now, using a proper 
web.xml and no invoker. Guess my job now will be to demonstrate the advantages 
of this (the URL improvement will be the easiest for them to see). Of course 
for this matter to succeed the creation of a fully automated web.xml building 
script will be required.

Thanks for the help.

Best regards,
Federico.

-Mensaje original-
De: Christopher Schultz [mailto:ch...@christopherschultz.net]
Enviado el: jueves, 09 de junio de 2011 13:43
Para: Tomcat Users List
Asunto: Re: Static resource mapping in web.xml

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Federico,

On 6/8/2011 2:04 PM, falva...@geocom.com.uy wrote:

If this is the case I could make it weight-in in the matter of building a
well formed web.xml.

Although it could take some time.

How many servlets do you have?


Mapping each servlet to an /* url-pattern will avoid us from using invoker
and at the same time get rid of /servlet in the URL and keep images under
/images.

Don't map to /* of course: instead map to a specific URL.

You can use some simple tools to generate the mappings. Something like this:

$ find -name *Servlet.java | sed -e 's/\(.*\)\.java/servlet\n
servlet-name\1\/servlet-name\n
servlet-class\1\/servlet-class\n\/servlet\n\nservlet-mapping\n
servlet-name\1\/servlet-name\n
url-pattern\1\/url-pattern\n\/servlet-mapping/'

Obviously, you'll have top massage some of that: the servlet-class needs
to be dot-separated the the above command will give you slash-separated
names.

You'll also have to separate theservlet  andservlet-mapping
sections ... or just run two separate commands: one to generate the
servlet  elements and the other to generate theservlet-mapping  elements.

Removing the invoker servlet and just explicitly mapping everything is
only a /little/ tedious but much safer. Take the time to do this now.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3w+CIACgkQ9CaO5/Lv0PAi+gCfYfLAaOJQIM0ziCbGOLN4eCno
4HYAoLLVVZQogmdMk1SzdXTpLEi9zbPm
=/1
-END PGP SIGNATURE-

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


Hi, Federico-

If I understand this correctly, and you're using ant, you should be able 
to strip '/servlet' from the servlet mappings by changing the uriroot 
attribute in the jasper2 task.


-Terence Bandoian



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



Question on WORK directory of tomcat container

2011-06-09 Thread Savoy, Melinda
Due to a conflict between the cached JSPs in the work directory of a tomcat 
container on our app's QA Windows 2003 server, does the tomcat service have to 
be restarted?

Any help would be greatly appreciated.  Thanks.

Melinda Savoy
Sr. Programmer Analyst, ERP Systems
Innovative Technology Solutions
Texas Health Resources
600 E. Lamar Blvd, Ste 301, Arlington TX  76011
melindasa...@texashealth.orgmailto:melindasa...@texashealth.org

Texas Health Resources: Arlington Memorial,
Harris Methodist and Presbyterian Hospitals
A shared mission and now a shared name.





The information contained in this message and any attachments is intended only 
for the use of the individual or entity to which it is addressed, and may 
contain information that is PRIVILEGED, CONFIDENTIAL, and exempt from 
disclosure under applicable law.  If you are not the intended recipient, you 
are prohibited from copying, distributing, or using the information.  Please 
contact the sender immediately by return e-mail and delete the original message 
from your system.

RE: Question on WORK directory of tomcat container

2011-06-09 Thread Caldarale, Charles R
 From: Savoy, Melinda [mailto:melindasa...@texashealth.org] 
 Subject: Question on WORK directory of tomcat container

 Due to a conflict between the cached JSPs in the work 
 directory of a tomcat container on our app's QA Windows
 2003 server, does the tomcat service have to be restarted?

What?

Please ask someone unfamiliar with whatever problem you're having take a look 
at the above and see if it makes any sense to them.  After you explain it to 
them, send the explanation to the mailing list so we'll have some idea of what 
you're talking about.

In general, a problem in a single webapp does not require restarting Tomcat, 
but might need a restart or redeploy of the webapp.  I have no idea if that 
applies in your case.

 - 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: how to correct stop a thread and avoid leaks

2011-06-09 Thread Pid
On 09/06/2011 18:44, Calum wrote:
 On 9 June 2011 09:11, Pid p...@pidster.com wrote:
 Eh?  Why would you need to put Tomcat specific dependencies in a spec
 compliant Servlet container?  The above is simply not true.

 The OP use of a ServletContextListener is perfectly valid, (even if the
 rest of the code is a little odd).
 
 Is it better to have a separate class that implements the Listener,
 and sets running = false in the Threads, or just have the thread class
 implement the listener itself?

If we're talking abstractly, rather than in reference to the OPs code,
then for most cases I'd suggest that a ServletContextListener would be
best implemented as a thread controller, rather than as a thread.

See java.util.concurrent, e.g. Executors.class, ExecutorService.class.

The contextInitialized() method of the SCL would create  start the
service, configuring threads etc  contextDestroyed() would shut the
service down - it's a thread pool manager, so takes care of stopping the
threads, if you've implemented them correctly.


Remember to catch InterruptedException in each threads run() method and
take care to clean up properly  stop the work it does.

If you implement a ThreadFactory you can name threads  make your life
easier when/if Tomcat complains they don't shutdown properly.


p


 Or are there not really any pros or cons either way?
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 




signature.asc
Description: OpenPGP digital signature


RE: Question on WORK directory of tomcat container

2011-06-09 Thread Propes, Barry L
It might be helpful to know if you deleted items out of your work directory or 
if you are implying you have to leave cached JSPs there without touching them, 
but you altered something else?

I guess like Chuck suggested, we'd be guessing at this, but it almost sounds 
like you are afraid to dump the contents of the work directory because you want 
some things left to be easily accessed through cache, while you made some 
changes in the web app?

I'd restart it.

-Original Message-
From: Caldarale, Charles R [mailto:chuck.caldar...@unisys.com]
Sent: Thursday, June 09, 2011 2:29 PM
To: Tomcat Users List
Subject: RE: Question on WORK directory of tomcat container

 From: Savoy, Melinda [mailto:melindasa...@texashealth.org]
 Subject: Question on WORK directory of tomcat container

 Due to a conflict between the cached JSPs in the work directory of a
 tomcat container on our app's QA Windows
 2003 server, does the tomcat service have to be restarted?

What?

Please ask someone unfamiliar with whatever problem you're having take a look 
at the above and see if it makes any sense to them.  After you explain it to 
them, send the explanation to the mailing list so we'll have some idea of what 
you're talking about.

In general, a problem in a single webapp does not require restarting Tomcat, 
but might need a restart or redeploy of the webapp.  I have no idea if that 
applies in your case.

 - 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: Migrated from 6.0.29 to 7.0.10, Now I get INFO: TLD skipped. URI: http://struts.apache.org/tags-bean is already defined

2011-06-09 Thread Dilip Parihar
Hi All,

I had gone thru the same error and here is what I configured to fix the error:
The solution i did is:

1. Remove the entries from WEB.xml of taglib directive.
2. Remove the *.tld from WEB-INF folder if any because they already exists in 
struts-xxx.jar file.
3.  In JSP replace
i.  %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean %
ii. %@ taglib uri=/WEB-INF/struts-html.tld prefix=html %
iii.%@ taglib uri=/WEB-INF/struts-logic.tld prefix=logic %
With This
i.  %@ taglib uri=http://jakarta.apache.org/struts/tags-bean; 
prefix=bean %
ii. %@ taglib uri=http://jakarta.apache.org/struts/tags-html; 
prefix=html %
iii.%@ taglib uri=http://jakarta.apache.org/struts/tags-logic; 
prefix=logic %
4.  If Tomcat 7.0.11 complaints about this error:
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
e.  This means there are two or more entries of jstl (.tld) entries in jar 
file.
i.  Jstl-1.2.jar
ii. Standard.jar
Both of these files contains c.tld, fmt.tld, c.tld, sql.tld
f.  Recommended to delete: standard.jar.

Thanks,
Dilip Parihar,
Santa Fe, NM, US




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



Optimal Settings to use Tomcat as a HTTP File Server

2011-06-09 Thread Anand HS
Hi,
We plan to use tomcat to let users download static content ( media,
executables etc.. ). I was curious to know if any one has attempted it
before and if so, the settings that we need to make to tomcat configurations
to make it optimally serve static content.

Thanks,
Anand


RE: Optimal Settings to use Tomcat as a HTTP File Server

2011-06-09 Thread Caldarale, Charles R
 From: Anand HS [mailto:anan...@gmail.com] 
 Subject: Optimal Settings to use Tomcat as a HTTP File Server

 We plan to use tomcat to let users download static content 
 ( media, executables etc.. ).

As much as I like Tomcat, I have to think it might be more appropriate to use 
Apache httpd rather than Tomcat for pure static content.  However, if you 
really want to use Tomcat, and you expect a heavy load, install the APR 
connector (especially important if you're using SSL).  The other major 
configuration setting would be the Java heap size, but you'll have to 
experiment to determine what's optimal for your platform and load.

 - 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



Context Definition Doesn't Work

2011-06-09 Thread Mark Leone
I've been running Tomcat since version 4. Today, running 7.0.12,  I 
decided to define a non-standard context, and I can't get it to work 
after carefully following all the instructions in the documentation and 
doing what all my searching confirmed I should be doing.


My web app is deployed at $CATALINA_HOME/webapps/filePort. I've been 
reaching it at http://myHost/filePort. Now I want to have a context of 
/mbp/filePort, because I want the web app to run on three separate 
Tomcat instances behind an apache server, using mod_jk to route to each 
Tomcat based on the first part of the context path.


So I have the file 
$CATALINA_HOME/conf/Catalina/localhost/mbp#filePort.xml, and inside this 
file is the following XML


Context 
WatchedResourceWEB-INF/web.xml/WatchedResource
/Context

In server.xml I have Engine Catalina and Host localhost defined, 
with no Context defined. I have no Context defined anywhere else. The 
appBase for Host localhost is defined as webapps.


However, the web app is still reachable at http://myHost/filePort and 
not at http://myHost/mbp/filePort. For the latter URL, Tomcat reports 
that the requested resource is not available.


Even though it's not recommended, I tried defining a Context element in 
server.xml, inside the Host element, with path=/mbp/filePort and 
docBase=filePort but I got the same result.


Presumably I'm missing something here, but I've done what the 
documentation says to do, and it doesn't work.


-Mark

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



RE: Context Definition Doesn't Work

2011-06-09 Thread Caldarale, Charles R
 From: Mark Leone [mailto:midnightj...@verizon.net] 
 Subject: Context Definition Doesn't Work

 My web app is deployed at $CATALINA_HOME/webapps/filePort.

That's the problem; see below.

 So I have the file 
 $CATALINA_HOME/conf/Catalina/localhost/mbp#filePort.xml

And I suspect that if you look in the logs, you'll see there are errors trying 
to deploy this non-existent webapp.

 Context 
 WatchedResourceWEB-INF/web.xml/WatchedResource
 /Context

The above Context is unnecessary, since that's the default.  Unless you're 
planning on adding something else in there, you can remove the file.

 the web app is still reachable at http://myHost/filePort

Because that's where it's located.  Change the location of the webapp to:

$CATALINA_HOME/webapps/mbp#filePort

 Even though it's not recommended, I tried defining a Context element in 
 server.xml, inside the Host element, with path=/mbp/filePort and 
 docBase=filePort but I got the same result.

Good, because that was a bad idea, presumably done as an act of desperation.

 - 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: Optimal Settings to use Tomcat as a HTTP File Server

2011-06-09 Thread Sriram Narayanan
On Fri, Jun 10, 2011 at 7:10 AM, Caldarale, Charles R
chuck.caldar...@unisys.com wrote:
 From: Anand HS [mailto:anan...@gmail.com]
 Subject: Optimal Settings to use Tomcat as a HTTP File Server

 We plan to use tomcat to let users download static content
 ( media, executables etc.. ).

 As much as I like Tomcat, I have to think it might be more appropriate to use 
 Apache httpd rather than Tomcat for pure static content.  However, if you 
 really want to use Tomcat, and you expect a heavy load, install the APR 
 connector (especially important if you're using SSL).  The other major 
 configuration setting would be the Java heap size, but you'll have to 
 experiment to determine what's optimal for your platform and load.

+1. Let Apache / Nginx / etc serve the static content and let Tomcat
focus on running your webapplication.

-- Sriram
==
Belenix: www.belenix.org

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



Re: Question on WORK directory of tomcat container

2011-06-09 Thread Sriram Narayanan
On Fri, Jun 10, 2011 at 12:42 AM, Savoy, Melinda
melindasa...@texashealth.org wrote:
 Due to a conflict between the cached JSPs in the work directory of a tomcat 
 container on our app's QA Windows 2003 server, does the tomcat service have 
 to be restarted?

 Any help would be greatly appreciated.  Thanks.


I've faced this before. You may need to restart at least the web
application - you don't need to restart Tomcat itself.

-- Sriram
==
Belenix: www.belenix.org

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



RE: Optimal Settings to use Tomcat as a HTTP File Server

2011-06-09 Thread Caldarale, Charles R
 From: Caldarale, Charles R 
 Subject: RE: Optimal Settings to use Tomcat as a HTTP File Server

  We plan to use tomcat to let users download static content 
  ( media, executables etc.. ).

 As much as I like Tomcat, I have to think it might be more 
 appropriate to use Apache httpd rather than Tomcat for pure
 static content.

I have to qualify my statement: if the *only* thing you're using Tomcat for is 
delivering static content, then httpd would be better.  If you have other 
reasons to use Tomcat (e.g., running servlets or JSPs), then by all means use 
it as your static content server as well.  You will generally see better 
performance overall by not having two servers in the mix forced to communicate 
with each other.
 
 - 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: Optimal Settings to use Tomcat as a HTTP File Server

2011-06-09 Thread Anand HS
Thanks Charles and Sriram for your inputs.
Since my requirement is to just serve static content, I will consider apache
httpd for it.

Thanks.!
Anand

On Thu, Jun 9, 2011 at 10:48 PM, Caldarale, Charles R 
chuck.caldar...@unisys.com wrote:

  From: Caldarale, Charles R
  Subject: RE: Optimal Settings to use Tomcat as a HTTP File Server

   We plan to use tomcat to let users download static content
   ( media, executables etc.. ).

  As much as I like Tomcat, I have to think it might be more
  appropriate to use Apache httpd rather than Tomcat for pure
  static content.

 I have to qualify my statement: if the *only* thing you're using Tomcat for
 is delivering static content, then httpd would be better.  If you have other
 reasons to use Tomcat (e.g., running servlets or JSPs), then by all means
 use it as your static content server as well.  You will generally see better
 performance overall by not having two servers in the mix forced to
 communicate with each other.

  - 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