Re: Do objects in session always need to be serializable?

2011-04-19 Thread Thomas Strauß

Am 20.04.2011 um 07:41 schrieb Mukarram Baig:

> Hello Guys,

Hello,


I will not comment on the low memory feature, as I don't know it, but if you do 
not enable serialization on your session objects and shutdown or reload an app, 
the sessions will get persisted and you get an exception telling you that the 
session contains "non-serializable" objects. The session persistence is clearly 
written in the Tomcat log, does not happen behind the scenes.
I would suggest that this would also happen for the low-mem situation or should 
prevent Tomcat to unload your session at all.

Having said that, without further details, I can only give a hint as we have 
seen similar stuff, where we could not explain application behavior until we 
realized that the users are opening different screens in the same browser. Our 
application and especially session data handling was not prepared to cope with 
such a (natural, agreed) situation as different screens where using the same 
session objects. 

Maybe this could explain your NPEs?

Best regards,

Thomas


> I might be asking something that is very fundamental, but please bear with
> me here. We are using tomcat in a non-clustered environment. We put certain
> domain objects in the session and we have a heartbeat going which ensures
> that the sessions are valid in the lifetime of the screen. The domain
> objects are not serializable. We have randomly seen NullPointerExceptions
> thrown when accessing properties of these domain objects via the session. I
> had read about Tomcat deciding to serialize sessions when it thinks that the
> available memory is getting tight on some forum (
> http://www.coderanch.com/t/86379/Tomcat/Problems-disabling-Session-Persistence-Manager)
> but couldn't see the same in the servlet spec or documentation on tomcat's
> site. Wanted to verify if this is indeed the case? If yes, under what
> (approximate) conditions does tomcat decide to serialize sessions to disk
> and back? Overall, is the recommended approach to always make objects in the
> session serializable? Also, wouldn't it be great if a better exception like
> NotSerializableException be thrown rather than the user stumbling over null
> values and NPE's being thrown?
> 
> Thanks in advance!
> 
> P.S.: We are using tomcat 6.0.16 on Solaris in 64 bit JVM mode with Xms
> 1024m and Xmx 4096m.
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> 



smime.p7s
Description: S/MIME cryptographic signature


Do objects in session always need to be serializable?

2011-04-19 Thread Mukarram Baig
 Hello Guys,

I might be asking something that is very fundamental, but please bear with
me here. We are using tomcat in a non-clustered environment. We put certain
domain objects in the session and we have a heartbeat going which ensures
that the sessions are valid in the lifetime of the screen. The domain
objects are not serializable. We have randomly seen NullPointerExceptions
thrown when accessing properties of these domain objects via the session. I
had read about Tomcat deciding to serialize sessions when it thinks that the
available memory is getting tight on some forum (
http://www.coderanch.com/t/86379/Tomcat/Problems-disabling-Session-Persistence-Manager)
but couldn't see the same in the servlet spec or documentation on tomcat's
site. Wanted to verify if this is indeed the case? If yes, under what
(approximate) conditions does tomcat decide to serialize sessions to disk
and back? Overall, is the recommended approach to always make objects in the
session serializable? Also, wouldn't it be great if a better exception like
NotSerializableException be thrown rather than the user stumbling over null
values and NPE's being thrown?

Thanks in advance!

P.S.: We are using tomcat 6.0.16 on Solaris in 64 bit JVM mode with Xms
1024m and Xmx 4096m.


Re: Need help with SSL Certificate install on Tomcat 6.0.29 APR.

2011-04-19 Thread Crypto Sal

Hi Jin,

In my experiences with the APR and Tomcat, you need to use 'OpenSSL' to 
generate the keypair (CSR/key) I am fairly certain the APR can't read 
Java Keystore files. You would only use a keystore (JKS) using 'keytool' 
with JSSE.


I think you have at least 2 options at this point:

1. Generate new key pair with OpenSSL using the 'req' utility.
2. Export new keystore that was created with 'keytool' to a PKCS12 file 
and then use openSSL to create PEM key, certificate and Certificate 
authority files.


I would suggest you do #1 vs. that of #2, unless #2 cause you extra 
money or you don't mind doing a little 'work'. :-P


--Crypto.Sal



On 04/19/2011 05:54 PM, Jin H wrote:

Hi.  We are a school running Tomcat 6.0.29 for Windows server 2003 with APR.  I 
currently have an SSL certificate installed.  I'm trying to update it with the 
renewed SSL certificate but I'm having no luck.

Here are the commands I used to create the CSR.

in the jdk1.6.0_17\bin folder i used this command:

keytool -certreq -keyalg RSA -alias alias2011 -file cert.csr -keystore 
key2011.key -keysize 2048

It then asks for a password which i enter.

I generated the CSR and sent it to my SSL vendor.  They e-mailed my ssl 
certificate back to me.
But they told me that I had to install 2 intermediate Certificate files.
I dowloaded a primary.crt and secondary.crt files from them.

I then ran this command to import the primary.crt

keytool -import -trustcacerts -alias primary -keystore key2011.key -file 
primary.crt

Then the secondary.crt

keytool -import -trustcacerts -alias secondary -keystore key2011.key -file 
secondary.crt

finally the SSL certificate they e-mailed back.

keytool -import -trustcacerts -alias alias2011 -keystore key2011.key -file 
2011.crt

After this I copy the key2011.key and 2011.crt to the root of tomcat.

I edited server.xml to this:



I didn't know the difference between SSLPassword and keystorePass so I put both 
in there.
I never put a password for my previous ssl certificate and it worked so I'm 
confused why I have to put one in now.

BTW here is the current server.xml that works with the about to expire SSL 
certificate.





Please help.  Thanks in advance.




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



Re: Need help with SSL Certificate install on Tomcat 6.0.29 APR.

2011-04-19 Thread Igor Cicimov
So why did you enter password when you created the csr if you dont want it?

On Apr 20, 2011 7:54 AM, "Jin H"  wrote:


Hi.  We are a school running Tomcat 6.0.29 for Windows server 2003 with APR.
 I currently have an SSL certificate installed.  I'm trying to update it
with the renewed SSL certificate but I'm having no luck.

Here are the commands I used to create the CSR.

in the jdk1.6.0_17\bin folder i used this command:

keytool -certreq -keyalg RSA -alias alias2011 -file cert.csr -keystore
key2011.key -keysize 2048

It then asks for a password which i enter.

I generated the CSR and sent it to my SSL vendor.  They e-mailed my ssl
certificate back to me.
But they told me that I had to install 2 intermediate Certificate files.
I dowloaded a primary.crt and secondary.crt files from them.

I then ran this command to import the primary.crt

keytool -import -trustcacerts -alias primary -keystore key2011.key -file
primary.crt

Then the secondary.crt

keytool -import -trustcacerts -alias secondary -keystore key2011.key -file
secondary.crt

finally the SSL certificate they e-mailed back.

keytool -import -trustcacerts -alias alias2011 -keystore key2011.key -file
2011.crt

After this I copy the key2011.key and 2011.crt to the root of tomcat.

I edited server.xml to this:



I didn't know the difference between SSLPassword and keystorePass so I put
both in there.
I never put a password for my previous ssl certificate and it worked so I'm
confused why I have to put one in now.

BTW here is the current server.xml that works with the about to expire SSL
certificate.





Please help.  Thanks in advance.


Re: Fix the cookie path with mod_jk

2011-04-19 Thread André Warnier

Thomas Freitag wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Chris,

On 18.04.11 um 16:42, Christopher Schultz wrote:

Thomas,

On 4/18/2011 3:34 AM, Thomas Freitag wrote:

Hi Yu

On 18.04.11 um 16:19, Yu Kikuchi wrote:

Hello All.
My Environment of Application Server is:
Apache 2.2.3, mod_jk 1.2.30, JBoss 5.0.0GA
I want to rewrite the Path contained in cookies. For example;
From) Set-Cookie JSESSIONID=794CC361C468123CA1D187B9C5F5FAA5; Path=/foo
To  ) Set-Cookie JSESSIONID=794CC361C468123CA1D187B9C5F5FAA5; Path=/bar
Appearing below is a good documentation about mod_jk,
but it doesn't mention about when I use mod_jk with before Apache 2.2.3.
The Apache Tomcat Connector - Generic HowTo "Reverse Proxy HowTo"
http://tomcat.apache.org/connectors-doc/generic_howto/proxy.html#URL Rewriting
Does anyone know any good ideas?
Or should I ask ApacheML about this problem?

