wood burning stoves 2.0*
The moose likes JSF and the fly likes javax.servlet.ServletException:Index:0, Size:0 at javax.faces.webapp.FacesServlet error on first pag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "javax.servlet.ServletException:Index:0, Size:0 at javax.faces.webapp.FacesServlet error on first pag" Watch "javax.servlet.ServletException:Index:0, Size:0 at javax.faces.webapp.FacesServlet error on first pag" New topic
Author

javax.servlet.ServletException:Index:0, Size:0 at javax.faces.webapp.FacesServlet error on first pag

Rafal Rowinski
Greenhorn

Joined: Mar 19, 2012
Posts: 7
This error appears on the first page of my application. There are no drop down lists or other elements that require Arrays. On that page i have two <h:inputText> and one <h:commandButton>. I dont know what is causing the error. Here is the full stack trace

javax.servlet.ServletException: Index: 0, Size: 0
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:422)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at filtry.odsylaczFilter.doFilter(odsylaczFilter.java:64)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:571)
at java.util.ArrayList.get(ArrayList.java:349)
at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1560)
at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:276)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1589)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:263)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:452)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
... 19 more

Pierwotna przyczyna

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:571)
at java.util.ArrayList.get(ArrayList.java:349)
at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1560)
at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:276)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1589)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:263)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:452)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at filtry.odsylaczFilter.doFilter(odsylaczFilter.java:64)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

Welcome to the JavaRanch, Rafal!

This kind of problem is very hard to solve and I usually end up having to put in a breakpoint and rummage around in the execution stack frames before I can find out what went wrong. Something similar to this problem comes up when there are problems with selectOneMenu controls and their selectItem lists/arrays.

The first thing to do is to check the JSF state-saving settings in your web.xml file. Since the failure came while attempting to restore a View, it's possible that you mis-configured something.


Customer surveys are for companies who didn't pay proper attention to begin with.
Rafal Rowinski
Greenhorn

Joined: Mar 19, 2012
Posts: 7
The problem is that this error appears randomly with no particular reason. I threw out filters and I hope everything is going to be fine now.

This is my web.xml file:



Thank you for your help

EDIT: code tag
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

Ouch!

If you use the Code tags (there's a button on your message editor), it will keep the message editor from making a mess of your XML. It's a lot easier on the eyes.

I think that the problem may be because you're attempting to catch a ViewExpiredException from an xhtml (JSF) page.

Most destinations that you declare in web.xml cannot be JSF pages - things like the login/loginfail, welcome page, error pages and so forth. That's because they get processed directly by the webapp server and aren't routed to the FacesServlet, so the required FacesContext isn't there when it's needed. Struts has the same problem, as does any web framework that works by routing URLs through as dispatching servlet.
Rafal Rowinski
Greenhorn

Joined: Mar 19, 2012
Posts: 7
Tim Holloway wrote:Ouch!

If you use the Code tags (there's a button on your message editor), it will keep the message editor from making a mess of your XML. It's a lot easier on the eyes.

I think that the problem may be because you're attempting to catch a ViewExpiredException from an xhtml (JSF) page.

Most destinations that you declare in web.xml cannot be JSF pages - things like the login/loginfail, welcome page, error pages and so forth. That's because they get processed directly by the webapp server and aren't routed to the FacesServlet, so the required FacesContext isn't there when it's needed. Struts has the same problem, as does any web framework that works by routing URLs through as dispatching servlet.


Thank you wery much for your response. It explains alot to me.



This page has a picture and a button leading to login page. Do you suggest to change it to plain xhtml page?




This one is a custom error page that provides a function to email a report to me. Sometimes I get a standard tomcat error page instead of the one I made.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

One thing that can be confusing is the difference between ".xhtml" files and "xhtml" files.

The ".xhtml" extension by convention is used for resources written in JSF Facelets (JSF2) View Definition language. VDL is an xml format. Ideally it should consist entirely of JSF2 tags, but this is rarely completely true. Even purists like myself have been known to slip in a little raw HTML, and a lot of people show no restraint whatsoever. So technically, JSF ".xhtml" files really aren't xhtml.

In contrast, xthml resources are HTML resources that conform the the xhtml standard. These resources should properly have an ".html" extension - their conformance to the xhtml standard is indicated by their embedded DOCTYPE, not by the file extension.

Just to muddy the waters, there's the critical difference between URL paths and resource paths, which isn't made any easier by the fact that both types of paths look almost identical, despite having radically different properties. And that the web.xml usually works with resource paths, but clients work exclusively with URL paths.

So, in short, what I really recommend is that you direct errors to either a plain HTML page (xhtml format is OK) or to a plain JSP.

If you're interested, BTW google and you'll find some resources on how to handle ViewExpiredExceptions more cleanly. I do think that JSF itself deserves more improvement in this area - especially when the view is an AJAX view request - but at least people have found solutions that more or less work in the mean time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.servlet.ServletException:Index:0, Size:0 at javax.faces.webapp.FacesServlet error on first pag
 
Similar Threads
JSF Exception
Strange NullPointerException
Hibernate Validation not working.. default provider not available
TransientObjectException of hibernate
Weird exception when running 2 apps on Tomcat behind Apache