aspose file tools*
The moose likes Struts and the fly likes Struts2 Reponse already committed errors in was6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Reponse already committed errors in was6" Watch "Struts2 Reponse already committed errors in was6" New topic
Author

Struts2 Reponse already committed errors in was6

Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
I am trying sample application using struts2. I am facing following problems.
I think struts2 framework is not able to forward response back to browser properly.
I am getting below errors.
[3/5/10 13:27:26:605 EST] 00000025 SRTServletRes W WARNING: Cannot set status. Response already committed.
[3/5/10 13:27:26:605 EST] 00000025 SRTServletRes W WARNING: Cannot set header. Response already committed.



struts-config.xml


struts.properties:




When I Launch the application using url "https://localhost:9443/ADCApp/showUpload" I am getting response already committed errors. I am not doing anything in my action class. Somehow struts2 framework is trying to update response after it is written/sent to the browser. I can see SOP being printed on the console and then the errors.

Can you please help me?
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Can you please use Code tags around the various source/configuration file excerpts? It's really hard to read without them. You can go back to your post and edit it using the Edit button.

I started with Struts 2 (not Struts 1), but struts-config.xml is a struts 1 file as far as I know. In Struts 2, it uses struts.xml. Perhaps the framework will use the old file if it doesn't find the new one? I would try changing the name of the file and see if that helps.
Otherwise, from my limited experience, I couldn't see anything wrong.
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Sorry I have formatted it..

I have initially given struts.xml and same results..
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
You have your showUpload action just passing control to /input.jsp, but we don't see what that looks like. Are you getting that page? I assume it must have some form on it with a submit button which directs the application to the processExcel action?

If this JSP page is not being displayed, then how are you seeing the System.out.println() in the ProcessExcel action class? I don't see how the application could ever get there based on the URL you said you were using.

I don't know if you can use a file named struts-config.xml in Struts 2, but I know you can use a file named struts.xml. I would change it.

In your struts-config.xml file, you're creating a result-type for "dispatcher", but this is the same as that provided by the struts-default package, which your package extends, making your entry unnecessary (FYI).

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It looks like you're using an older version of Struts 2. You may be seeing the WAS filter compatibility issue; there's a WebFear setting for it, but I don't recall what it is. Searching the web will probably turn up some hits. I don't recall which versions of WebFear are affected or have the switch option.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
That's a good question. What version of Struts 2 are you using? I assumed that since you were just learning, you would have downloaded the latest version (2.1.8.1, I think).
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
I am using struts 2.0.11 as that is the version approved and available in our company enterprise maven repository. I will try with Latest version and see if it resolves the issue.

I have renamed struts-config.xml to struts.xml and got same error.

Initially I did not had showUpload action. I had input.jsp as my welcome page which had a submit button. Clicking on it will call processExcel Action. I can get to the input.jsp fine and onsubmit it is going to processExcel action where when after control is returned from action is it is failing. I wanted to see if I can get input.jsp from an action. That is when I added showUpload action and tried to call it directory. Which again failed with same errors. That is when I felt I am missing some configuration but could not figure out what.

I will try to do more research on webfear setting and see if it fixes it.

Thanks for all the help.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Well, all your ProcessExcelAction does is return Action.SUCCESS ("success"), so I suspect there is something else going on here. Can you create a simple test action and see if you can get that to work? If you can, then start adding pieces in until you find the piece that's causing the problem.

Have you modified the list of interceptors? Perhaps one is misbehaving?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why are you declaring an actionPackages? Why are you re-declaring the dispatcher result?
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Thanks a lot Mark. I will try these options on monday and post you how it goes.

1. Get latest version of struts

2. Try to troubleshoot with testcases

3. Updated WAS Settings to these:
-> Web Container Settings -> Web Container -> Custom Properties
- select New and then enter "com.ibm.ws.webcontainer.invokefilterscompatibility" as the property name and "true" as the value
- save the update and restart the server

Thanks for all the help.
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
I was thinking I am missing something. I thought may be declaring them will help framework to solve the issue. I had same problem with declaring them and without declaring them. I was doing trail and error..
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Saritha ventrapragada wrote:I was thinking I am missing something. I thought may be declaring them will help framework to solve the issue. I had same problem with declaring them and without declaring them. I was doing trail and error..


The result type of dispatcher is the same that is provided by the "struts-default" package, which your package extends, so declaring it in your package also is not needed (I think I said this already) - you should just remove it.

The actionPackage attribute is to tell the framework which Java packages it should inspect for Java annotations. Are you using any Java annotations to describe your struts 2 architecture? If not, then you don't need this - remove it.

Note: Having things in your configuration which you don't need may cause confusion on the part of those that are trying to understand what you're doing, as the assumption will be they are there for a reason. This will make it harder for you to get help - even if these aren't causing any structural harm to the application itself, I would remove them.

Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
I have tried to use latest version (without using maven) and was able to run the app successfully (but was still getting response already committed errors). I was able to submit the form and look at the results.

I am not seeing any exceptions except for these even with 2.18.. Am I missing any jars?


Jars that I have in my class path:
commons-io-1.4.jar
commons-logging-1.0.4.jar
freemarker-2.3.15.jar
log4j-1.2.14.jar
ognl-2.7.3.jar
struts2-core-2.1.8.1.jar
xwork-core-2.1.6.jar


Anyhelp will be greatly appreciated.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Are you sure that's the correct version of commons-io? That's not the version that come with Struts 2.1.8.1 (which is version 1.3.2) and I seem to recall there being a warning some place which said to make sure you get the correct version (although, I can't remember if that warning was about this Jar).

Did you try creating a simple test case to see if you get the same result there? It may be worth a shot.
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Sorry copy paste error.. Version is commons-io-1.3.2.jar. I am still seeing response already committed errors.

I did write testcase and test case was successful. I will get right result back. I did not explore more on how to invoke struts framework after control is returned from action class.
Any suggestions will definitely help.

Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
From the application parts you've shared with us, I can't see anything wrong.
Perhaps someone else can?

Sorry.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm surprised it even starts up without commons-fileupload, unless they recently removed that dependency.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 Reponse already committed errors in was6