Menu

Error in update Action

Help
2009-02-26
2012-12-13
  • Jan van Lit

    Jan van Lit - 2009-02-26

    I am trying to create a 3-tier application as in Demo5.
    I use Java 1.6 and tomcat 6. While testing I run into the problem with the next exception

    java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lorg.openswing.swing.message.receive.java.ValueObject;
            at net.vanlit.system.server.updateUserDetail.executeCommand(Unknown Source)

    this error occurs in the next line in the update Action class
    UserVO oldVO = (UserVO)((ValueObject[])inputPar)[0];

    Anyone have an idea what I am doing wrong?

    public final Response executeCommand(Object inputPar,UserSessionParameters userSessionPars,HttpServletRequest request, HttpServletResponse response,HttpSession userSession,ServletContext context) {
        Connection conn = null;

        try {
            conn = ConnectionManager.getConnection(context);
           
          HashMap map = new HashMap();
          map.put("userid","USR01.UID");
          map.put("passwd","USR01.passwd");
          map.put("email","USR01.email");
          map.put("name","USR01.name");
          map.put("language_id","USR01.language_id");

          HashSet pk = new HashSet();
          pk.add("userid");

          UserVO oldVO = (UserVO)((ValueObject[])inputPar)[0];
          UserVO newVO = (UserVO)((ValueObject[])inputPar)[1];
         
              return QueryUtil.updateTable(
              conn,
              userSessionPars,
              pk,
              (ValueObject)oldVO,
              (ValueObject)newVO,
              "USR01",
              map,
              "Y",
              "N",
              context,
              true
          );
        }

     
    • Jan van Lit

      Jan van Lit - 2009-03-13

      After doing several testing, I currently changed my code from 3-tier to 2-tier, which works at the moment. It is not as I want it, but it works for now.
      I also switched from the form editor jiglo/eclipse to netbeans 6.5, because jiglo did not update properties as it should.
      3rd I added some code generation to the Druid project here on sf.net to create the full VO for me, and added some code to create a table browser/editor with openSwing, which i will publish when it is ready.

       
    • mcarniel

      mcarniel - 2009-03-14

      It seems that the class cast exception depends on the wrong declaration of array: on client-side the array is declared of Object[] type and jvm throws an exception a class cast exception since the code attempts to cast Object[] to ValueObject[].
      You should write:

      UserVO oldVO = (UserVO)((Object[])inputPar)[0];

       

Log in to post a comment.