The recipes in the HowTo you mentioned won't work with Apache httpd
2.2.3, because mod_headers supports the edit function only for Version
2.2.4 and newer.

Using mod_rewrite will probably work with previous versions. Just
speculating, here.


Fixing/altering outgoing (response) headers is beyond the
functionality of mod_rewrite. The other parts work with mod_rewrite,
but mod_headers (with its edit functionality) is an important part in
this use case.



Getting back to the original issue, Thomas seems to be right when he says that if the 
cookie path is set to /foo, the browser will return it also for URLs such as /foobar and 
/foofoo.
From the Cookie RFCs, i gather that the cookie path is taken as a *prefix*, and /foo is a 
prefix of /foobar.


Now the issue is : who is setting the cookie path ?  if it is the application, and if this 
is a concern, then I would suggest to fix the application.


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



Re: Fix the cookie path with mod_jk

2011-04-19 Thread Thomas Freitag
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Chris,

On 18.04.11 um 16:42, Christopher Schultz wrote:
> Thomas,
> 
> On 4/18/2011 3:34 AM, Thomas Freitag wrote:
> > Hi Yu
> > 
> > On 18.04.11 um 16:19, Yu Kikuchi wrote:
> >> Hello All.
> > 
> >> My Environment of Application Server is:
> >> Apache 2.2.3, mod_jk 1.2.30, JBoss 5.0.0GA
> > 
> >> I want to rewrite the Path contained in cookies. For example;
> >> From) Set-Cookie JSESSIONID=794CC361C468123CA1D187B9C5F5FAA5; Path=/foo
> >> To  ) Set-Cookie JSESSIONID=794CC361C468123CA1D187B9C5F5FAA5; Path=/bar
> > 
> >> Appearing below is a good documentation about mod_jk,
> >> but it doesn't mention about when I use mod_jk with before Apache 2.2.3.
> > 
> >> The Apache Tomcat Connector - Generic HowTo "Reverse Proxy HowTo"
> >> http://tomcat.apache.org/connectors-doc/generic_howto/proxy.html#URL 
> >> Rewriting
> > 
> >> Does anyone know any good ideas?
> >> Or should I ask ApacheML about this problem?
> > 
> > The recipes in the HowTo you mentioned won't work with Apache httpd
> > 2.2.3, because mod_headers supports the edit function only for Version
> > 2.2.4 and newer.
> 
> Using mod_rewrite will probably work with previous versions. Just
> speculating, here.

