Ignore:
Timestamp:
12/30/11 03:11:51 (5 months ago)
Author:
jharrop
Message:

Work around for class cast exception in BinderImpl?.unmarshal (copied from MainDocumentPart?).

Location:
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/FooterPart.java

    r1650 r1736  
    200200                                XmlUtils.transform(doc, mcPreprocessorXslt, null, result); 
    201201                                doc = (org.w3c.dom.Document)result.getNode(); 
    202                                 jaxbElement =  (Ftr) binder.unmarshal( doc );                                    
     202                                 
     203                                try {                            
     204                                        jaxbElement =  (Ftr) binder.unmarshal( doc ); 
     205                                } catch (ClassCastException cce) { 
     206                                        // Work around for issue with JAXB binder, in Java 1.6 
     207                                        // See comments in MainDocumentPart.                                     
     208                                        log.warn("Binder not available for this docx"); 
     209                                        Unmarshaller u = jc.createUnmarshaller(); 
     210                                        jaxbElement = (Ftr) u.unmarshal( doc );                                  
     211                                } 
    203212                        } 
    204213                         
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/HeaderPart.java

    r1650 r1736  
    191191                                log.info("encountered unexpected content; pre-processing"); 
    192192                                eventHandler.setContinue(true); 
     193                                 
     194                                // There is no JAXBResult(binder), 
     195                                // so use a  
    193196                                DOMResult result = new DOMResult(); 
     197                                 
    194198                                Templates mcPreprocessorXslt = JaxbValidationEventHandler.getMcPreprocessor(); 
    195199                                XmlUtils.transform(doc, mcPreprocessorXslt, null, result); 
     200                                 
    196201                                doc = (org.w3c.dom.Document)result.getNode(); 
    197                                 jaxbElement =  (Hdr) binder.unmarshal( doc );                                    
     202                                try {                            
     203                                        jaxbElement =  (Hdr) binder.unmarshal( doc ); 
     204                                } catch (ClassCastException cce) { 
     205                                        // Work around for issue with JAXB binder, in Java 1.6 
     206                                        // See comments in MainDocumentPart.                                     
     207                                        log.warn("Binder not available for this docx"); 
     208                                        Unmarshaller u = jc.createUnmarshaller(); 
     209                                        jaxbElement = (Hdr) u.unmarshal( doc );                                  
     210                                } 
     211                                 
     212                                 
    198213                        } 
    199214                         
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/MainDocumentPart.java

    r1659 r1736  
    322322                                        jaxbElement =  (org.docx4j.wml.Document) binder.unmarshal( doc ); 
    323323                                } catch (ClassCastException cce) { 
    324                                         // Work around for issue with JAXB binder, in Java 1.6 
    325                                         // encountered with /src/test/resources/jaxb-binder-issue.docx                                   
     324  
    326325                                        log.warn("Binder not available for this docx"); 
    327326                                        Unmarshaller u = jc.createUnmarshaller(); 
    328327                                        jaxbElement = (org.docx4j.wml.Document) u.unmarshal( doc );                                      
    329                                         /* java.lang.ClassCastException: org.docx4j.wml.PPr cannot be cast to javax.xml.bind.JAXBElement 
     328                                        /*  
     329                                         * Work around for issue with JAXB binder, in Java 1.6  
     330                                         * encountered with /src/test/resources/jaxb-binder-issue.docx  
     331                                         * See http://old.nabble.com/BinderImpl.associativeUnmarshal-ClassCastException-casting-to-JAXBElement-td32456585.html 
     332                                         *  
     333                                         * java.lang.ClassCastException: org.docx4j.wml.PPr cannot be cast to javax.xml.bind.JAXBElement 
    330334                                                at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl$IntercepterLoader.intercept(Unknown Source) 
    331335                                                at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(Unknown Source) 
Note: See TracChangeset for help on using the changeset viewer.