Hi Lukasz,

thanks for the update. I will take a deeper look on your e-mail to see if we can deal with the POI/XMLBeans guys.

Regards
JB

On 09/05/2013 11:32 AM, Łukasz Dywicki wrote:
Hey guys,
There is main issue with our poi bundle. It does not contain poi-ooxml-schemas 
artifact which contains stuff necessary for docx and office 2007 stuff. I've 
tried to update this bundle to have ooxml-schemas embedded as well, but then 
I've hit another issue which prevented me from reading docx contents. I don't 
know details of xmlbeans (and honestly I won't go into detail), but it uses 
some weird constructions to register generated code in schema registry (below) 
causing errors (at the end). The workaround to make everything working smoothly 
is to embed xmlbeans together with poi. I prepared a new version of poi 3.9 
bundle which wraps xmlbeans 2.3 used by this version of poi. The big question 
is how we can solve this to let our bundle users work with it. There are couple 
of posts about these issues, so do you accept workaround solution? :) I'm not 
sure what's going on with poi and xmlbeans, however maybe some of you can make 
pressure on them as we did with wicket to avoid split packag
es and so on?

package schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707;

import java.lang.reflect.Constructor;
import org.apache.xmlbeans.SchemaTypeSystem;

public class TypeSystemHolder
{
   public static final SchemaTypeSystem typeSystem = loadTypeSystem();

   private static final SchemaTypeSystem loadTypeSystem()
   {
     try
     {
       return 
(SchemaTypeSystem)Class.forName("org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl",
 true, TypeSystemHolder.class.getClassLoader()).getConstructor(new Class[] { Class.class 
}).newInstance(new Object[] { TypeSystemHolder.class });
     }
     catch (ClassNotFoundException localClassNotFoundException)
     {
       throw new RuntimeException("Cannot load 
org.apache.xmlbeans.impl.SchemaTypeSystemImpl: make sure xbean.jar is on the 
classpath.", localClassNotFoundException);
     }
     catch (Exception localException)
     {
       throw new RuntimeException("Could not instantiate SchemaTypeSystemImpl (" + 
localException.toString() + "): is the version of xbean.jar correct?", localException);
     }
   }
}

org.apache.tika.exception.TikaException: Unexpected RuntimeException from 
org.apache.tika.parser.microsoft.ooxml.OOXMLParser@7450b809
        at 
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:244)[108:org.apache.tika.core:1.4.0]
        at 
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:242)[108:org.apache.tika.core:1.4.0]
        at 
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:242)[108:org.apache.tika.core:1.4.0]
        at 
org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:120)[108:org.apache.tika.core:1.4.0]
        at 
org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:136)[108:org.apache.tika.core:1.4.0]
         ...
Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: Cannot resolve type 
for handle _XY_Q=space|R=space@http://www.w3.org/XML/1998/namespace 
(schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707.cttext7f5btype)
 - code 13
        at 
org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.readHandle(SchemaTypeSystemImpl.java:2025)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.readTypeRef(SchemaTypeSystemImpl.java:2099)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.loadAttribute(SchemaTypeSystemImpl.java:2926)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.readAttributeData(SchemaTypeSystemImpl.java:2918)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.finishLoadingType(SchemaTypeSystemImpl.java:2535)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.resolveHandle(SchemaTypeSystemImpl.java:3511)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.SchemaComponent$Ref.getComponent(SchemaComponent.java:113)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.SchemaType$Ref.get(SchemaType.java:872)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.schema.SchemaPropertyImpl.getType(SchemaPropertyImpl.java:92)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(SchemaTypeImpl.java:995)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(XmlObjectBase.java:938)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1675)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.store.Cur.getUser(Cur.java:2659)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.store.Cur.getObject(Cur.java:2652)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.store.Cursor._getObject(Cursor.java:995)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.xmlbeans.impl.store.Cursor.getObject(Cursor.java:2904)[182:org.apache.servicemix.bundles.xmlbeans:2.6.0.2]
        at 
org.apache.poi.xwpf.usermodel.XWPFParagraph.<init>(XWPFParagraph.java:90)[180:org.apache.servicemix.bundles.poi:3.9.0.3-SNAPSHOT]
        at 
org.apache.poi.xwpf.usermodel.XWPFDocument.onDocumentRead(XWPFDocument.java:146)[180:org.apache.servicemix.bundles.poi:3.9.0.3-SNAPSHOT]
        at 
org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:159)[180:org.apache.servicemix.bundles.poi:3.9.0.3-SNAPSHOT]
        at 
org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:116)[180:org.apache.servicemix.bundles.poi:3.9.0.3-SNAPSHOT]
        at 
org.apache.poi.xwpf.extractor.XWPFWordExtractor.<init>(XWPFWordExtractor.java:53)[180:org.apache.servicemix.bundles.poi:3.9.0.3-SNAPSHOT]
        at 
org.apache.poi.extractor.ExtractorFactory.createExtractor(ExtractorFactory.java:180)[180:org.apache.servicemix.bundles.poi:3.9.0.3-SNAPSHOT]
        at 
org.apache.tika.parser.microsoft.ooxml.OOXMLExtractorFactory.parse(OOXMLExtractorFactory.java:87)[153:org.apache.tika.parsers:1.4.0]
        at 
org.apache.tika.parser.microsoft.ooxml.OOXMLParser.parse(OOXMLParser.java:82)[153:org.apache.tika.parsers:1.4.0]
        at 
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:242)[108:org.apache.tika.core:1.4.0]
        ... 45 more


Cheers,
Łukasz Dywicki
--
[email protected]
Twitter: ldywicki
Blog: http://dywicki.pl
Code-House - http://code-house.org




--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to