Fixing/altering outgoing (response) headers is beyond the
functionality of mod_rewrite. The other parts work with mod_rewrite,
but mod_headers (with its edit functionality) is an important part in
this use case.

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

iEYEARECAAYFAk2uCqgACgkQGE5pHr3PKuVfSQCeLsAVWBjzaA+U9NWaafNgXww/
TbMAnRa+J4cvaglSl4HCGDqQVRCjgG7p
=BJRk
-END PGP SIGNATURE-

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



RE: Working of Tomcat with MS Access

2011-04-19 Thread George Sexton

> -Original Message-
> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> Sent: Friday, April 15, 2011 1:02 PM
> To: Tomcat Users List
> Subject: Re: Working of Tomcat with MS Access
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Jeff,
> 
> On 4/15/2011 11:11 AM, Jeff Hubbs wrote:
> > You do realize, I hope, that what you're proposing is akin to
> sourcing
> > parts for your jet engine from Fisher-Price?
> 
> :)
> 
> > MS Access is a desktop application that accesses files on disk.  Java
> > apps running on Tomcat typically access an RDBMS over a network
> > connection via SQL statements and their responses.  AFAIK there is
> not a
> > "server instantiation" of MS Access;
> 
> While you're right, I believe that MS has an Access JDBC (or ODBC)
> driver that allows you to specify the file to open as part of the JDBC
> URL. It's kind of like using a CSV file as a database, though...

More to the point, there's no such thing as a 64-bit ODBC driver for Access. In 
short, if you use Access for a data store, your app must run in 32 bit mode 
using a 32-bit JVM.


> 
> Anyway, this is possible. He's just missing some configuration of some
> kind. I feel kind of fortunate that I have no past experience on which
> to draw to help the OP.
> 
> Google for "read access database in Java" perhaps?
> 
> - -chris


George Sexton
MH Software, Inc.
303 438-9585
www.mhsoftware.com


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



Need help with SSL Certificate install on Tomcat 6.0.29 APR.

2011-04-19 Thread Jin H

Hi.  We are a school running Tomcat 6.0.29 for Windows server 2003 with APR.  I 
currently have an SSL certificate installed.  I'm trying to update it with the 
renewed SSL certificate but I'm having no luck. 

Here are the commands I used to create the CSR.

in the jdk1.6.0_17\bin folder i used this command:

keytool -certreq -keyalg RSA -alias alias2011 -file cert.csr -keystore 
key2011.key -keysize 2048

It then asks for a password which i enter.

