My problem is solved :
I was giving a DOM document as parameter to the transform, and this DOM document was shared between threads. nodeCloning the document solved the problem, but introduce performance regression...
Grrrr...

Best regards,
Christophe

Le 05/09/2012 15:29, Christophe Marchand a écrit :
Hi all !

now in a new company, I joined back the list.

I have a strange problem, transforming a DOM to a Stream. It seems my DOM do not have a correct structure.
When I run my process in a single thread, I have no problem, but when I use parallel processing, I have this error :

java.lang.NullPointerException
    at org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source)
    at org.apache.xerces.dom.ParentNode.item(Unknown Source)
    at net.sf.saxon.dom.NodeWrapper$ChildEnumeration.skipFollowingTextNodes(NodeWrapper.java:1166)
    at net.sf.saxon.dom.NodeWrapper$ChildEnumeration.next(NodeWrapper.java:1194)
    at net.sf.saxon.tree.util.Navigator$AxisFilter.next(Navigator.java:879)
    at net.sf.saxon.expr.ContextMappingIterator.next(ContextMappingIterator.java:51)
    at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:51)
    at net.sf.saxon.expr.GeneralComparison.effectiveBooleanValue(GeneralComparison.java:539)
    at net.sf.saxon.expr.FilterIterator$NonNumeric.matches(FilterIterator.java:182)
    at net.sf.saxon.expr.FilterIterator.getNextMatchingItem(FilterIterator.java:65)
    at net.sf.saxon.expr.FilterIterator.next(FilterIterator.java:44)
    at net.sf.saxon.expr.ContextMappingIterator.next(ContextMappingIterator.java:51)
    at net.sf.saxon.expr.ContextMappingIterator.next(ContextMappingIterator.java:51)
    at net.sf.saxon.value.SequenceExtent.<init>(SequenceExtent.java:103)
    at net.sf.saxon.expr.sort.DocumentOrderIterator.<init>(DocumentOrderIterator.java:30)
    at net.sf.saxon.expr.sort.DocumentSorter.iterate(DocumentSorter.java:96)
    at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:207)
    at net.sf.saxon.expr.AtomicSequenceConverter.iterate(AtomicSequenceConverter.java:110)
    at net.sf.saxon.functions.StringJoin.evaluateItem(StringJoin.java:71)
    at net.sf.saxon.expr.Expression.evaluateAsString(Expression.java:469)
    at net.sf.saxon.expr.instruct.SimpleNodeConstructor.processLeavingTail(SimpleNodeConstructor.java:180)
    at net.sf.saxon.expr.instruct.ValueOf.processLeavingTail(ValueOf.java:226)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123)
    at net.sf.saxon.expr.LetExpression.process(LetExpression.java:409)
    at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:387)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569)
    at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:758)
    at net.sf.saxon.expr.instruct.Template.expand(Template.java:225)
    at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:284)
    at net.sf.saxon.expr.instruct.CallTemplate.processLeavingTail(CallTemplate.java:308)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569)
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:208)
    at net.sf.saxon.expr.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:368)
    at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:636)
    at net.sf.saxon.expr.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:340)
    at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:232)
    at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:196)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269)
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569)
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318)
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269)
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:208)
    at net.sf.saxon.expr.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:368)
    at net.sf.saxon.trans.StringifyRuleSet.process(StringifyRuleSet.java:54)
    at net.sf.saxon.expr.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:356)
    at net.sf.saxon.Controller.transformDocument(Controller.java:1887)
    at net.sf.saxon.Controller.transform(Controller.java:1737)
    at com.oxiane.perf.java.pdf.PdfRunner.createPdfFromBulletin(PdfRunner.java:134)


My code is :
            DocumentBuilderFactory domFactory = FactoryProvider.getDocumentBuilderFactory();
            DocumentBuilder builder = domFactory.newDocumentBuilder();
            Document dom = builder.parse(new ByteArrayInputStream(data));
...
            String xsltName = elementModel.getXslt();
            Templates tpl = rendererXsltCache.get(xsltName);
            if(tpl==null) {
                File XsltFile = new File(payeModel.getBaseDirectory(),xsltName);
                TransformerFactory tFactory = FactoryProvider.getTransformerFactory();
                tpl = tFactory.newTemplates(new StreamSource(XsltFile));
                rendererXsltCache.put(xsltName, tpl);
            }
            Transformer transformer = tpl.newTransformer();
            transformer.setParameter("repository", repository);
            File targetFile = new File(outputDir, fileName+".pdf");
            OutputStream osXhtml = new FileOutputStream(tmpFile);
            transformer.transform(new DOMSource(dom), new StreamResult(osXhtml));
            osXhtml.flush(); osXhtml.close();


I use Saxon 9.2.

Any idea wil be much appreciated !

Best regards,
Crhistophe


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help