0

I'm facing the common issue of java.lang.NoClassDefFoundError during application runtime when i try to create and write a workbook using poi 3.2 final version (for .xls files only). I have created this utility as an enterprise application project with ejb and web modules. The workbook creation is triggered through an EJB timer which starts on load of the project to the server.

The run time fails for the class org.apache.poi.hssf.usermodel.HSSFWorkbook. The library references are made as far as i'm aware. I've placed the poi 3.2 final jar in ejb/META-INF/lib/folder. I have also added it from the Order and Export tab of the Build path and referenced in the Java EE dependencies. For good measure, i have placed it in the web-inf/lib folder of the web project also, but to no avail.

In the same app, i am also using the Jsoup jar. After referencing it in the above stated places, Jsoup is working fine.

Curiously enough, this error does not occur when i create the same service as a web application (dynamic web project) with a regular utility timer. The workbook gets created. The jar is placed in the web-inf/lib folder.

Could someone please let me know is there any difference in the way this jar is referenced for a web project and an enterprise project?

Appreciate your patience and help..

8
  • Apache POI 3.2 is over 7 years old now! Why on earth are you using such an ancient version? The list of fixes since then is huge!
    – Gagravarr
    Nov 17, 2015 at 16:26
  • @Gagravarr You are absolutely right. I was initially using 3.13 poi jar (with all the ooxml jars) version which sent me on a different run time load issue. Nov 18, 2015 at 8:58
  • @Gagravarr Even though i am using only the HSSF workbook related imports, on usage of the latest poi jars (anything from 3.5 to 3.13 versions), on run time loading, it looks up for the class org.apache.poi.ss.usermodel.RichtextString. I have verified the jars also, they seem to have this class in them. Just to make it relevant atleast, i tried to use the older version which only loads HSSF packages instead of SS packages. Any ideas? Nov 18, 2015 at 9:01
  • As per the Apache POI FAQ, mixing POI jars from different versions is not supported. Stop doing that! Use only 3.13 jars
    – Gagravarr
    Nov 18, 2015 at 10:20
  • @Gagravarr I am not mixing the jar versions. I meant to say, i tried using from 3.2 to 3.13 jar versions separately. Below is what i was using which lead to the org.apache.poi.ss.usermodel.RichTextString class load error. poi-3.13-20150929.jar,poi-example-3.13-20150929.jar, poi-excelant-3.13-20150929.jar, poi-ooxml-3.13-20150929.jar, poi-ooxml-schemas-3.13-20150929.jar,poi-scratchpad-3.13-20150929.jar Nov 18, 2015 at 13:20

1 Answer 1

0

This worked when i placed the jars in the META-INF/lib folder of the EAR project as opposed to the EJB project, and referenced it in the library dependencies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.