I generated the CSR and sent it to my SSL vendor.  They e-mailed my ssl 
certificate back to me.
But they told me that I had to install 2 intermediate Certificate files.
I dowloaded a primary.crt and secondary.crt files from them.

I then ran this command to import the primary.crt

keytool -import -trustcacerts -alias primary -keystore key2011.key -file 
primary.crt

Then the secondary.crt

keytool -import -trustcacerts -alias secondary -keystore key2011.key -file 
secondary.crt

finally the SSL certificate they e-mailed back.

keytool -import -trustcacerts -alias alias2011 -keystore key2011.key -file 
2011.crt

After this I copy the key2011.key and 2011.crt to the root of tomcat.

I edited server.xml to this:



I didn't know the difference between SSLPassword and keystorePass so I put both 
in there.
I never put a password for my previous ssl certificate and it worked so I'm 
confused why I have to put one in now.

BTW here is the current server.xml that works with the about to expire SSL 
certificate.





Please help.  Thanks in advance.
  

Re: AW: AW: Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread André Warnier

Fischereit, Jana wrote:

Hi,

I resolved my problem. The problem was that the method request.getInputStream().read() just finish reading the in the server.xml file defined maxHTTPHeaderSize of the inputStream. So I wrote my own method to read the inputsteam and everything works fine. 


Besides I changed my client-side to multipartFileUpload (like the example from 
the previous posted link: 
http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/MultipartFileUploadApp.java?view=markup)


That sounds very bizarre.
If you use a multipart file upload, and you read the request body yourself on the server 
side, then you should be getting funny things in the uploaded file.

Have you checked it ?


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



AW: AW: Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread Fischereit, Jana
Hi,

I resolved my problem. The problem was that the method 
request.getInputStream().read() just finish reading the in the server.xml file 
defined maxHTTPHeaderSize of the inputStream. So I wrote my own method to read 
the inputsteam and everything works fine. 

Besides I changed my client-side to multipartFileUpload (like the example from 
the previous posted link: 
http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/MultipartFileUploadApp.java?view=markup)

Thank you for your help!

Jana

-Ursprüngliche Nachricht-
Von: André Warnier [mailto:a...@ice-sa.com] 
Gesendet: Dienstag, 19. April 2011 16:10
An: Tomcat Users List
Betreff: Re: AW: Setting the maxHTTPHeaderSize to 'infinity'

Pid wrote:
> On 4/19/11 12:20 PM, André Warnier wrote:
>> Hi.
>>
>> I will let someone else comment on your code.
> 
> I can say that doesn't look like i'd expect it to, per the example code
> from the Commons HTTP 3.x or HTTP Client 4.x versions.
> 
> 
> 
>> (But remember, this is a help forum for Tomcat, which is the server
>> side.  It is not really a forum to help people write Java HTTP cients).
>>
>> It looks like this is your first try at sending a file to a server.
>> So let me recommend something :
>>
>> I would start by creating a simple HTML form with an > ..>, and then make sure that it works using the form.
>> (Because, to upload a file, you also need to have some special code on
>> the server to receive it, and you had better make sure that that side is
>> working first).
> 
> +1
> 
>> You can find an example here :
>> http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/http/fileupload/package-summary.html
>>
>> and maybe someone else can suggest more examples somewhere.
> 
> http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/MultipartFileUploadApp.java?view=markup
> 
> 

Lest Jana would get confused :
The first link above points to an example for the server code needed (the 
servlet which 
receives the file upload POST).
The second example is one for the client side : the workstation Java program 
which uploads 
a file to a server, via a POST request.


> p
> 
>> Then, once it is working with the form, attack the client side.
>> If you search a bit on Google, you will find several examples of how to
>> do this right.
>> No need to re-invent the wheel.
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
> 
> 


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

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



Re: Restarting Tomcat & Threads

2011-04-19 Thread David kerber

On 4/19/2011 10:34 AM, Zbynek Vavros wrote:


- How do you kill Tomcat ?

I stop its service.

- You say "after start" and "I didnt [sic] start anything" in the same
sentence; you're contradicting yourself.

I start Tomcat which starts my webapp but connection to Lotus is started
separatedlly.
= I start my webapp but do not start "Lotus connector".

1) My code(thread) could not be executed unless I start it via web
interface.Which I dont.

2) Im talking about log from log4j so it is log of my application.No one
else's.


So you have to go through that web interface to start the lotus thread, 
but you're not doing that and the thread is still starting up?


Sounds like the method that starts the thread is being called from 
somewhere that you're not expecting.  Any chance it's being fired off 
from a timer or a listener?







