6 Replies Latest reply on Mar 14, 2017 3:39 PM by mistrz_7

    XmlItemReader

    mistrz_7

      Hello,

      I work on proces that get data from xml file na load it to csv. My simple xml batch file is:

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

          <step id="load">

              <chunk>

              <reader ref="xmlItemReader">

                      <properties>

                          <property name="resource" value="/home/sla/data_in.xml"/>

                          <property name="beanType" value="pl.test.domain.DataIn"/>

                      </properties>

                  </reader>

                 <processor ref="dataInItemProcessor">

                 </processor>

                

                 <writer ref="csvItemWriter">

                      <properties>

                      <property name="resource" value="/home/sla/data_out.csv""/>

                          <property name="writeMode" value="overwrite"/>

                          <property name="preference" value="STANDARD_PREFERENCE"/>

                          <property name="delimiterChar" value=","/>

                          <property name="quoteChar" value="^"/>

                          <property name="beanType" value="pl.test.domain.DataIn"/>

        </properties>

                  </writer>

                 

              </chunk>

          </step>

      </job>

       

      I have add to pom file all dependecies (https://jberet.gitbooks.io/jberet-user-guide/content/xmlitemreader_and_xmlitemwriter/index.html ). When I start my job I got error:

       

      19:26:16,030 ERROR [org.jberet] (Batch Thread - 1) JBERET000007: Failed to run job libra, load, org.jberet.job.model.Step@3607133b: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;

        at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:86) [jackson-dataformat-xml-2.8.1.jar:2.8.1]

        at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:67) [jackson-dataformat-xml-2.8.1.jar:2.8.1]

        at org.jberet.support.io.XmlItemReaderWriterBase.initXmlFactory(XmlItemReaderWriterBase.java:79) [jberet-support-1.2.0.Final.jar:1.2.0.Final]

        at org.jberet.support.io.XmlItemReader.open(XmlItemReader.java:107) [jberet-support-1.2.0.Final.jar:1.2.0.Final]

        at org.jberet.runtime.runner.ChunkRunner.run(ChunkRunner.java:181) [jberet-core-1.0.2.Final.jar:1.0.2.Final]

        at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:205) [jberet-core-1.0.2.Final.jar:1.0.2.Final]

        at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:138) [jberet-core-1.0.2.Final.jar:1.0.2.Final]

        at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:164) [jberet-core-1.0.2.Final.jar:1.0.2.Final]

        at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88) [jberet-core-1.0.2.Final.jar:1.0.2.Final]

        at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:58) [jberet-core-1.0.2.Final.jar:1.0.2.Final]

        at org.wildfly.jberet.services.BatchEnvironmentService$WildFlyBatchEnvironment$1.run(BatchEnvironmentService.java:144) [wildfly-jberet-8.1.0.Final.jar:8.1.0.Final]

        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_101]

        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_101]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_101]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_101]

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_101]

        at org.jboss.threads.JBossThread.run(JBossThread.java:122)

       

      I don't know where is the problem. It looks that all required libs are in war file.

       

      Best regards

      sw

        • 1. Re: XmlItemReader
          cfang

          could be a version issue with jackson databind jar.

           

          From jackson-databind/SerializationConfig.java at jackson-databind-2.8.1 · FasterXML/jackson-databind · GitHub ,

           

          this method was there since jackson 2.6.

           

          Does your app package in all required jackson jars, or does it reference them in WildFly jackson  modules?  The jackson jars inside WildFly 8.x moduels may be quite old by now.

          • 2. Re: XmlItemReader
            mistrz_7

            My war file contains:

             

            commons-net-3.5.jar

            jackson-annotations-2.8.1.jar

            jackson-core-2.8.1.jar

            jackson-databind-2.8.1.jar

            jackson-dataformat-xml-2.8.1.jar

            jackson-module-jaxb-annotations-2.8.1.jar

            javax.inject-1.jar

            jberet-support-1.2.0.Final.jar

            jboss-batch-api_1.0_spec-1.0.0.Final.jar

            jboss-json-api_1.0_spec-1.0.0.Final.jar

            json-simple-1.1.1.jar

            stax2-api-3.1.4.jar

            super-csv-2.3.1.jar

            woodstox-core-5.0.2.jar

            • 3. Re: XmlItemReader
              cfang

              These API jars shoudl not be packaged into WAR file:

               

              javax.inject-1.jar,

              jboss-batch-api_1.0_spec-1.0.0.Final.jar,

              jboss-json-api_1.0_spec-1.0.0.Final.jar

               

              That's just a good practice, and should not the the cause of this problem.  Teh only cause of this problem is somewhere in the runtime classpath, an older version of jackson jar is pulled in.

               

              Can you run "mvn dependency:tree" to check which library also has dependency on these jackson jars?

               

              Since you have JSON API jar there, probably your app does some JSON processing, which may very well depends on some older versions of jackson.  If that's the case, explicitly declare all these jackson dependencies with appropriate version, as opposed to being pulled in via transitive dependencies.

               

              If the problem still persists, can you create a JBeret JIRA issue with reproducible test app?

              • 4. Re: XmlItemReader
                cfang
                1. JBERET-320

                NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter

                • 5. Re: XmlItemReader
                  cfang

                  Looks like these jackson jars are added to your app deployment as implicit dependencies.  Similar problems and solutions reported by others:

                   

                  java - Unable to exclude Jackson jars in WildFly - Stack Overflow

                   

                  Wildfly 9 - How do I exclude Jackson - Stack Overflow

                   

                  They may work for your app.

                   

                  Another option is to just use the jackson jars in WildFly, by declaring them in your app's jboss-deployment-strucutre.xml file, if the older versions are acceptable to your app.

                  • 6. Re: XmlItemReader
                    mistrz_7

                    The solution was just to exclude jackon libs.

                    Thank for help.