Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Converting Old POI Reading .xls Files to POI 3.7 Issues

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having difficulty moving to the new process. I didn't have to change much using POI 3.7 (just removed the (short) casting) to replace the deprecated with the new methods, like row.getCell(). Yet, on the Busy Developer's Guide to HSSF and XSSF Features (https://coderanch.com/forums/jforum?module=posts&action=insert&forum_id=45 ), it shows the deprecated values.

Anyway, when I upload a 97-2003 format spreadsheet (xls), I am erroring out on the line . It doesn't even hit the catch, just goes straight to an error with the explanation

Caused by: java.lang.NoSuchMethodError: org/apache/poi/hssf/usermodel/HSSFRow.getCell(I)Lorg/apache/poi/hssf/usermodel/HSSFCell;

followed by

javax.servlet.ServletException: org/apache/poi/hssf/usermodel/HSSFRow.getCell(I)Lorg/apache/poi/hssf/usermodel/HSSFCell;

.

The reason I bring this up is because I was converting to use 2007+ .xlsx format spreadsheets and I was getting strange errors uploading those (and this got caught in the try/catch):

Unable to process spreadsheet: Invalid header signature; read 1688935826934608, expected -2226271756974174256

.

When I looked up the error, everything said you had to update to POI 3.5 or later (I have 3.7), so I'm stumped. By both errors, actually. I stripped all formatting just to be certain that there was nothing funny in the spreadsheets that couldn't be handled. Help.


 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(By the way, I did try using XSSF as well - wasn't much better)
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure your code compiles against POI 3.7, and that the same libraries are used for compilation and at runtime. In general, upgrading POI is smooth, but sometimes methods get reorganised between releases.
 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what do you mean

Make sure your code compiles against POI 3.7, and that the same libraries are used for compilation and at runtime.



I pulled in the jars, recompiled my entire application, and made the changes to replace the deprecated methods, and then ran it. I'm no newbie, just looking to find out why I'm having issues.
 
Sheriff
Posts: 24658
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So that takes care of reviewing the compiling environment. Now you've got your runtime environment to review, which appears to be a servlet container of some kind. It's possible that your effective classpath includes two different copies of the POI jar, at least that's one possibility based on the error message. Did you put the POI jar in the container's classpath and in your application's WEB-INF/lib, for example?
 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. Unfortunately, I removed all of the old and put in all of the new. Next?
 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I just realized that sounded snarky. It wasn't. I've checked everything and can't figure out why the new stuff breaks.
 
Paul Clapham
Sheriff
Posts: 24658
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And which jar file is the HSSFRow class being loaded from in the environment where the error occurs?

Hint:
 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
poi-3.7-20101029.jar
and I'm using tomcat 5.5 on eclipse ganymede - no jars except jconn3.jar, tools.jar, and bootstrap.jar are part of the global environment
 
Those are the largest trousers in the world! Especially when next to this ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!