0

Can anyone explain me why I am getting the following exception:

java.lang.ClassCastException: org.apache.struts2.dispatcher.StrutsRequestWrapper cannot be cast to com.evermind[Oracle Containers
    for J2EE 10g (10.1.3.5.0) ].server.http.EvermindHttpServletRequest
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.NotFoundServlet.sendNotFound(NotFoundServlet.java:26
    )
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.NotFoundServlet.service(NotFoundServlet.java:18)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java
    :64)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java
    :15)
    at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)

I get it when I suppose to have NOT_FOUND page and my request url ends on .[some_ext] like .htm, .blah. But when request is without .[some_ext] (like _http:/domain/part1/part2/nosuchurl) then everything is ok and I get normal NOT_FOUND page mapped in the struts config:

<default-action-ref name="nopagefound"/>
<action name="nopagefound">
  <result>/WEB-INF/jsp/errors/notfound.jsp</result>
</action>

I use Struts2(2.3.1.2)+Spring deployed on oc4j 10.1.3.5.0.

Here is my struts mapping:

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

And in Struts.properties

struts.action.extension= ,
user1278890
  • 643
  • 8
  • 22

1 Answers1

0
<filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.action</url-pattern>
</filter-mapping>

If the extension is .action then only pass through the StrutsPrepareAndExecuteFilter then you couldn't get this exception. And for handling 404 error you can override default error page.

MohanaRao SV
  • 1,117
  • 1
  • 8
  • 22
  • Thanks for the answer but that does not help. First of all I do not need any extension, and second - I have this exception for both default and custom 404 page. And furthermore If I map like you suggested I have no exception for non-existent urls which end on `.action` but I do have it for all others. – user1278890 Mar 27 '12 at 09:07
  • As you know if you are not specifying any extension struts will give .action extension. And what are the other extensions you have if they are not actions you do need this filter at all. – MohanaRao SV Mar 27 '12 at 16:12
  • To @Mohana Rao SV. Well as I have said I do not need any extension I just need to show normal 404 PAGE NOT FOUND if user specifies some wrong url. And here comes a problem if this wrong url have no extension I have got the 404 page but when there is some extension (no matter which) I have ClassCastException(500 ERROR PAGE) where 404 page should be. I think maybe it is oc4j bug, because oc4j 10.1.3.5.0 is a little old. – user1278890 Mar 28 '12 at 07:38