RE: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Brian
Hi Mark,

I applied your advice. I added a directive to my error page, so it wont
create a session variable, and therefore won't try to create a session if it
does exist (%@ page session=false%).
Well, IT WORKED! I got rid of the java.lang.IllegalStateException: Cannot
create a session after the response has been committed exception, which I
have seen in my log for months or maybe years!

Now the previous thing that went wrong is able to show its details in the
log. What is that? A Struts tag that tries to output the content of a bean
that is not present even though it should (this is the Struts tag:
bean:write name=TEXT-NoteNoShippingFees/).
That bean should always be present, because it is created in the previous
Struts action. How can it be missing SOMETIMES, if it is not the only bean
that is being created in the previous action, and others of these beans that
are created in the action are present in the page? I guess it has something
to do with the buffer that gets full sometimes, or am I wrong? What do you
think?

In fact, I have had LOTs of problems with beans that dissappear even
though they should be present because they were created in the previous
actions. I have been dealing with these randomic problem for YEARS, and I
applied just a patch for that (If the bean is not present, redirect to the
home page instead of showing an error message and dumping a trace in the
log).  That was just a workaround, and not a clean solution. I will try now
to use a buffer with 16K, to see if that will solve this.

Brian


   

 -Original Message-
 From: Mark Thomas [mailto:ma...@apache.org]
 Sent: Thursday, September 23, 2010 02:51 PM
 To: Tomcat Users List
 Subject: Re: In org.apache.catalina.connector.Request.doGetSession,
 java.lang.IllegalStateException: Cannot create a session after the
response
 has been committed
 
 On 23/09/2010 12:01, Brian wrote:
  Thanks for the commited explanation, but I still have a doubt: Where
  in my code do I commit? I don't do it explicitly, so it is happening
  at some point automatically but I don't know exactly where/when. If a
  full buffer is not the cause, what is it for the commit to happen? In
  which method/class does it happen?
 
 As soon as the buffer is full or you flush the response.
 
  I will raise the 8K capacity in the buffer, just in case that is the
  problem. That would explain why this problem appears to be randomic.
  If just some pages are too big, that would make the buffer to be full,
  and then everything in the sequence you described would happen.
 
  I don't explicitly disable the session creation in my JSPs, so that is
  not the problem. I don't call any flushing method either.
 
 You need to explicitly disable session generation in your error JSP.
 That will ensure the sequence never happens.
 
  It is clear that something goes wrong in my ProductsForModel.jps
  page (actually, in the java code generated for it), so an Exception is
  being thrown and  PageContextImpl.handlePageException() takes care
  of it. But what exception? Is it the 
  java.lang.IllegalStateException: Cannot create a session after the
response
 has been committed? Or is it another one?
 
 Yep, the broken error JSP is hiding the exception. Another option is to
remove
 the error handling JSPs.
 
 Mark
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org


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



Re: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread André Warnier

Brian wrote:
...


In fact, I have had LOTs of problems with beans that dissappear 


that's usually a problem associated with age.  I was going to ask, but

I have been dealing with these randomic problem for YEARS, 


you've answered that yourself.

;-)

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



Re: [OT] In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Brian,

On 9/24/2010 2:22 AM, Brian wrote:
 Well, IT WORKED!

Excellent.

 Now the previous thing that went wrong is able to show its details in the
 log. What is that? A Struts tag that tries to output the content of a bean
 that is not present even though it should (this is the Struts tag:
 bean:write name=TEXT-NoteNoShippingFees/).

How is the bean declared in the page? Or, is it declared in one page and
used in another?

 That bean should always be present, because it is created in the previous
 Struts action.

Where is it stored? Remember that there are 4 scopes (in increasing
order of specificity): application, session, request, and page. If your
page is looking in request scope, but the bean is in the session, it
won't be found. Or, alternatively, if you store a bean in the request
and issue a redirect, then the bean has likely been discarded.

 How can it be missing SOMETIMES, if it is not the only bean
 that is being created in the previous action, and others of these beans that
 are created in the action are present in the page? I guess it has something
 to do with the buffer that gets full sometimes, or am I wrong? What do you
 think?

