3 Replies Latest reply on Sep 2, 2016 10:45 AM by Cheng Fang

    Custom XML External Entities

    Richard Moore Master

      Having a problem trying to get the xml into my job -

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE job [

              <!ENTITY entity-test SYSTEM "entity-test.xml">

              ]>   

      <job id="sqlParmsFromFile" version="1.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee">

      &entity-test;

       

       

      The entity-test.xml file contains -

       

      <properties>

        <property name="simple" value="Did this even work?" />

        <property name="transientSql" value="faclCdSql"/>

        <property name="faclCdList" value="type=list, file=#{systemProperties['APP_DATA']}/sqlParmsFromFile.txt"/>

        </properties>

       

       

      javax.batch.operations.JobStartException: JBERET000602: Failed to parse and bind XML for job sqlParmsFromFile

        at org.jberet.creation.ArchiveXmlLoader.loadJobXml(ArchiveXmlLoader.java:106)

        at org.jberet.operations.JobOperatorImpl.start(JobOperatorImpl.java:102)

        at com.awginc.batch.JavaBatchExecutor.startJob(JavaBatchExecutor.java:97)

        at com.awginc.batch.JavaBatchExecutor.main(JavaBatchExecutor.java:64)

      Caused by: com.fasterxml.aalto.WFCException: General entity reference (&entity-test;) encountered in entity expanding mode: operation not (yet) implemented

      at [row,col {unknown-source}]: [40,16]

        at com.fasterxml.aalto.in.XmlScanner.reportInputProblem(XmlScanner.java:1333)

        at com.fasterxml.aalto.in.Utf8Scanner.handleEntityInText(Utf8Scanner.java:658)

        at com.fasterxml.aalto.in.Utf8Scanner.skipCharacters(Utf8Scanner.java:856)

        at com.fasterxml.aalto.in.XmlScanner.skipToken(XmlScanner.java:416)

        at com.fasterxml.aalto.in.StreamScanner.nextFromTree(StreamScanner.java:189)

        at com.fasterxml.aalto.stax.StreamReaderImpl.next(StreamReaderImpl.java:760)

        at org.jberet.job.model.JobParser.parseStep(JobParser.java:164)

        at org.jberet.job.model.JobParser.parseJob(JobParser.java:75)

        at org.jberet.creation.ArchiveXmlLoader.loadJobXml(ArchiveXmlLoader.java:97)

        ... 3 more

        • 1. Re: Custom XML External Entities
          Cheng Fang Master

          [JBERET-139] Implement XMLResolver for Job XML parsing - JBoss Issue Tracker

           

          Just remove aalto.jar from your classpath, and let JBeret use the default xml parser in Java SE.

           

          Or you can use woodstox xml parser, which is also from com.fasterxml (the same org as aalto xml ).

          • 2. Re: Custom XML External Entities
            Richard Moore Master

            I got past the first exception with the removal of the aalto jar but now I am getting -

             

            Exception in thread "main" java.lang.NullPointerException

              at com.sun.xml.internal.stream.StaxEntityResolverWrapper.resolveEntity(StaxEntityResolverWrapper.java:62)

              at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntityAsPerStax(XMLEntityManager.java:990)

              at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1213)

              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1909)

              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3064)

              at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)

              at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)

              at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:553)

              at org.jberet.job.model.JobParser.parseStep(JobParser.java:164)

              at org.jberet.job.model.JobParser.parseJob(JobParser.java:75)

              at com.awginc.batch.JobAuditor.<init>(JobAuditor.java:21)

              at com.awginc.batch.JobAuditor.main(JobAuditor.java:14)

            • 3. Re: Custom XML External Entities
              Cheng Fang Master

              https://github.com/jberet/jsr352/blob/master/jberet-core/src/test/java/org/jberet/job/model/JobMergerTest.java#L101

               

              the above test class does the similar as you would: load a job and verify certain elements.  It also uses external entities to hold common segments.  It calls ArchiveXmlLoader.loadJobXml(...) to load the job.xml, which is at a higher lever than JobParser.

              1 of 1 people found this helpful