Zbynek

  Kind Regards / Mit
  freundlichen Grüßen /
  Üdvözlettel / S
  pozdravem:


  Zbynek VAVROS (Embedded
  Development image moved
 to file:
pic01634.gif)

  Delivery Centre  616 00, Brno
   Central Europe  Technicka 21
 Brno SITE Czech Republic

  (Embedded image moved to
file: pic31451.gif)Phone: 420-53341- x6283
   Mobile:
   E-mail: zbynek_vav...@cz.ibm.com




IBM Global Services
   Delivery Center Czech
  Republic, s.r.o.
Registered address:
  Brno, Technicka 2995/21,
  Zip code: 61600, Company
ID: 26244535
   Entered in the
Commercial Register
 maintained by the
   Regional Court in Brno
   (Part C, Entry 39922)

IBM Global Services
   Delivery Center Czech
  Republic, s.r.o.
   Sídlo: Brno, Technická
   2995/21, PSČ 61600 IČ:
  26244535
Zapsaná v obchodním
 rejstříku, vedeném
   Krajským soudem v Brně
   oddíl C, vlozka 39922






|>
| From:  |
|>
   
>--|
   |"Caldarale, Charles R"  
  |
   
>--|
|>
| To:|
|>
   
>--|
   |Tomcat Users List  
  |
   
>--|
|>
| Date:  |
|>
   
>--|
   |04/19/2011 04:09 PM 
  |
   
>--|
|>
| Subject:   |
|>
   
>--|
   |RE: Restarting Tomcat&  Threads 
  |
   
>--|






From: Zbynek Vavros [mailto:zbynek_vav...@cz.ibm.com]
Subject: Restarting Tomcat&  Threads



I have noticed that when I kill Tomcat (shut down its service)


How do you kill Tomcat?  (Be specific.)


then after start this thread is started automatically (I can
see messages about connecting to Lotus in log when I didnt
start anything).


You say "after start" and "I didnt [sic] start anything" in the same
sentence; you're contradicting yourself.

Tomcat knows nothing about your thread or the connection to Lotus, so one
of two things is happening:

1) Your code is being executed, you just aren't aware of it.

2) Something else is connecting to Lotus and you're mistaking that for your
code.

  - Chuck



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



Re: Restarting Tomcat & Threads

2011-04-19 Thread André Warnier

Zbynek Vavros wrote:

- How do you kill Tomcat ?

I stop its service.

- You say "after start" and "I didnt [sic] start anything" in the same
sentence; you're contradicting yourself.

I start Tomcat which starts my webapp but connection to Lotus is started
separatedlly.
= I start my webapp but do not start "Lotus connector".

1) My code(thread) could not be executed unless I start it via web
interface.Which I dont.

2) Im talking about log from log4j so it is log of my application.No one
else's.



The tomcat code, by itself, has no reason to connect to Lotus.
So if something connects to Lotus, it must be in the code of your application.
But you say above that you do not do that.
So something above is wrong.

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



RE: Restarting Tomcat & Threads

2011-04-19 Thread Zbynek Vavros

- How do you kill Tomcat ?

I stop its service.

- You say "after start" and "I didnt [sic] start anything" in the same
sentence; you're contradicting yourself.

I start Tomcat which starts my webapp but connection to Lotus is started
separatedlly.
= I start my webapp but do not start "Lotus connector".

1) My code(thread) could not be executed unless I start it via web
interface.Which I dont.

2) Im talking about log from log4j so it is log of my application.No one
else's.


Zbynek
   
 Kind Regards / Mit
 freundlichen Grüßen / 
 Üdvözlettel / S   
 pozdravem:
   
   
 Zbynek VAVROS (Embedded
 Development image moved
to file:
   pic01634.gif)
   
 Delivery Centre  616 00, Brno 
  Central Europe  Technicka 21 
Brno SITE Czech Republic   
   
 (Embedded image moved to  
   file: pic31451.gif)Phone: 420-53341- x6283  
  Mobile:  
  E-mail: zbynek_vav...@cz.ibm.com 
   
   
   
   
   IBM Global Services 
  Delivery Center Czech
 Republic, s.r.o.  
   Registered address: 
 Brno, Technicka 2995/21,  
 Zip code: 61600, Company  
   ID: 26244535
  Entered in the   
   Commercial Register 
maintained by the  
  Regional Court in Brno   
  (Part C, Entry 39922)
   
   IBM Global Services 
  Delivery Center Czech
 Republic, s.r.o.  
  Sídlo: Brno, Technická   
  2995/21, PSČ 61600 IČ:   
 26244535  
   Zapsaná v obchodním 