You'll have to give us more details. Note that this is not a Struts
forum, though many of us (including myself) have Struts experience and
would be glad to help. Technically, you ought to start a new thread
since you're asking about a new subject (this helps people find answers
to their questions when searching the archives).

 In fact, I have had LOTs of problems with beans that dissappear even
 though they should be present because they were created in the previous
 actions. I have been dealing with these randomic problem for YEARS, and I
 applied just a patch for that (If the bean is not present, redirect to the
 home page instead of showing an error message and dumping a trace in the
 log).  That was just a workaround, and not a clean solution. I will try now
 to use a buffer with 16K, to see if that will solve this.

Could you also be experiencing session timeouts that aren't properly
handled? Does your application use any kind of authentication and
authorization? If not, you could easily be seeing visitors with expired
sessions accessing actions that expect the session to be in a certain state.

There are lots of ways to fix this kind of thing, but the remedies all
depend upon your requirements and application architecture.

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

iEYEARECAAYFAkycqy0ACgkQ9CaO5/Lv0PDGMgCgktZRGzJLSmg6KLu1fMhu0G+J
66oAniuA/KNxzzRpYyJEqOgadZZ79tF2
=EjKC
-END PGP SIGNATURE-

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



RE: [OT] In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Brian
Hi Christoper,


 -Original Message-
 From: Christopher Schultz [mailto:ch...@christopherschultz.net]
 Sent: Friday, September 24, 2010 08:44 AM
 To: Tomcat Users List
 Subject: Re: [OT] In org.apache.catalina.connector.Request.doGetSession,
 java.lang.IllegalStateException: Cannot create a session after the response
 has been committed
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Brian,
 
 On 9/24/2010 2:22 AM, Brian wrote:
  Well, IT WORKED!
 
 Excellent.
 
  Now the previous thing that went wrong is able to show its details in
  the log. What is that? A Struts tag that tries to output the content
  of a bean that is not present even though it should (this is the Struts tag:
  bean:write name=TEXT-NoteNoShippingFees/).
 
 How is the bean declared in the page? Or, is it declared in one page and used
 in another?


The previous Struts actions places it in the session object.

 
  That bean should always be present, because it is created in the
  previous Struts action.
 
 Where is it stored? Remember that there are 4 scopes (in increasing order of
 specificity): application, session, request, and page. If your page is 
 looking in
 request scope, but the bean is in the session, it won't be found. Or,
 alternatively, if you store a bean in the request and issue a redirect, then 
 the
 bean has likely been discarded.


It is stored in the session, just because I wanted to avoid the problems that 
happen when you redirect. That means that the bean will consume memory while 
the session is alive (instead of just for the time the request or response is 
alive), but memory is not a big issue here.
That makes me think that the buffer full, then flushed is maybe the reason 
why the bean dissappears somehow.
I have increased the buffer from 8k to 64k, and I will keep an eye on the log 
to see if it still happens.

 
  How can it be missing SOMETIMES, if it is not the only bean that is
  being created in the previous action, and others of these beans that
  are created in the action are present in the page? I guess it has
  something to do with the buffer that gets full sometimes, or am I
  wrong? What do you think?
 
 You'll have to give us more details. Note that this is not a Struts forum,
 though many of us (including myself) have Struts experience and would be
 glad to help. Technically, you ought to start a new thread since you're asking
 about a new subject (this helps people find answers to their questions when
 searching the archives).


You are right. If the problem still exists, I will seach for a solution in 
another source dedicated to Struts. This is no more related to Tomcat directly.

 
  In fact, I have had LOTs of problems with beans that dissappear even
  though they should be present because they were created in the
  previous actions. I have been dealing with these randomic problem
  for YEARS, and I applied just a patch for that (If the bean is not
  present, redirect to the home page instead of showing an error message
  and dumping a trace in the log).  That was just a workaround, and not
  a clean solution. I will try now to use a buffer with 16K, to see if that 
  will
 solve this.
 
 Could you also be experiencing session timeouts that aren't properly
 handled? Does your application use any kind of authentication and
 authorization? If not, you could easily be seeing visitors with expired 
 sessions
 accessing actions that expect the session to be in a certain state.

