Custom error page with stacktrace

2008-08-20 Thread Tom van Wietmarschen

L.S,

I'm running tomcat to serve out XML to a custom client (not a 
webbrowser). In order to show an error page that this client can 
actually display I use custom error pages in Tomcat. For this I have 
specified a JSP as an error page, this works very well. However, during 
the test phase of our project I'd also like to add the stacktrace to the 
error document and optionally to a logfile. Since the client cannot 
interpret a normal HTML page, the standard 500 error page that comes 
with Tomcat is unusable. How can I access the stacktrace/error message 
from my own JSP or a servlet so I can output it to our own custom XML 
format and our testers can give proper feedback. I did some googling for 
this but it seems like everyone else is just trying to get rid of the 
stacktrace instead of changing it.


Sincerely,
   Tom van Wietmarschen
--

**Tom van Wietmarschen**
Software Engineer

Service2Media B.V.
Vreelandseweg 7
1216 CG Hilversum

Capitool 41   
7521 PL Enschede


Tel  +31 (0)35 626 46 12
Fax +31 (0)35 626 46 13
www.service2media.com <http://www.service2media.com>


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Response already comitted on first line of servlet

2008-07-04 Thread Tom van Wietmarschen

Tom van Wietmarschen wrote:

L.S,

I'm investigating a problem in which one of our servlets doesn't return
any headers most of the time (sometimes it does work, but it seems quite
random) After a bit of digging I found out that the reason the headers
aren't added is that the response already seems to be comitted.
Okay, I found and fixed the bug yesterday evening, I was using a 
MemoryCacheImageOutputStream that I didn't dispose of properly. So when 
it got garbage collected it closed the outputstream in its finalize 
method, and since the response object is recycled this comitted the 
response of a subsequent run.


Tom
--

**Tom van Wietmarschen**
Software Engineer

Service2Media B.V.
Vreelandseweg 7
1216 CG Hilversum

Capitool 41   
7521 PL Enschede


Tel  +31 (0)35 626 46 12
Fax +31 (0)35 626 46 13
www.service2media.com <http://www.service2media.com>


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Response already comitted on first line of servlet

2008-07-03 Thread Tom van Wietmarschen

L.S,

I'm investigating a problem in which one of our servlets doesn't return 
any headers most of the time (sometimes it does work, but it seems quite 
random) After a bit of digging I found out that the reason the headers 
aren't added is that the response already seems to be comitted.


I've added the following two lines to the top of my Servlet (these are 
the first 2 lines of doGet())


   if(response.isCommitted())
   logger.error("WTF?");

and it seems that the response is already commited on the 1st line of my 
servlet, before I've done anything to it. Also, I've got no filters 
defined for this servlet. I've set a breakpoint on the logger.error line 
and this is the stacktrace at that point:


Daemon Thread [TP-Processor3] (Suspended (breakpoint at line 31 in 
ImageLoader))   
   ImageLoader.doGet(HttpServletRequest, HttpServletResponse) line: 31   
   ImageLoader(HttpServlet).service(HttpServletRequest, 
HttpServletResponse) line: 690   
   ImageLoader(HttpServlet).service(ServletRequest, ServletResponse) 
line: 803   
   ApplicationFilterChain.internalDoFilter(ServletRequest, 
ServletResponse) line: 269   
   ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) 
line: 188   
   StandardWrapperValve.invoke(Request, Response) line: 213   
   StandardContextValve.invoke(Request, Response) line: 174   
   StandardHostValve.invoke(Request, Response) line: 127   
   ErrorReportValve.invoke(Request, Response) line: 117   
   StandardEngineValve.invoke(Request, Response) line: 108   
   CoyoteAdapter.service(Request, Response) line: 174   
   JkCoyoteHandler.invoke(Msg, MsgContext) line: 200   
   HandlerRequest.invoke(Msg, MsgContext) line: 283   
   ChannelSocket.invoke(Msg, MsgContext) line: 773   
   ChannelSocket.processConnection(MsgContext) line: 703   
   ChannelSocket$SocketConnection.runIt(Object[]) line: 895   
   ThreadPool$ControlRunnable.run() line: 689   
   ThreadWithAttributes(Thread).run() line: 595   

Looking at the enclosed CoyoteResponse object shows that the 'committed' 
variable is set to true, but bytesWritten is 0, contentLength is 0, 
contentType is null, etc. so there doesn't seem to have been anything 
done to the response that could have triggered a commit.


I've also tried adding a response.reset() at the top of the method, this 
also fails, 10 lines down the road the response is committed again (I 
haven't touched the response object yet at that point in the code, I'm 
also doing nothing multithreaded to the response object myself. 
Furthermore for debugging I'm only using 1 client and that client is 
firing requests serially and not in parallel). Requests are going 
through a mod_jk on an Apache2.2 server, but direct connections to the 
tomcat seem to show the same behaviour.