rejstříku, vedeném   
  Krajským soudem v Brně   
  oddíl C, vlozka 39922  
   





|>
| From:  |
|>
  
>--|
  |"Caldarale, Charles R"   
 |
  
>--|
|>
| To:|
|>
  
>--|
  |Tomcat Users List   
 |
  
>--|
|>
| Date:  |
|>
  
>---

Re: AW: Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread André Warnier

Pid wrote:

On 4/19/11 12:20 PM, André Warnier wrote:

Hi.

I will let someone else comment on your code.


I can say that doesn't look like i'd expect it to, per the example code
from the Commons HTTP 3.x or HTTP Client 4.x versions.




(But remember, this is a help forum for Tomcat, which is the server
side.  It is not really a forum to help people write Java HTTP cients).

It looks like this is your first try at sending a file to a server.
So let me recommend something :

I would start by creating a simple HTML form with an , and then make sure that it works using the form.
(Because, to upload a file, you also need to have some special code on
the server to receive it, and you had better make sure that that side is
working first).


+1


You can find an example here :
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/http/fileupload/package-summary.html

and maybe someone else can suggest more examples somewhere.


http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/MultipartFileUploadApp.java?view=markup




Lest Jana would get confused :
The first link above points to an example for the server code needed (the servlet which 
receives the file upload POST).
The second example is one for the client side : the workstation Java program which uploads 
a file to a server, via a POST request.




p


Then, once it is working with the form, attack the client side.
If you search a bit on Google, you will find several examples of how to
do this right.
No need to re-invent the wheel.


-
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: Restarting Tomcat & Threads

2011-04-19 Thread Caldarale, Charles R
> From: Zbynek Vavros [mailto:zbynek_vav...@cz.ibm.com] 
> Subject: Restarting Tomcat & Threads

> I have noticed that when I kill Tomcat (shut down its service)

How do you kill Tomcat?  (Be specific.)

> then after start this thread is started automatically (I can 
> see messages about connecting to Lotus in log when I didnt 
> start anything).

You say "after start" and "I didnt [sic] start anything" in the same sentence; 
you're contradicting yourself.

Tomcat knows nothing about your thread or the connection to Lotus, so one of 
two things is happening:

1) Your code is being executed, you just aren't aware of it.

2) Something else is connecting to Lotus and you're mistaking that for your 
code.

 - 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



Restarting Tomcat & Threads

2011-04-19 Thread Zbynek Vavros


Hi,

I would like to ask on strange behavior Im experiencing.
I have webapp that connects to Lotus Notes periodically(every 1 minute).
For this I have class that implements Runnable that takes care about
connection itself.
Im starting this using basic :

Thread t = new Thread(MyClassImplementingRunnable);
t.start();

I have noticed that when I kill Tomcat (shut down its service) then after
start this thread is started
automatically (I can see messages about connecting to Lotus in log when I
didnt start anything).

Is this usual behavior?
Is there any was for threads "not to start automatically" ?

Im beginner with Tomcat so excuse my lack of knowledge.

Thanks
Zbynek


   
 Kind Regards / Mit
 freundlichen Grüßen / 
 Üdvözlettel / S   
 pozdravem:
   
   
 Zbynek VAVROS (Embedded
 Development image moved
to file:
   pic31252.gif)
   
 Delivery Centre  616 00, Brno 
  Central Europe  Technicka 21 
Brno SITE Czech Republic   
   
 (Embedded image moved to  
   file: pic21477.gif)Phone: 420-53341- x6283  
  Mobile:  
  E-mail: zbynek_vav...@cz.ibm.com 
   
   
   
   
   IBM Global Services 
  Delivery Center Czech
 Republic, s.r.o.  
   Registered address: 
 Brno, Technicka 2995/21,  
 Zip code: 61600, Company  
   ID: 26244535
  Entered in the   
   Commercial Register 
maintained by the  
  Regional Court in Brno   
  (Part C, Entry 39922)
   
   IBM Global Services 
  Delivery Center Czech
 Republic, s.r.o.  
  Sídlo: Brno, Technická   
  2995/21, PSČ 61600 IČ:   
 26244535  
   Zapsaná v obchodním 
rejstříku, vedeném   
  Krajským soudem v Brně   
  oddíl C, vlozka 39922  
   



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

Re: AW: Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread Pid
On 4/19/11 12:20 PM, André Warnier wrote:
> Hi.
> 
> I will let someone else comment on your code.

