2 Replies Latest reply on Nov 3, 2009 11:43 PM by Damian Harvey

    Seam ArrayStore Exception

    sailaja y Newbie
      Hi All,

      I am getting this Exception. Can any one help me out to solve this problem.

      The following is the stacktrace for Exception.

      java.lang.ArrayStoreException
      Stack Trace
      java.lang.ArrayStoreException
      at java.util.ArrayList.toArray(ArrayList.java:306)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.getCurrentSelectedValues(MenuRenderer.java:633)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:524)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:757)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:811)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
      at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
      at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
      at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
      at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
      at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
      at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
      at org.jboss.seam.ui.renderkit.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:146)
      at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      at java.lang.Thread.run(Thread.java:619)
        • 1. Re: Seam ArrayStore Exception
          Damian Harvey Apprentice

          I have the same problem.


          In my case it is caused by the h:selectManyListbox being passed values that are a mix of concrete instances and Hibernate Proxies (ie. objects that are lazy loaded).


          If I look at them in the debugger my list contains entries like:



          com.locuslive.odyssey.entity.UnLocode
          com.locuslive.odyssey.entity.UnLocode_$$_javassist_124
          




          When the MenuRenderer gets to line 633 (JSF Mojarra 1.2_4) the toArray() method throws the ArrayStoreException


          // get the type of the first element - Should
          // we assume that all elements of the List are
          // the same type?
          return list.toArray((Object[]) Array
                 .newInstance(list.iterator().next().getClass(),
                                 size));
          


          Ironic comment too. Nice.


          My solution is to iterate through my list and ensure that each instance is a concrete one and if it's a proxy then to load it fully (eg. with entityManager.find())


          Cheers,


          Damian.

          • 2. Re: Seam ArrayStore Exception
            Damian Harvey Apprentice

            I take that back.


            My solution wasn't working nor was Hibernate.initialize(). My nasty workaround is to completely override the MenuRenderer and replace that nasty line of code with a simple list.toArray()