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..
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.