I can say that doesn't look like i'd expect it to, per the example code
from the Commons HTTP 3.x or HTTP Client 4.x versions.



> (But remember, this is a help forum for Tomcat, which is the server
> side.  It is not really a forum to help people write Java HTTP cients).
> 
> It looks like this is your first try at sending a file to a server.
> So let me recommend something :
> 
> I would start by creating a simple HTML form with an  ..>, and then make sure that it works using the form.
> (Because, to upload a file, you also need to have some special code on
> the server to receive it, and you had better make sure that that side is
> working first).

+1

> 
> You can find an example here :
> http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/http/fileupload/package-summary.html
> 
> and maybe someone else can suggest more examples somewhere.

http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/MultipartFileUploadApp.java?view=markup


p

> Then, once it is working with the form, attack the client side.
> If you search a bit on Google, you will find several examples of how to
> do this right.
> No need to re-invent the wheel.
> 
> 
> -
> 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: AW: Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread André Warnier

Hi.

I will let someone else comment on your code.
(But remember, this is a help forum for Tomcat, which is the server side.  It is not 
really a forum to help people write Java HTTP cients).


It looks like this is your first try at sending a file to a server.
So let me recommend something :

I would start by creating a simple HTML form with an , and then make 
sure that it works using the form.
(Because, to upload a file, you also need to have some special code on the server to 
receive it, and you had better make sure that that side is working first).


You can find an example here :
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/http/fileupload/package-summary.html
and maybe someone else can suggest more examples somewhere.

Then, once it is working with the form, attack the client side.
If you search a bit on Google, you will find several examples of how to do this 
right.
No need to re-invent the wheel.


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



AW: Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread Fischereit, Jana
Thank you for your answer!

First I also thought that they have nothing to do with one another. But when I 
tried to transfer a xml-file (size 9kb) it did not work. Afterwards I increased 
the maxHTTPHeaderSize to 10 kb. So I concluded that the xml-stream is contained 
in the body of the request-header. 

Here is my java-code I am using to transfer the file to the server:

