Warning: Undefined array key "birthday_search" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 173

Warning: Undefined array key "joindate" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 190

Warning: Undefined array key "posts" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 191

Warning: Undefined array key "posts" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 197

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 6509

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 212

Warning: Undefined array key "privacy_options" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 251

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 4998

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 1585

Warning: Undefined array key "lastactivity" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 1601

Warning: Trying to access array offset on value of type bool in /home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb5/route/profile.php on line 74
Error "Java exception received when calling Java method" when calling HELLOEXCEL - MC Press Online Forums

Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Error "Java exception received when calling Java method" when calling HELLOEXCEL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error "Java exception received when calling Java method" when calling HELLOEXCEL

    Tom,

    Thanks for the lovely book with the nice explanations. I am on V5R4M0 and I've POI HSSF version 3.0.2 (poi-3.0.2-FINAL-20080204.jar) downloaded and I this following bit of code:

    D workbook s LIKE(HSSFWorkbook)
    D sheet s LIKE(HSSFSheet)
    D row S LIKE(HSSFRow)
    D cell S LIKE(HSSFCell)
    *
    /Free
    JavaServiceProgram();
    JNIEnv_P = getJNIEnv();
    workbook = new_HSSFWorkbook();
    sheet = AirExcel_getSheet(workbook:'Report');
    row = AirExcel_getRow(sheet:0);
    cell = AirExcel_getCell(row:0);
    AirExcel_setCellValueString(cell:'Hello World');
    //*** Close the Spreadsheet and Reclaim Resources
    AirExcel_write(workbook:'/Adhoc Reports/Test_excel.xls');

    ....

    But the call to HELLOEXCEL is falling over at line AirExcel_setCellValueString(cell:'HELLO WORLD'). I am getting this in my Job Log:

    Additional Message Information

    Message ID . . . . . . : RNX0301 Severity . . . . . . . : 50
    Message type . . . . . : Escape
    Date sent . . . . . . : 11/10/10 Time sent . . . . . . : 10:09:21

    Message . . . . : Java exception received when calling Java method.
    Cause . . . . . : RPG procedure AIREXCEL_S in program VENLIB/SVAIREXCEL
    received Java exception "java.lang.NoSuchMethodError: setCellValue" when
    calling method "setCellValue" with signature
    "(Lorg.apache.poi.hssf.usermodel.HSSFRichTextStringV" in class
    "org.apache.poi.hssf.usermodel.HSSFCell".
    Recovery . . . : Contact the person responsible for program maintenance to
    determine the cause of the problem.
    Technical description . . . . . . . . : If the exception indicates that the
    Java class was not found, ensure the class for the method is in the class


    When I replace the code with AirExcel_setCellValueNumeric(cell:1234) the code works and I able to see a Excel file created with cell0,0 having a value of 1234.

    Am I sure why the setCellValueString along is giving the NoSuchMethod error? I checked the Java docs and I see this definition for the setCellValue overridden for a RichString definition:

    public void setCellValue(RichTextString value)Set a string value for the cell.

    Specified by:
    setCellValue in interface Cell
    Parameters:
    value - value to set the cell to. For formulas we'll set the formula string, for String cells we'll set its value. For other types we will change the cell to a string cell and set its value. If value is null then we will change the cell to a Blank cell.

  • #2
    Tom,

    I don't know if this will help you get more information. When I tried to see the contents of HSSFCell class I am not able to see a setCellValue method overriden to to a HSSFRichTextString object. Does this mean that I need to use the HSSFString object? I've placed the POI jar file in a IFS folder called '/Adhoc Reports/jar' and I setting this folder in my CLASSPATGH.


    Compiled from "HSSFCell.java"
    public class org.apache.poi.hssf.usermodel.HSSFCell extends java.lang.Object{
    public static final int CELL_TYPE_NUMERIC;
    public static final int CELL_TYPE_STRING;
    public static final int CELL_TYPE_FORMULA;
    public static final int CELL_TYPE_BLANK;
    public static final int CELL_TYPE_BOOLEAN;
    public static final int CELL_TYPE_ERROR;
    public static final short ENCODING_COMPRESSED_UNICODE;
    public static final short ENCODING_UTF_16;
    protected org.apache.poi.hssf.usermodel.HSSFCell(org.apache. poi.hssf.model.Workbook,org.apache.poi.hssf.model. Sheet,int,short);
    protected org.apache.poi.hssf.usermodel.HSSFCell(org.apache. poi.hssf.model.Workbook,org.apache.poi.hssf.model. Sheet,int,short,int);
    protected org.apache.poi.hssf.usermodel.HSSFCell(org.apache. poi.hssf.model.Workbook,org.apache.poi.hssf.model. Sheet,int,org.apache.poi.hssf.record.CellValueReco rdInterface);
    public void setCellNum(short);
    public short getCellNum();
    public void setCellType(int);
    public int getCellType();
    public void setCellValue(double);
    public void setCellValue(java.util.Date);
    public void setCellValue(java.util.Calendar);
    public void setCellValue(java.lang.String);
    public void setCellFormula(java.lang.String);
    public java.lang.String getCellFormula();
    public double getNumericCellValue();
    public java.util.Date getDateCellValue();
    public java.lang.String getStringCellValue();
    public void setCellValue(boolean);
    public void setCellErrorValue(byte);
    public boolean getBooleanCellValue();
    public byte getErrorCellValue();
    public void setCellStyle(org.apache.poi.hssf.usermodel.HSSFCel lStyle);
    public org.apache.poi.hssf.usermodel.HSSFCellStyle getCellStyle();
    public short getEncoding();
    public void setEncoding(short);
    protected org.apache.poi.hssf.record.CellValueRecordInterfac e getCellValueRecord();
    public void setAsActiveCell();
    }

    Comment


    • #3
      Tom,

      I finally got the code to work. I created a method for AirExcel_setCellValueString and passed a string object to it after having copied the original AirExcel_setCellValueString as AirExcel_setcellValueRichString.

      I am not sure why the POI version I have doesnot have setCellValue(RichString)? Seems to have only the public void setCellValue(java.lang.String) method?

      Now finally my HelloExcel code is working ... Good learning ...

      Comment


      • #4
        I was just going to say that Congrats! You're right, it is good learning.

        Comment


        • #5
          Tom,

          Thanks for the response and once again a great book, well written. But I wonder why the setCellValue method overridden to RichTextString is not available in 3.0.2 when in javadocs they say it is supported?

          Regards,
          Venky

          Comment


          • #6
            Thanks Venky, I'm glad you are enjoying the book!

            The online javadocs on the POI website will always represent the latest released version. Because you are using an older version, you need to refer to the JavaDocs associated with it.

            For the current version, it has:
            setCellValue(RichTextString value)

            But for version 3.0.2 it looks as though they were using a custom RichTextString:
            setCellValue(HSSFRichTextString value)

            When you downloaded your poi-bin-3.0.2-FINAL-20080204.zip file, you probably extracted it to get your jar file. When that extracts, it also has a docs folder that contains the JavaDocs for that version.

            Have a great day! And have fun with your coding!
            Tom

            Comment


            • #7
              Tom,

              What puzzles me is the fact the the JAR file doesnot have a method overridden either to RichTextString not HSSFRichTextString. It seems to only have these methods available?

              public void setCellValue(double);
              public void setCellValue(java.util.Date);
              public void setCellValue(java.util.Calendar);
              public void setCellValue(java.lang.String);


              I mean it took me some time to find out what methods are available in a CLASS in a JAR file. Used this command from QSHELL -->
              javap -classpath '/Adhoc Reports/jar/poi-3.0.2-FINAL-20080204.jar' org.apache.poi.hssf.usermodel.HSSFCell > 'Adhoc Reports/SIR0042429.txt'
              Regards,
              Venky

              Comment


              • #8
                Hi Venky,

                I just executed the disassembler on my jar file and I see the HSSFRichTextString object parameter as an option for setCellValue.

                Maybe I'm not understanding the question. Are you saying that you're not seeing the HSSFRichTextString parameter option, or are you asking why the developers of POI did not include the RichTextString option with that Version of POI?
                Attached Files
                Last edited by Guest; 10-12-2010, 09:56 AM.

                Comment


                • #9
                  I don't know if you could attach the jar file that you're using to this forum or not. I see that you sent me an email, perhaps you could send it to me in an email and I'll look at it. If you are using version 3.0.2, you should have the HSSFRichTextString option. If for some reason it does not, you could try downloading it from the POI Archives.

                  Grab the poi-bin-3.0.2-FINAL-20080204.zip file and unpack it to get the jar file and try it again.

                  I hope this is what you are looking for. If not, let me know,
                  Tom

                  Comment


                  • #10
                    Tom,

                    What I meant was that when I tried to look at the contents of the jar file I was not able to locate a setCellValue method expecting a HSSFRichTextString value as a parameter. That's the reason why the RPG was falling over on the call to AirExce_setCellValueString.

                    That's when I tried to look at what methods are available in the HSSFCell Java class to me. This is is what I saw:

                    public void setCellValue(double);
                    public void setCellValue(java.util.Date);
                    public void setCellValue(java.util.Calendar);
                    public void setCellValue(java.lang.String);

                    Am I correct to say that the code samples provided in the book is written with POI 3.0.2 and if I had got the correct JAR I shouldn't have to make a change to the samples you've given?

                    Regards,
                    Venky

                    Comment


                    • #11
                      That is correct. If you do not modify the code, and you are using POI 3.0.2, it should work as is.

                      I don't understand why you're not seeing:
                      public void setCellValue(org.apache.poi.hssf.usermodel.HSSFRic hTextString)

                      It leads me to believe that you are using a different jar than what I am looking at. I would recommend downloading the jar again from the archive link I provided above to see if you get this option.

                      Comment

                      Working...
                      X