The sessions expire if 2 hours have passed, and if that happens, the system 
forwards them to another page. 
I mean, in my programming I already considered what should happen if the 
session suddenly expired, and it should not arrive to this point.

Thanks!
 



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



Re: [OT] In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Wesley Acheson
On Fri, Sep 24, 2010 at 5:29 PM, Brian bbprefix-m...@yahoo.com wrote:
 Hi Christoper,


 The sessions expire if 2 hours have passed, and if that happens, the system 
 forwards them to another page.
 I mean, in my programming I already considered what should happen if the 
 session suddenly expired, and it should not arrive to this point.

 Thanks!


You can't be sure that's whats happening though. The browser can make
its own rules with session cookies. Unlikely but possible for the
cookies to be deleted sometimes. Some people may not accept session
cookies in the first place.

Are you encoding the urls for sessions too? Where's the bean being set
in an Interceptor, in a filter, on an earlier page in the session?  Is
it possible that you've missed a route to the pages which should
always have this bean?

Is it possible that people are directly navigating to the page that
throws the error (say via a bookmark, or got a cached search engine
result)?

My advise would be (assuming you have an access log enabled that
contains the session id). Look at the access log. Try to figure out
the route the person took through your site. How long between page
views? Was there some detail that they entered in the bean which was
unserialiasble etc.

I doubt anyone here can tell you the answer to your new problem, it
too dependant on your new environment, however hopefully we will point
you in a good direction to start looking. Also you can start a new
thread as Christopher put but mark it OT. (if you don't believe tomcat
is at fault).

Regards,

Wesley Acheson

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



RE: [OT] In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Brian
Hi Wesley,


 -Original Message-
 From: Wesley Acheson [mailto:wesley.ache...@gmail.com]
 Sent: Friday, September 24, 2010 10:44 AM
 To: Tomcat Users List
 Subject: Re: [OT] In org.apache.catalina.connector.Request.doGetSession,
 java.lang.IllegalStateException: Cannot create a session after the
response
 has been committed
 
 On Fri, Sep 24, 2010 at 5:29 PM, Brian bbprefix-m...@yahoo.com wrote:
  Hi Christoper,
 
 
  The sessions expire if 2 hours have passed, and if that happens, the
system
 forwards them to another page.
  I mean, in my programming I already considered what should happen if the
 session suddenly expired, and it should not arrive to this point.
 
  Thanks!
 
 
 You can't be sure that's whats happening though. The browser can make its
 own rules with session cookies. Unlikely but possible for the cookies to
be
 deleted sometimes. Some people may not accept session cookies in the first
 place.


That is interesting. I think I need to study that subject...
Oh, regarding people not accepting cookies: Struts then mantains a
jsessionid in the URL.

 
 Are you encoding the urls for sessions too? Where's the bean being set in
an
 Interceptor, in a filter, on an earlier page in the session?  Is it
possible that
 you've missed a route to the pages which should always have this bean?


I use Struts. All my URLs are actions (.do). So for all of them, a java code
is executed, whish creates the bean and stores it in the session.

 
 Is it possible that people are directly navigating to the page that throws
the
 error (say via a bookmark, or got a cached search engine result)?

I already considered that in my programming, years ago. If they do, it doesn
matter. The actions still execute given that they access a .do and not a
.jsp, and the bean gets created immediately before, before the JSP is sent
to the response. And if other beans that should be present (because they
should have been created, if they followed a regular path of actions in my
site) are not present, the client is redirected to the home page. 
That certainly happens a lot, given that my site gets thousands of request
from the crawlers such as GoogleBot! And they do whatever they want,
certainly.
 

 My advise would be (assuming you have an access log enabled that contains
 the session id). Look at the access log. Try to figure out the route the