A response.reset() just before the response.addHeader seems to work, but 
this, of course, isn't a real solution.


Does anyone have a clue what's going on ? I can't find anything in our 
code that could trigger this behaviour, could it be a bug in Tomcat or 
am I missing something ?


Sincerely,
   Tom
--

**Tom van Wietmarschen**
Software Engineer

Service2Media B.V.
Vreelandseweg 7
1216 CG Hilversum

Capitool 41   
7521 PL Enschede


Tel  +31 (0)35 626 46 12
Fax +31 (0)35 626 46 13
www.service2media.com <http://www.service2media.com>


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: The troubles with tribes

2008-03-12 Thread Tom van Wietmarschen

Tom van Wietmarschen wrote:

Filip Hanik - Dev Lists wrote:
  

The biggest issue I have is that I keep getting
memberAdded/memberDisappeared events from the same member. I've made a
small test app (based on the example on the Tribes introduction page)
that I run on a client PC and a similar implementation that I start
from a ServletContextListener. The client app creates a group, starts
it, sends a message and then quits. I get the memberAdded event, then
the message, and then a memberGone, memberAdded,memberGone, etc. until
the client has died.
  

what is your config? could be a simple mistake.

(...)

Can you tell me how I should configure this ? I'll have a look around
the source in the mean time to see if I can figure this out myself.
  
I got the problem fixed, I tested it on several machines and only one of 
them was failing, the rest worked as expected. After adding some more 
debug output I noticed that alle the machines that worked correctly 
showed up with their hostname in the memberAdded event, the machine that 
didn't work only showed by IP adress. Turns out NetBios was disabled on 
that machine. Apparently some kind of reverse-lookup is required for 
this to work and it used netbios on Win32. I'm guessing that on Linux 
this will just do a reverse DNS lookup ?


Tom

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: The troubles with tribes

2008-03-12 Thread Tom van Wietmarschen

Filip Hanik - Dev Lists wrote:

The biggest issue I have is that I keep getting
memberAdded/memberDisappeared events from the same member. I've made a
small test app (based on the example on the Tribes introduction page)
that I run on a client PC and a similar implementation that I start
from a ServletContextListener. The client app creates a group, starts
it, sends a message and then quits. I get the memberAdded event, then
the message, and then a memberGone, memberAdded,memberGone, etc. until
the client has died.


what is your config? could be a simple mistake.
  
There is no config, I basically tried the code that is in the 
'introduction' page, which seems to be the only piece of documentation, 
and it doesn't mention anything about configuration. Also, I'm not 
running this on TC6 but on a TC5.5 server (I just added the 
apache-tribes jar to the lib directory of my webapp)


Can you tell me how I should configure this ? I'll have a look around 
the source in the mean time to see if I can figure this out myself.

Another issue is that there seems to be no way to define a group. If I
create a GroupChannel for use by application A, and in the same subnet
I create a GroupChannel for application B, application A will receive
messages for app B and vice versa, app A will see members from app B
join the group, etc.
Is it possible to create a group that's only for use within one
application ?


groups are divided up by the multicasting address/port if you are using
multicasting. furthermore, you can set the "domain" for each member, and
then have your application filter out based on that.
  
Is every application a member or is there one member for every host ? 
(can I e.g. set the 'domain' for app A to "com.ourcompany.productA" and 
the 'domain' for appB to something different and then filter on it or is 
the 'domain' setting per-host ?)


Tom

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



The troubles with tribes

2008-03-11 Thread Tom van Wietmarschen

L.S.,

After investigating several possibilities I decided to test Tribes for 
messaging in an application I'm developing. However, I've run in to 
several problems which I can't figure out by myself. I hope this is the 
correct place to ask these questions since there seems to be no separate 
Tribes project or mailing list.


The biggest issue I have is that I keep getting 
memberAdded/memberDisappeared events from the same member. I've made a 
small test app (based on the example on the Tribes introduction page) 
that I run on a client PC and a similar implementation that I start from 
a ServletContextListener. The client app creates a group, starts it, 
sends a message and then quits. I get the memberAdded event, then the 
message, and then a memberGone, memberAdded,memberGone, etc. until the 
client has died.


Another issue is that there seems to be no way to define a group. If I 
create a GroupChannel for use by application A, and in the same subnet I 
create a GroupChannel for application B, application A will receive 
messages for app B and vice versa, app A will see members from app B 
join the group, etc.
Is it possible to create a group that's only for use within one 
application ?


