0

While running the project/code that creates a XSSFWorkbook, the system is failing with no class definition found error for org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFileRecoveryPr

I have all the poi 3.9 jars and its pre-requisites jar too.

Interesting stuff is that, the same project/code is running fine on my friend's system.

The project is a JSF 1.2 project built on RAD.

Can it be related to the MS office installation suite on my system? Also why is the class being called during workbook creation time, could not find any documentation anywhere.

Please help to resolve the issue as I am unable to proceed ahead on testing of the project.

Vikram
  • 21
  • 6

1 Answers1

0

From the Apache POI FAQ entry on "I'm using the poi-ooxml-schemas jar, but my code is failing with "java.lang.NoClassDefFoundError: org/openxmlformats/schemas/something":

To use the new OOXML file formats, POI requires a jar containing the file format XSDs, as compiled by XMLBeans. These XSDs, once compiled into Java classes, live in the org.openxmlformats.schemas namespace.

There are two jar files available, as described in the components overview section. The full jar of all of the schemas is ooxml-schemas-1.1.jar, and it is currently around 15mb. The smaller poi-ooxml-schemas jar is only about 4mb. This latter jar file only contains the typically used parts though.

Many users choose to use the smaller poi-ooxml-schemas jar to save space. However, the poi-ooxml-schemas jar only contains the XSDs and classes that are typically used, as identified by the unit tests. Every so often, you may try to use part of the file format which isn't included in the minimal poi-ooxml-schemas jar. In this case, you should switch to the full ooxml-schemas-1.1.jar. Longer term, you may also wish to submit a new unit test which uses the extra parts of the XSDs, so that a future poi-ooxml-schemas jar will include them.

So, short term, you just need to switch from the poi-ooxml-schemas jar to the larger (and complete) ooxml-schemas jar. Longer term, you need to submit a junit test to the Apache POI project which uses your desired CT class, and that class will then be automatically included in the smaller poi-ooxml-schemas jar in a future release.

Gagravarr
  • 47,320
  • 10
  • 111
  • 156
  • In the whole project we are not using that particular class. Also as described the same excel workbook creation is working on my friend's system. So there is no unit test case for the usage of that class in whatever we have built. Nor we know why on my system only that error is coming. – Vikram Apr 03 '14 at 04:25
  • Switch to the full `ooxml-schemas-1.1` jar and it'll work. I can only suspect the difference between machines is either a different file (different excel files can need different bits of the schema), or a different classpath (you're not running the jars you think you are) – Gagravarr Apr 03 '14 at 09:28
  • This project was created on my friends machine. I imported the project from his system, so I feel all jars and setting are same. I have cross verified several time. To re-test the setting, I changed from XSSF to HSSF and it worked fine for me. Currently I have gone ahead using ooxml-schemas 1.1 jar. I had to review the code and change few formats. I have done and exported the code on his system back. Now the changed code works on his system with using poi-ooxml-schemal 3.9 jar only. @Gagravarr – Vikram Apr 19 '14 at 06:51
  • I am still unable to decipher through multiple hit and trial,that why the two machines are behaving differently. @Gagravarr – Vikram Apr 19 '14 at 06:53
  • Is it only some files that show the problem? (Different files can use different bits of the file format). Are you *absolutely certain* that you're using the jars on your classpath that you think you are? Are both machines using the same JVM/JDK? – Gagravarr Apr 19 '14 at 12:18
  • The JDK version are different – Vikram Jun 23 '14 at 17:18