person
 took through your site. How long between page views? Was there some
 detail that they entered in the bean which was unserialiasble etc.


GOOD IDEA! I will do it!

 


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



Re: [OT] In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Brian,

On 9/24/2010 11:29 AM, Brian wrote:
 -Original Message-
 From: Christopher Schultz [mailto:ch...@christopherschultz.net]
 Sent: Friday, September 24, 2010 08:44 AM

 Where is it stored? Remember that there are 4 scopes (in increasing order of
 specificity): application, session, request, and page. If your page is 
 looking in
 request scope, but the bean is in the session, it won't be found. Or,
 alternatively, if you store a bean in the request and issue a redirect, then 
 the
 bean has likely been discarded.
 
 It is stored in the session, just because I wanted to avoid the 
 problems that happen when you redirect.

Are you sure that the user is hanging-on to the session? If the client
doesn't support cookies, are you properly issuing a redirect? (If you
use Struts's ActionForward with redirect=true in S1 or if you use a
result type=redirect in S2 then you should be okay).

 That makes me think that the buffer full, then flushed
 is maybe the reason why the bean dissappears somehow.

Very unlikely: the bean is put into the session far earlier than the
error occurs, and the session shouldn't be damaged by anything like what
you describe.

 Could you also be experiencing session timeouts that aren't properly
 handled? Does your application use any kind of authentication and
 authorization? If not, you could easily be seeing visitors with expired 
 sessions
 accessing actions that expect the session to be in a certain state.
 
 The sessions expire if 2 hours have passed, and if that happens, the
 system forwards them to another page.

How is that done? Not the forward... the detection of session expiration.

 I mean, in my programming I already considered what should happen if
 the session suddenly expired, and it should not arrive to this point.

But it might end up there anyway :)

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

iEYEARECAAYFAkyc25YACgkQ9CaO5/Lv0PC81gCgo/rUKOR7kbFCpShpxaKDfb65
a6IAmwfqbITWH7w54XGfc2mtVj3/RZHH
=tD97
-END PGP SIGNATURE-

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



RE: [OT] In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Brian
Well... I must say that it looks like you are really an expert!  I need to 
check again my app in order to be able to respond all your questions. I started 
it 5 years ago, so there are a lot of details that I programmed long time ago, 
and once they seemed to work  fine, I gradually forgot about them.

But... for now, it SEEMS that the dissapearing beans issue is not happening 
anymore. However, it takes more time to be sure. Maybe I have been like lucky, 
and they will happen anytime soon.

At least the can't create session if response has been commited has been 
solved totally. That is great!!!
 

 -Original Message-
 From: Christopher Schultz [mailto:ch...@christopherschultz.net]
 Sent: Friday, September 24, 2010 12:11 PM
 To: Tomcat Users List
 Subject: Re: [OT] In org.apache.catalina.connector.Request.doGetSession,
 java.lang.IllegalStateException: Cannot create a session after the response
 has been committed
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Brian,
 
 On 9/24/2010 11:29 AM, Brian wrote:
  -Original Message-
  From: Christopher Schultz [mailto:ch...@christopherschultz.net]
  Sent: Friday, September 24, 2010 08:44 AM
 
  Where is it stored? Remember that there are 4 scopes (in increasing
  order of
  specificity): application, session, request, and page. If your page
  is looking in request scope, but the bean is in the session, it won't
  be found. Or, alternatively, if you store a bean in the request and
  issue a redirect, then the bean has likely been discarded.
 
  It is stored in the session, just because I wanted to avoid the
  problems that happen when you redirect.
 
 Are you sure that the user is hanging-on to the session? If the client doesn't
 support cookies, are you properly issuing a redirect? (If you use Struts's
 ActionForward with redirect=true in S1 or if you use a result
 type=redirect in S2 then you should be okay).
 
  That makes me think that the buffer full, then flushed
  is maybe the reason why the bean dissappears somehow.
 
 Very unlikely: the bean is put into the session far earlier than the error 
 occurs,
 and the session shouldn't be damaged by anything like what you describe.
 
  Could you also be experiencing session timeouts that aren't properly
  handled? Does your application use any kind of authentication and
  authorization? If not, you could easily be seeing visitors with
  expired sessions accessing actions that expect the session to be in a
 certain state.
 
  The sessions expire if 2 hours have passed, and if that happens, the
  system forwards them to another page.
 
 How is that done? Not the forward... the detection of session expiration.
 
  I mean, in my programming I already considered what should happen if
  the session suddenly expired, and it should not arrive to this point.
 
 But it might end up there anyway :)
 
 - -chris
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (MingW32)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iEYEARECAAYFAkyc25YACgkQ9CaO5/Lv0PC81gCgo/rUKOR7kbFCpShpxaKDfb
 65
 a6IAmwfqbITWH7w54XGfc2mtVj3/RZHH
 =tD97
 -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: [OT] In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-24 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Brian,