Sincerely,
   Tom van Wietmarschen

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using a custom method of session-id propagation

2008-03-11 Thread Tom van Wietmarschen

Christopher Schultz wrote:

| The problem with both cookies and session id's in the URL is that we
| develop applications for use on cellphones. Cell network operators are a
| bunch of not-so-nice-people who sometimes feel the need to screw up HTTP
| traffic in their gateways, e.g. by messing with cookies and session ids.

Can you give us an example of what happens to your JSESSIONID cookie?
  
At the moment, nothing, but that can change any time, that's why we want 
to have at least the option of using a different header. We've had 
operators mess with all kinds of standard HTTP headers so we try to have 
a fallback for these.

| There is no guarantee that the cookies that arrive on the handset are
| the same as the ones that have been sent out from our servers. Sometimes
| cookies go missing, standard HTTP headers are mutilated, etc.

That sucks. Is it selective? I mean... do you always get the GET line
correctly, just the others are hosed?
  
Depends, a while back everything got messed up on a certain local 
operator. They even replaced the user-agent with something incorrect. 
(basically, every request looked like it came from an OperaMini browser).


Sincerely,
   Tom

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using a custom method of session-id propagation

2008-03-05 Thread Tom van Wietmarschen


Tom this is 100% correct "there is no way to even instantiate a session 
object from a  self-supplied session-id let alone replace the current 
session object in the HttpRequest." but I am still a little curious as 
to why Tomcats generated session id is not adequate, is it purely 
because you can't get at it early enough?


Yes, the session id itself is adequate, I don't want to change that at 
all, nor do I want to change the session manager.


What I want to change is how the session id is communicated to the 
client and back. Basically, I want to change the object that retrieves 
the session ID from the HTTP request and feeds it to the session 
manager. (storing the session id in an additional header in the response 
is no problem)


The problem with both cookies and session id's in the URL is that we 
develop applications for use on cellphones. Cell network operators are a 
bunch of not-so-nice-people who sometimes feel the need to screw up HTTP 
traffic in their gateways, e.g. by messing with cookies and session ids. 
There is no guarantee that the cookies that arrive on the handset are 
the same as the ones that have been sent out from our servers. Sometimes 
cookies go missing, standard HTTP headers are mutilated, etc.


Our experience is that the custom X-headers are left alone, so we want 
to use a custom header to send and retrieve the session ID.
After reading a little, Tomcat 5x onwards comes with session replication 
capabilities, which means there is some code which you can reference and 
write a valve that intercepts the request as soon as a new session is 
created and before its sent back to the user in the response, an example 
of this being the ReplicationValve which ships with Tomcat. ||You can 
then persist it in a database or do whatever you want with it.
I've looked at the Tomcat API doc's and it seems to me the 
sessionmanager itself is not responsible for retrieving the session id, 
the session id is fed to it by someone else. (See 'findSession' in 
ManagerBase). Also, sending the session id back to the client is not the 
problem I can use a filter to do that. The problem is that if the client 
sends the session ID to the server in a custom header, Tomcat needs to 
pick up that session id and use that when calling findSession. So who is 
calling findSession and is it something I can easily replace ?


Furthermore, as an additional difficulty, we only use sessions in a 
subset of our applications, so it would be preferrable if this is 
something we can enable on a per-application basis.


I hope this clarifies what I'm trying to do.

Sincerely,
   Tom
--

**Tom van Wietmarschen**
Software Engineer

Service2Media B.V.
Vreelandseweg 7
1216 CG Hilversum

Capitool 41   
7521 PL Enschede


Tel  +31 (0)35 626 46 12
Fax +31 (0)35 626 46 13
www.service2media.com <http://www.service2media.com>


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Using a custom method of session-id propagation

2008-03-04 Thread Tom van Wietmarschen

L.S.,

I was wondering if it is possible to write a custom method of
propagating the session ID between HTTP requests. Specifically: we want
to store the session id in a X-ourcompanyname-sessionid header (we use a
custom http client so we can modify that to send the sessionid back in a
header).

The reason for this is that we have to deal with clients that are using
mobile data connections, and mobile phone operators sometimes feel the
need to mess with a clients cookies and sessions as well as doing other
kinds of nasty things in their proxies. Non-standard headers are usually
left alone.

I've been looking at a way to do this but I can't find a solution,
filters seem to be too late in the chain: a request object is already
created and there is no way to even instantiate a session object from a
self-supplied session-id let alone replace the current session object in
the HttpRequest.

Does anyone known if there is a way to write my own handlers for
retrieving and setting the current sessionid and have tomcat use that
instead of looking at the requesturl or cookies ?

Sincerely,
   Tom van Wietmarschen




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]