0

I'm running an webapp in glassfish with Struts 2. My web.xml file have the following filters:

StrutsPrepareFilter, SiteMeshFilter, StrutsExecuteFilter

it works fine.

The problem is that I have a to do a file upload. For some reason it works on Tomcat, but on GlassFish the file comes null in the action.

If I change the filters to:

ActionContextCleanUp, SiteMeshFilter, FilterDispatcher

it works. The fact is that ActionContextCleanUp and FilterDispatcher are deprecated.

So I have 2 questions: Does anyone knows what is the issue with the glassfish file upload?

I'm trying to debug the filters to see where the file is being lost, but I don't know where in the filters are the parameters. The filter recieve a httpservletrequest with no parameter, even on tomcat.

Where are the submited parameters on filters?

I created a test project where the same problem is happening. The file is uploaded to the temporary folder then lost.

Here is the web.xml:

    <welcome-file-list>
        <welcome-file>upload.jsp</welcome-file>
    </welcome-file-list>

    <filter>
        <filter-name>exec</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>exec</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

The same happen if I use prepare and execute filters separately.

Matheus
  • 281
  • 2
  • 5
  • Post your web.xml so we can see what is involved exactly. I've used struts2 file upload numerous times on Glass fish without issue, so it is certainly a matter of your particular configuration. – Quaternion Dec 22 '12 at 01:09
  • try this filter http://struts.apache.org/2.3.7/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.html – MohanaRao SV Dec 23 '12 at 17:05

2 Answers2

0

Problem solved. There was an issue with glassfish permissions on linux. I had used eclipse plugin to install glassfish. By installing glassfish manually as root and then adding the server in eclipse solved the problem.

Matheus
  • 281
  • 2
  • 5
0

Well, it was a way back then, but i ran into the same problem and the permission didn't solved this time. So while searching about this I finally found the true solution.

The problem is in Glassfish v3, the web-core.jar must be replaced. The correct jar and more info can be found here.

Matheus
  • 281
  • 2
  • 5