On 9/24/2010 3:38 PM, Brian wrote:
 At least the can't create session if response has been commited has
 been solved totally. That is great!!!

Yup. Now you can see all those error messages you've been missing.

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

iEYEARECAAYFAkyc/wAACgkQ9CaO5/Lv0PCiwQCgsfaU6xOj4Dn5NsMLKtiaAC77
Fe0AoKre/bNzU86Gk1/TRrTpKkWMtyJf
=s67J
-END PGP SIGNATURE-

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



In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-23 Thread Brian
Hi, 

First of all, I'm using Tomcat 6.0.29 (the latest as of September 2010),
Struts and other technologies not relevant here. 

My website runs fine 99% of the time, but several times per day I get an
error in my Tomcat Log, so it is an sporadic issue. I don't know the reason.
My code is separated in model/view/controller, given that I'm using Struts,
so my code has been correctly separated in layers. This error happens in
several JSP pages. 
As far as I can understand, Tomcat generates a Java class (a servlet) for
every JSP (well, everybody know that I guess). When my problem arrises, an
exception is being thrown when the corresponding generated servlet tries to
run the _jspService() method that uses a lot of out.write() methods to
send the output to the response. An exception is being thrown for some
reason, and then my log gets the error trace. 
Anybody knows what is going on? 
What does response has been commited mean? I have a theory: Maybe it means
that in the java code that the container generated for my JSP, at least one
out.write() method has already been used, which means that It already has
started to send html code to the browser. Am I right? 
Again, this is a sporadic issue, which drives me crazy!

This is the error in the log: 


---
Sep 21, 2010 3:18:42 PM org.apache.jasper.runtime.JspFactoryImpl
internalGetPageContext 
SEVERE: Exception initializing page context 
java.lang.IllegalStateException: Cannot create a session after the response
has been committed Which session is my code creating? where?
Why is this sporadic? 
at org.apache.catalina.connector.Request.doGetSession(Request.java:2377) 
at org.apache.catalina.connector.Request.getSession(Request.java:2097) 
at
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:83
3) 
at
javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWr
apper.java:216) 
at
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRe
quest.java:547) 
at
javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWr
apper.java:216) 
at
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRe
quest.java:547) 
at
javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWr
apper.java:216) 
at
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRe
quest.java:547) 
at
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRe
quest.java:493) 
at
org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:1
46) 
at
org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:12
4) 
at
org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryIm
pl.java:107) 
at
org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:
63) 
at
org.apache.jsp.WEB_002dINF.pages.utility.Error_jsp._jspService(Error_jsp.jav
a:49) -- This is the JSP page where all my JSP pages redirect
when something goes wrong 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
77) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290) 
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206) 
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.
java:646) 
at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch
er.java:551) 
at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher
.java:488) 
at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:9
68) 
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:621) 
at
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
mpl.java:820) 
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:791) 
at
org.apache.jsp.WEB_002dINF.pages.ProductsForModel_jsp._jspService(ProductsFo
rModel_jsp.java:1137) --- In this case, the problem happened in my page
ProductsForModel.jsp 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
77) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 