public static void main(String[] args) {

OutputStream os = null;
InputStream is = null;

try {

URL url = new URL(args[0]);
String urlString = url.toString();
String reportFile = args[1];
String dataSourceFile = args[2];

System.out.println("\nURL:  " + args[0]);
System.out.println("ReportFile:  " + args[1]);
System.out.println("DataSourceFile: " + args[2]);

// Prepare HTTP post
PostMethod post = new PostMethod(urlString);

File file = new File(dataSourceFile);
InputStreamRequestEntity requestEntity = new   
InputStreamRequestEntity(
new FileInputStream(dataSourceFile), 
file.length());
post.setFollowRedirects(false);
post.setRequestEntity(requestEntity);

// Specify content type and encoding
post.setRequestHeader("Content-type", "text/xml; 
charset=ISO-8859-1");

post.addRequestHeader("reportFile=", reportFile);
post.addRequestHeader("xmlFileSize=", file.length() + 
"");

HttpClient httpclient = new HttpClient();

// Execute request
try {

int result = httpclient.executeMethod(post);
System.out.println("Is post-request sent?: " + 
post.isRequestSent());

// Display status code
System.out.println("Response status code: " + 
result);

// Redirect by using a get-method
URI uri = url.toURI();
Desktop.getDesktop().browse(uri);

} catch (Exception ex) {
System.out.println("\nError: " + ex);
} finally {
post.releaseConnection();
}

} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


The post.setRequestBody(body) is deprecated and 
post.setRequestEntity(requestEntity) should be used instead. I tried the 
deprecated method as well, but received the same results.

-Ursprüngliche Nachricht-
Von: André Warnier [mailto:a...@ice-sa.com] 
Gesendet: Dienstag, 19. April 2011 12:28
An: Tomcat Users List
Betreff: Re: Setting the maxHTTPHeaderSize to 'infinity'

Fischereit, Jana wrote:
> Hi,
> 
> I would like to send xml-files by using the http-post *request-body*. 

(emphasis added)


But I read that the default maxHTTPHeaderSize is 8kb

max HTTP *Header* Size  (emphasis added)

Nothing to do with one another.



-
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: Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread André Warnier

Fischereit, Jana wrote:

Hi,

I would like to send xml-files by using the http-post *request-body*. 


(emphasis added)


But I read that the default maxHTTPHeaderSize is 8kb

max HTTP *Header* Size  (emphasis added)

Nothing to do with one another.



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



Setting the maxHTTPHeaderSize to 'infinity'

2011-04-19 Thread Fischereit, Jana
Hi,

I would like to send xml-files by using the http-post request-body. But I read 
that the default maxHTTPHeaderSize is 8kb 
(http://tomcat.apache.org/tomcat-6.0-doc/config/http.html#Standard_Implementation).
 So I cannot transfer files of arbitrary size.

Why is there a limit? May problems occur by increasing that size to for example 
20 mb?

And if there are no problems, how can I set this parameter to 'infinity'? I 
tried to use "-1" in the server.xml file, but recieved a 
java.lang.NegativeArraySizeException:




I am using Tomcat 6.0.32, Windows XP Professional SP3, Sun Java 1.6.0 Update 24.



Thanks and Regards,


Jana


Re: [OT] Protecting against HTTP response splitting

2011-04-19 Thread Konstantin Kolinko
2011/4/19 Christopher Schultz :
>
> Looks like I must override sendRedirect because otherwise the setHeader
> call implemented in Response.sendRedirect isn't intercepted by the
> wrapper class.
>
> For those interested, see below for the implementation I came up with.
>

>            if(containsCRorLF(value))
>                throw new IllegalArgumentException("Header value must
> not contain CR or LF characters");

It would be better to check that all characters are correct ones rather
than check for two specific incorrect characters.

Checking for \r \n only might be not enough. Though that depends on
where the value comes from.

Best regards,
Konstantin Kolinko

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



Re: Log rotate catalina.out

2011-04-19 Thread Igor Cicimov
Hi Thomas,

Yes I have reference in the catalina.sh to the log4j.properties file:

LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/log4j.properties"

this is what I get in the catalina.out on restart:

INFO: Configuring Log4j from File:
/data/apache-tomcat-6.0.29/webapps/application/WEB-INF/etc/log4j-configuration.xml
19/04/2011 4:16:24 PM org.apache.catalina.core.ApplicationContext log
INFO:  Log4J context Initialized

where log4j-configuration.xml is the application XML file located as given
in the above log line. So that is being loaded ok.

If I remove CONSOLE from the list of root loggers, isn't this going to
prevent anything from being logged in the catalina.out file? I would like to
keep the useful info from the restart process.

Thanks,
Igor

On Mon, Apr 18, 2011 at 4:54 PM, Thomas Freitag  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi Igor,
>
> On 04/18/2011 08:23 AM, Igor Cicimov wrote:
> > Hi Thomas,
> >
> > First thanks for your reply. This is the relevant section in the
> > $CATALINA_BASE/conf/log4j.properties file:
>
> Do you use the JAva System Property
> - -Dlog4j.configuration=file:$CATALINA_BASE/conf/log4j.properties to
> reference this file? If not, it will never be loaded.
>
> >
> > log4j.debug=true
> > log4j.rootLogger=INFO, CATALINA, CONSOLE
> > .
> > .
> > .
> > log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
> > log4j.appender.CONSOLE.encoding=UTF-8
> > log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
> > log4j.appender.CONSOLE.DatePattern = '.'-MM-dd
> > log4j.appender.CONSOLE.layout.conversionPattern=%d{ISO8601} - %X{login} -
> > %X{device} - %X{uri} - %X{log} - %X{sessionId} - %m%n
>
> Remove CONSOLE from the list of root loggers.
>
> > and this is the log4j.properties file (relevant console section) for the
> > application:
> >
> >  > class="org.apache.log4j.DailyRollingFileAppender">
> >  > value="$CATALINA_BASE/logs/application-console.log"/>
> > 
> > 
> > 
> >  value="%d{HH:mm:ss}
> > [%c] %m%n"/>
> > 
> > 
>
> This is a XML configuration, you can not mix this with a properties
> configuration. Where is this file located WAR!WEB-INF/classes? If you
> use the system property I mentioned before this file will never be loaded.
>
> > but I can still see the application console output going into
> 'catalina.out'
> > instead in the 'application-console.log' file which never gets created.
>
> I don't believe your log4j configuration get loaded, check the
> catalina.out for log4j debug messages (at least during Tomcat startup,
> some lines with prefix "LOG4J" should appear).
>
> > And this is what I have in the application context:
> >
> >   
> >
> > Thanks,
> > Igorr,
>
>
> Regards,
> - --
> Thomas Freitag
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk2r4C0ACgkQGE5pHr3PKuW+/ACeKaT7UbhhQHMe9G/gUlgnLuSv
> +/YAn0z6AOITkg+v4QsjCxmC6vIxQHxz
> =YwFi
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>