Bug 49325

Summary: Websphere 6.1: java.lang.NoClassDefFoundError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPhoneticRun
Product: POI Reporter: Ted <teds.mailing.lists>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.6-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: A simple spreadsheet containing three rows and two columns.

Description Ted 2010-05-20 16:21:39 UTC
Created attachment 25468 [details]
A simple spreadsheet containing three rows and two columns.

When attempting to open an .xlsx file running on the Websphere 6.1 JDK, the poi-bin-3.6-20091214 distribution results in the following exception. No exception is generated when running on jre_1.5.0_11.

As a workaround, replacing poi-ooxml-schemas-3.6-20091214.jar with ooxml-schemas-1.0.jar downloaded from http://mirrors.ibiblio.org/pub/mirrors/maven2//org/apache/poi/ooxml-schemas/1.0/ resolved the issue.

It has been suggested by Dave Fisher (per http://article.gmane.org/gmane.comp.jakarta.poi.user/14509) to include the org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPhoneticRun in the poi-ooxml-schemas jar.

Sample .xlsx file is attached.  A sample program follows:


import java.io.File;
import java.io.FileInputStream;

import org.apache.poi.ss.usermodel.WorkbookFactory;

/**
 * Demonstrates a bug using poi-bin-3.6-20091214 with Websphere 6.1 JDK:
 *  java.lang.NoClassDefFoundError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPhoneticRun
 *  
 *  Per Dave Fisher: (http://article.gmane.org/gmane.comp.jakarta.poi.user/14509)
 *    The poi-ooxml-schemas jar is a cut-down version of ooxml-schemas-1.0.jar - the full schemas are about 13 MB.
 *    Replace poi-ooxml-schemas in your classpath with ooxml-schemas-1.0.jar. 
 */
public final class Main {
    static final String XLSX_PATH = "C:/simple.xlsx";
    
    public static void main(String[] args) throws Exception {
        final File xlsx = new File(XLSX_PATH); 
        WorkbookFactory.create(new FileInputStream(xlsx));
        System.out.println("okay!");
    }
}



Exception in thread "main" org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
	at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:61)
	at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:256)
	at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:196)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:172)
	at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:63)
	at Main.main(Main.java:20)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
	at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:59)
	... 5 more
Caused by: java.lang.NoClassDefFoundError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPhoneticRun
	at java.lang.J9VMInternals.verifyImpl(Native Method)
	at java.lang.J9VMInternals.verify(J9VMInternals.java:59)
	at java.lang.J9VMInternals.initialize(J9VMInternals.java:120)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
	at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createUnattachedNode(SchemaTypeImpl.java:1859)
	at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(SchemaTypeImpl.java:1021)
	at org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(XmlObjectBase.java:893)
	at org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1657)
	at org.apache.xmlbeans.impl.store.Xobj.find_all_element_users(Xobj.java:2080)
	at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSstImpl.getSiArray(Unknown Source)
	at org.apache.poi.xssf.model.SharedStringsTable.readFrom(SharedStringsTable.java:113)
	at org.apache.poi.xssf.model.SharedStringsTable.<init>(SharedStringsTable.java:97)
	... 10 more
Comment 1 Yegor Kozlov 2010-05-22 12:16:03 UTC
Fixed in r947312

I included your sample in the POI test suite. It ensures that the build procedure includes needed classes from the full ooxml-schemas.jar.

Yegor