Re: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-23 Thread Mark Thomas
On 23/09/2010 07:42, Brian wrote:
 What does response has been commited mean? I have a theory: Maybe it means
 that in the java code that the container generated for my JSP, at least one
 out.write() method has already been used, which means that It already has
 started to send html code to the browser. Am I right? 
 Again, this is a sporadic issue, which drives me crazy!

committed means that the HTTP headers have been written to the client
and no further headers can be sent (note: creating a session requires
sending a cookie header to the client - this will be important in a
bit). Output is buffered (I think 8k by default - might be 4k) by
default so you can still add headers even after some content has been
written.

JSPs create sessions by default unless you explicitly disable this.

I suspect the sequence is:
1. Your page starts processing
2. The page is committed (either it calls flush or the output fills the
buffer so it has to flush)
3. Something goes wrong
4. Redirect to error JSP
5. Error JSP tries to create a session
6. Response has been committed so session can't be created
7. You get the error you are seeing

If step 3 occurs before step 2 then everything will work as the response
won't have been committed.

Mark



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



RE: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-23 Thread Brian
Wow. This is what I call Premium Support! I was thinking about writing en
email to you, Mark, since I was studying the Tomcat source code and saw your
name there. But thought it would be too direct to write to you. I'm honored
to receive your response, really  :-)

Thanks for the commited explanation, but I still have a doubt: Where in my
code do I commit? I don't do it explicitly, so it is happening at some point
automatically but I don't know exactly where/when. If a full buffer is not
the cause, what is it for the commit to happen? In which method/class does
it happen?

I will raise the 8K capacity in the buffer, just in case that is the
problem. That would explain why this problem appears to be randomic. If
just some pages are too big, that would make the buffer to be full, and then
everything in the sequence you described would happen.

I don't explicitly disable the session creation in my JSPs, so that is not
the problem. I don't call any flushing method either.

I still have another doubt: According to your sequence, in step 2 my page is
commited (Maybe because of a full buffer, maybe any other reason I don't
imagine). OK. But in step 3 (something goes wrong), I guess you are
talking about these two lines in my log:

at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:791) - This takes care of that
at
org.apache.jsp.WEB_002dINF.pages.ProductsForModel_jsp._jspService(ProductsFo
rModel_jsp.java:1137) Here something goes wrong, and an Exception
is being thrown

It is clear that something goes wrong in my ProductsForModel.jps page
(actually, in the java code generated for it), so an Exception is being
thrown and  PageContextImpl.handlePageException() takes care of it. But
what exception? Is it the  java.lang.IllegalStateException: Cannot create a
session after the response has been committed? Or is it another one? I
guess it is another one, and that the cannot create... exception is being
thrown after that, when executing the service method in the java code that
correspoonds to the JSP error page to which I redirect. But how can I know
what exception raised in my ProductsForModel.jps page? It seems that since
the code in the JSP error page didnt work (because of its own exception), it
didn't do its job: to explain what went wrong in the ProductsForModel.jps
page.

Thanks a lot!



 -Original Message-
 From: Mark Thomas [mailto:ma...@apache.org]
 Sent: Thursday, September 23, 2010 01:11 PM
 To: Tomcat Users List
 Subject: Re: In org.apache.catalina.connector.Request.doGetSession,
 java.lang.IllegalStateException: Cannot create a session after the
response
 has been committed
 
 On 23/09/2010 07:42, Brian wrote:
  What does response has been commited mean? I have a theory: Maybe it
  means that in the java code that the container generated for my JSP,
  at least one out.write() method has already been used, which means
  that It already has started to send html code to the browser. Am I
right?
  Again, this is a sporadic issue, which drives me crazy!
 
 committed means that the HTTP headers have been written to the client
 and no further headers can be sent (note: creating a session requires
sending
 a cookie header to the client - this will be important in a bit). Output
is
 buffered (I think 8k by default - might be 4k) by default so you can still
