2 Replies Latest reply on Jan 31, 2006 8:12 PM by takahashi

    ArrayList -  java.lang.ArrayIndexOutOfBoundsException

    takahashi

      Hi again...

      I posted error about String[][] a couple of weeks ago, and thank you for processing about this issue.

      This time I am trying to send/receive the ueser defined class with ArrayList variable, and getting the following error:


      12:03:21,093 ERROR [BeanPropertyTarget] Could not convert [Ltest.webservice.Subject; to bean field 'subjectArrayList[0]', type [Ltest.webservice.Subject;
      12:03:21,093 ERROR [RPCInvocation] java.lang.ArrayIndexOutOfBoundsException
      java.lang.ArrayIndexOutOfBoundsException
      at org.jboss.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:243)
      at org.jboss.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:305)
      at org.jboss.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:590)
      at org.jboss.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1249)
      at org.jboss.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:252)
      at org.jboss.axis.message.SOAPElementAxisImpl.publishToHandler(SOAPElementAxisImpl.java:1386)
      at org.jboss.axis.message.RPCElement.deserialize(RPCElement.java:262)
      at org.jboss.axis.message.RPCElement.getParams(RPCElement.java:396)
      at org.jboss.axis.providers.java.RPCInvocation.prepareFromRequestEnvelope(RPCInvocation.java:235)
      at org.jboss.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:103)
      at org.jboss.axis.providers.java.JavaProvider.invoke(JavaProvider.java:358)
      at org.jboss.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
      at org.jboss.axis.SimpleChain.doVisiting(SimpleChain.java:160)
      at org.jboss.axis.SimpleChain.invoke(SimpleChain.java:123)
      at org.jboss.axis.handlers.soap.SOAPService.invoke(SOAPService.java:560)
      at org.jboss.webservice.server.ServerEngine.invokeInternal(ServerEngine.java:200)
      at org.jboss.webservice.server.ServerEngine.invoke(ServerEngine.java:89)
      at org.jboss.axis.transport.http.AxisServlet.doPost(AxisServlet.java:905)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.jboss.axis.transport.http.AxisServletBase.service(AxisServletBase.java:370)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:534)


      My JSE is:
      public interface StudentJSE extends Remote{
       Student updateStudent(Student target) throws RemoteException;
       StudentArrayList updateStudentArrayList(StudentArrayList targetList) throws RemoteException;
      
      }
      


      Student class is:
      public class Student implements Serializable {
       Subject[] subjectList;
       String name;
       :
       appropriate setters and getters
      }
      


      StudentArrayList class is:
      public class StudentArrayList implements Serializable {
       List subjecArraytList = new ArrayList();
       String name;
      
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       public Subject[] getSubjectArrayList() {
       return(Subject[])this.subjecArraytList.toArray(new Subject[this.subjecArraytList.size()]);
       }
      
       public void setSubjectArrayList(Subject[] subjecArraytList) {
       this.subjecArraytList.clear();
       for(int j=0; j>subjecArraytList.length; j++) {
       this.subjecArraytList.add(subjecArraytList[j]);
       }
       }
      
      }
      
      


      It works fine with Student class. I can get the expected result through
      UpdateStudent method.
      BUT not StudentArrayList class.... UpdateStudentArrayList method terminated with the ArrayIndexOutOfBoundsException.

      I found the bug about ArrayList which is JBWS-383(JBoss doesn't properly
      support JavaBeans with array-type properties).
      Is this bug caused the error I encountered??

      How to solve this problem?
      I will be appreciated any help!!

      -Mie

        • 1. Re: ArrayList -  java.lang.ArrayIndexOutOfBoundsException
          thomas.diesler

          Collections are not supported in JAXRPC. You should use arrays.

          • 2. Re: ArrayList -  java.lang.ArrayIndexOutOfBoundsException
            takahashi

            Hi Thomas,

            Thank you for your reply.

            I tried the same web-service on AXIS, it woked OK.
            I thought it worked fine with the bean class which has
            setters( parameter:array) and getters(return type: array)
            even if its property is ArrayList(collection type).
            I understand it won't work if I use setters(parameter: ArrayList)
            and getters(return type: ArrayList)....

            In my case, I have the following bean class property:


            List subjecArraytList = new ArrayList();


            And, I have these setter and getter:

            public Subject[] getSubjectArrayList() {
            return(Subject[])this.subjecArraytList.toArray(new Subject[this.subjecArraytList.size()]);
            }

            public void setSubjectArrayList(Subject[] subjecArraytList) {
            this.subjecArraytList.clear();
            for(int j=0; j>subjecArraytList.length; j++) {
            this.subjecArraytList.add(subjecArraytList[j]);
            }
            }


            The only way I can run this service on JBoss is to change ArrayList to Arrays???

            I found the following sun tutorial site:

            http://doc.albanet.ro/java/j2eetutorial14/doc/JAXRPC2.html#wp82023

            It says "This release of JAX-RPC also supports several implementation classes of the java.util.Collection interface".
            It includes ArrayList as well.

            Any advise is greatly appreciated!

            -Mie