Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB example issue Cannot create a session after the response has been committed  RSS feed

 
sai rama krishna
Ranch Hand
Posts: 524
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a EAR enterprise project with EJB and Web module.

EJB module has a SongTokenImpl stateless session bean with @Stateless and @Webservice annotation.

Web module has SongServlet.java and success jsp.

SongServlet has dependency injection to SongTokenImpl.




When I run the EAR project it loaded below web project URL

http://localhost:8080/JulyEnterpriseProjectWeb
I then ran by passing the corresponding parameter as below
http://localhost:8080/JulyEnterpriseProjectWeb/SongServlet?songname=xyz
It supposed to to forward to success.jsp and shoould say

we got song token for song xyz

Instead i see below error.
SongServlet threw exception: java.lang.IllegalStateException: Cannot create a session after the response has been committed

How to fix this issue. Please advise
 
saqib rashids
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting a return after forwarding the request. Refer to the below link for more information, it might help


http://stackoverflow.com/questions/7951331/java-lang-illegalstateexception-cannot-forward-after-response-has-been-committe
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where you get the error in code exactly, and the full error stack trace? That will tell you where you/implicit code tries to do something after the response is committed.
 
sai rama krishna
Ranch Hand
Posts: 524
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added line
return;

after below line
request.getRequestDispatcher("success.jsp").forward(request, response);



I still having the issues.

I added one more system out before return statement



when i restarted server in debug mode and step over i went till
System.out.println("We are at end of doGet method before return stmt");
also to the line. I see songname xyz also getting populated
return;
This example worked fine few days back. Not sure why i am getting these kind of issues now.

I do not see the response not committed error in console any more now.

I see console message as below
we got song token for song xyz
We are at end of doGet method before return stmt
please advise
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I do not see the response not committed error in console any more now.

So the application is working now? I'm confused because your next few sentences seem to indicate you are still running into some problem:

I see console message as below
we got song token for song xyz
We are at end of doGet method before return stmt
please advise

Can you add more details on what problem you are running into now?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!