add
 headers even after some content has been written.
 
 JSPs create sessions by default unless you explicitly disable this.
 
 I suspect the sequence is:
 1. Your page starts processing
 2. The page is committed (either it calls flush or the output fills the
buffer so
 it has to flush) 3. Something goes wrong 4. Redirect to error JSP 5. Error
JSP
 tries to create a session 6. Response has been committed so session can't
be
 created 7. You get the error you are seeing
 
 If step 3 occurs before step 2 then everything will work as the response
won't
 have been committed.
 
 Mark
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org


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



Re: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-23 Thread Mark Thomas
On 23/09/2010 12:01, Brian wrote:
 Thanks for the commited explanation, but I still have a doubt: Where in my
 code do I commit? I don't do it explicitly, so it is happening at some point
 automatically but I don't know exactly where/when. If a full buffer is not
 the cause, what is it for the commit to happen? In which method/class does
 it happen?

As soon as the buffer is full or you flush the response.

 I will raise the 8K capacity in the buffer, just in case that is the
 problem. That would explain why this problem appears to be randomic. If
 just some pages are too big, that would make the buffer to be full, and then
 everything in the sequence you described would happen.
 
 I don't explicitly disable the session creation in my JSPs, so that is not
 the problem. I don't call any flushing method either.

You need to explicitly disable session generation in your error JSP.
That will ensure the sequence never happens.

 It is clear that something goes wrong in my ProductsForModel.jps page
 (actually, in the java code generated for it), so an Exception is being
 thrown and  PageContextImpl.handlePageException() takes care of it. But
 what exception? Is it the  java.lang.IllegalStateException: Cannot create a
 session after the response has been committed? Or is it another one?

Yep, the broken error JSP is hiding the exception. Another option is to
remove the error handling JSPs.

Mark



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



RE: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-23 Thread Maximilian Stocker
Rather than chasing it at the view end why don't you just call getSession in 
the controller or a filter? Then you have no need of doing anything with any 
buffers  etc.

As to what exception is happening it's the illegal state. Whatever has happened 
up to that point of the processing has flushed the HTTP headers. At that point 
attempting to create a new session is illegal and throws an exception.

-Original Message-
From: Brian [mailto:bbprefix-m...@yahoo.com]
Sent: Thursday, September 23, 2010 3:02 PM
To: 'Tomcat Users List'
Subject: RE: In org.apache.catalina.connector.Request.doGetSession, 
java.lang.IllegalStateException: Cannot create a session after the response has 
been committed

Wow. This is what I call Premium Support! I was thinking about writing en
email to you, Mark, since I was studying the Tomcat source code and saw your
name there. But thought it would be too direct to write to you. I'm honored
to receive your response, really  :-)

Thanks for the commited explanation, but I still have a doubt: Where in my
code do I commit? I don't do it explicitly, so it is happening at some point
automatically but I don't know exactly where/when. If a full buffer is not
the cause, what is it for the commit to happen? In which method/class does
it happen?

I will raise the 8K capacity in the buffer, just in case that is the
problem. That would explain why this problem appears to be randomic. If
just some pages are too big, that would make the buffer to be full, and then
everything in the sequence you described would happen.

I don't explicitly disable the session creation in my JSPs, so that is not
the problem. I don't call any flushing method either.

I still have another doubt: According to your sequence, in step 2 my page is
commited (Maybe because of a full buffer, maybe any other reason I don't
imagine). OK. But in step 3 (something goes wrong), I guess you are
talking about these two lines in my log:

at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:791) - This takes care of that
at
org.apache.jsp.WEB_002dINF.pages.ProductsForModel_jsp._jspService(ProductsFo
rModel_jsp.java:1137) Here something goes wrong, and an Exception
is being thrown

It is clear that something goes wrong in my ProductsForModel.jps page
(actually, in the java code generated for it), so an Exception is being
thrown and  PageContextImpl.handlePageException() takes care of it. But
what exception? Is it the  java.lang.IllegalStateException: Cannot create a
session after the response has been committed? Or is it another one? I
guess it is another one, and that the cannot create... exception is being
thrown after that, when executing the service method in the java code that
correspoonds to the JSP error page to which I redirect. But how can I know
what exception raised in my ProductsForModel.jps page? It seems that since
the code in the JSP error page didnt work (because of its own exception), it
didn't do its job: to explain what went wrong in the ProductsForModel.jps
page.

Thanks a lot!



 -Original Message-
 From: Mark Thomas [mailto:ma...@apache.org]
 Sent: Thursday, September 23, 2010 01:11 PM
 To: Tomcat Users List
 Subject: Re: In org.apache.catalina.connector.Request.doGetSession,
 java.lang.IllegalStateException: Cannot create a session after the
response
 has been committed

 On 23/09/2010 07:42, Brian wrote:
  What does response has been commited mean? I have a theory: Maybe it
  means that in the java code that the container generated for my JSP,
  at least one out.write() method has already been used, which means
  that It already has started to send html code to the browser. Am I
right?
  Again, this is a sporadic issue, which drives me crazy!

 committed means that the HTTP headers have been written to the client
 and no further headers can be sent (note: creating a session requires
sending
 a cookie header to the client - this will be important in a bit). Output
is
 buffered (I think 8k by default - might be 4k) by default so you can still
add
 headers even after some content has been written.

 JSPs create sessions by default unless you explicitly disable this.

 I suspect the sequence is:
 1. Your page starts processing
 2. The page is committed (either it calls flush or the output fills the
buffer so
 it has to flush) 3. Something goes wrong 4. Redirect to error JSP 5. Error
JSP
 tries to create a session 6. Response has been committed so session can't
be
 created 7. You get the error you are seeing

 If step 3 occurs before step 2 then everything will work as the response
won't
 have been committed.

 Mark



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


-
To unsubscribe, e-mail: users-unsubscr

RE: In org.apache.catalina.connector.Request.doGetSession, java.lang.IllegalStateException: Cannot create a session after the response has been committed

2010-09-23 Thread Brian
 On 23/09/2010 12:01, Brian wrote:
  Thanks for the commited explanation, but I still have a doubt: Where
  in my code do I commit? I don't do it explicitly, so it is happening
  at some point automatically but I don't know exactly where/when. If a
  full buffer is not the cause, what is it for the commit to happen? In
  which method/class does it happen?
 
 As soon as the buffer is full or you flush the response.


OK, thanks. I will increase the buffer to 16k, maybe then to 32K, and so on
until I see that the problem is gone.

 
  I will raise the 8K capacity in the buffer, just in case that is the
  problem. That would explain why this problem appears to be randomic.
  If just some pages are too big, that would make the buffer to be full,
  and then everything in the sequence you described would happen.
 
  I don't explicitly disable the session creation in my JSPs, so that is
  not the problem. I don't call any flushing method either.
 
 You need to explicitly disable session generation in your error JSP.
 That will ensure the sequence never happens.


Now that is an very interesting idea! I didn't think of that (as if I
thought about everything else, he he).
I will add a directive so that error page won't use sessions. Then I will
compare the container-generated java code to the one using sessions, to see
what am I missing. I guess I'm not missing anything, unless I use the
session in my code in that page.


  It is clear that something goes wrong in my ProductsForModel.jps
  page (actually, in the java code generated for it), so an Exception is
  being thrown and  PageContextImpl.handlePageException() takes care
  of it. But what exception? Is it the 
  java.lang.IllegalStateException: Cannot create a session after the
response
 has been committed? Or is it another one?
 
 Yep, the broken error JSP is hiding the exception. Another option is to
remove
 the error handling JSPs.

 
But If I remove the JSP than handles the errors (I mean, if I take out the
directive that declares that page in the other pages), how will I know if
something goes wrong in my pages? Correct me if I'm wrong, but I think that
only the user will see the error in his browser, but the log will not be
populated with the information of what went wrong.




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