Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-19982

Wildfly doesn't pick up batchlet classes in debug mode

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • 4.3.0.Beta1
    • 4.3.0.Beta1
    • batch, server
    • None
    • Hide

      1. Import batch-processing project from https://github.com/jboss-developer/jboss-sandbox-quickstarts as an existing maven project
      2. Debug the project on some local Wildfly 8.2.0.Final
      3. When http://localhost:8080/jboss-batch-processing/batch.jsf is opened in the browser press the "Generate a new file and start import job" button on the page.
      4. See the console. There are not any errors.
      5. Open /jboss-batch-processing/src/main/resources/META-INF/batch-jobs/import-file.xml.
      6. Modify it:

      <?xml version="1.0" encoding="UTF-8"?>
      <job id="import-file" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/jobXML_1_0.xsd" version="1.0">
          <listeners>
              <listener ref="jobListener" />
          </listeners>
          <step id="import-file-chunk" next="reportBatchelet">
              <listeners>
                  <listener ref="persistListener" />
              </listeners>
              <!-- The item-count specified the size of the chunk -->
              <chunk item-count="3">
                  <reader ref="recordsReader">
                      <properties>
                          <!--  Define how values are separated -->
                          <property name="separatorRegex" value="[|]" />
                          <property name="fileName" value="#{jobParameters['fileName']}" />
                      </properties>
                  </reader>
                  <processor ref="contactFormatter" />
                  <writer ref="contactsPersister" />
              </chunk>
          </step>
          <step id="reportBatchelet" next="emailingContact">
              <batchlet ref="reportBatchelet" />
          </step>
          <step id="emailingContact">
              <batchlet ref="emailingContactBatchlet"></batchlet>
              <end on="END"/>
          </step>
      </job>
      

      7. Save the file.
      8. Add a new Java class /jboss-batch-processing/src/main/java/org/jboss/as/quickstarts/batch/job/EmailingContactBatchlet.java:

      package org.jboss.as.quickstarts.batch.job;
      
      import java.util.List;
      import java.util.logging.Logger;
      
      import javax.batch.api.AbstractBatchlet;
      import javax.inject.Inject;
      import javax.inject.Named;
      import javax.persistence.EntityManager;
      
      import org.jboss.as.quickstarts.batch.model.Contact;
      
      @Named
      public class EmailingContactBatchlet extends AbstractBatchlet {
      
          @Inject
          private EntityManager entityManager;
      
          @Inject
          private Logger log;
      
          @Override
          public String process() throws Exception {
      		List<Contact> contacts = (List<Contact>) entityManager.createQuery("SELECT c FROM Contact c").getResultList();
      		for (Contact contact : contacts) {
      			log.info("EMAILING " + contact);
      			// TODO Send email to the contact
      		}
              return "END";
          }
      }
      

      9. Refresh the browser. Press the "Generate a new file and start import job" button on http://localhost:8080/jboss-batch-processing/batch.jsf again.
      10. FAILURE: See the console:

      12:46:44,586 WARN  [org.jberet] (Batch Thread - 2) JBERET000001: Failed to run batchlet org.jberet.job.model.RefArtifact@7dad8621: java.lang.IllegalStateException: JBERET000600: Failed to create artifact with ref name emailingContactBatchlet.  Ensure CDI beans.xml is present and batch.xml, if any, is configured properly.
      	at org.jberet.runtime.context.JobContextImpl.createArtifact(JobContextImpl.java:196) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	at org.jberet.runtime.runner.BatchletRunner.run(BatchletRunner.java:61) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:208) [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.runJobElement(CompositeExecutionRunner.java:128) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:184) [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.runJobElement(CompositeExecutionRunner.java:128) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:184) [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.2.0.Final.jar:8.2.0.Final]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_45]
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_45]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_45]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_45]
      	at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
      	at org.jboss.threads.JBossThread.run(JBossThread.java:122)
      Caused by: java.lang.IllegalStateException: JBERET000600: Failed to create artifact with ref name emailingContactBatchlet.  Ensure CDI beans.xml is present and batch.xml, if any, is configured properly.
      	at org.jberet.creation.ArtifactFactoryWrapper.getClassFromBatchXmlOrClassLoader(ArtifactFactoryWrapper.java:65) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	at org.jberet.creation.ArtifactFactoryWrapper.create(ArtifactFactoryWrapper.java:41) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	at org.jberet.runtime.context.JobContextImpl.createArtifact(JobContextImpl.java:194) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	... 19 more
      Caused by: java.lang.ClassNotFoundException: emailingContactBatchlet from [Module "deployment.jboss-batch-processing.war:main" from Service Module Loader]
      	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
      	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
      	at org.jberet.creation.ArtifactFactoryWrapper.getClassFromBatchXmlOrClassLoader(ArtifactFactoryWrapper.java:63) [jberet-core-1.0.2.Final.jar:1.0.2.Final]
      	... 21 more
      
      12:46:44,592 INFO  [org.jboss.as.quickstarts.batch.job.listener.JobListener] (Batch Thread - 2) Job import-file - Execution #2 finished. Status: FAILED
      

      11. Restart the server. Refresh the browser. Press the button. See console:

      13:02:38,562 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=1, name=Maqpcwlxzh, phone=(439)-717-604]
      13:02:38,562 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=2, name=Qdostlilkb, phone=(444)-737-677]
      13:02:38,562 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=3, name=Ljkayqfkkh, phone=(671)-394-583]
      13:02:38,562 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=4, name=Fnasgvfxrg, phone=(835)-667-558]
      13:02:38,563 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=5, name=Ubalsunbnx, phone=(780)-472-167]
      13:02:38,563 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=6, name=Piyftzbbyu, phone=(348)-523-965]
      13:02:38,563 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=7, name=Gobdqpmsbv, phone=(463)-946-411]
      13:02:38,563 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=8, name=Fiowuekayh, phone=(703)-340-466]
      13:02:38,563 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=9, name=Scrkctbxhv, phone=(182)-839-533]
      13:02:38,563 INFO  [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=10, name=Rquvzulybx, phone=(945)-980-621]
      13:02:38,564 INFO  [org.jboss.as.quickstarts.batch.job.listener.JobListener] (Batch Thread - 1) Job import-file - Execution #1 finished. Status: COMPLETED
      
      Show
      1. Import batch-processing project from https://github.com/jboss-developer/jboss-sandbox-quickstarts as an existing maven project 2. Debug the project on some local Wildfly 8.2.0.Final 3. When http://localhost:8080/jboss-batch-processing/batch.jsf is opened in the browser press the "Generate a new file and start import job" button on the page. 4. See the console. There are not any errors. 5. Open /jboss-batch-processing/src/main/resources/META-INF/batch-jobs/import-file.xml. 6. Modify it: <?xml version= "1.0" encoding= "UTF-8" ?> <job id= " import -file" xmlns= "http: //xmlns.jcp.org/xml/ns/javaee" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http: //xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/jobXML_1_0.xsd" version= "1.0" > <listeners> <listener ref= "jobListener" /> </listeners> <step id= " import -file-chunk" next= "reportBatchelet" > <listeners> <listener ref= "persistListener" /> </listeners> <!-- The item-count specified the size of the chunk --> <chunk item-count= "3" > <reader ref= "recordsReader" > <properties> <!-- Define how values are separated --> <property name= "separatorRegex" value= "[|]" /> <property name= "fileName" value= "#{jobParameters[ 'fileName' ]}" /> </properties> </reader> <processor ref= "contactFormatter" /> <writer ref= "contactsPersister" /> </chunk> </step> <step id= "reportBatchelet" next= "emailingContact" > <batchlet ref= "reportBatchelet" /> </step> <step id= "emailingContact" > <batchlet ref= "emailingContactBatchlet" ></batchlet> <end on= "END" /> </step> </job> 7. Save the file. 8. Add a new Java class /jboss-batch-processing/src/main/java/org/jboss/as/quickstarts/batch/job/EmailingContactBatchlet.java: package org.jboss.as.quickstarts.batch.job; import java.util.List; import java.util.logging.Logger; import javax.batch.api.AbstractBatchlet; import javax.inject.Inject; import javax.inject.Named; import javax.persistence.EntityManager; import org.jboss.as.quickstarts.batch.model.Contact; @Named public class EmailingContactBatchlet extends AbstractBatchlet { @Inject private EntityManager entityManager; @Inject private Logger log; @Override public String process() throws Exception { List<Contact> contacts = (List<Contact>) entityManager.createQuery( "SELECT c FROM Contact c" ).getResultList(); for (Contact contact : contacts) { log.info( "EMAILING " + contact); // TODO Send email to the contact } return "END" ; } } 9. Refresh the browser. Press the "Generate a new file and start import job" button on http://localhost:8080/jboss-batch-processing/batch.jsf again. 10. FAILURE : See the console: 12:46:44,586 WARN [org.jberet] (Batch Thread - 2) JBERET000001: Failed to run batchlet org.jberet.job.model.RefArtifact@7dad8621: java.lang.IllegalStateException: JBERET000600: Failed to create artifact with ref name emailingContactBatchlet. Ensure CDI beans.xml is present and batch.xml, if any, is configured properly. at org.jberet.runtime.context.JobContextImpl.createArtifact(JobContextImpl.java:196) [jberet-core-1.0.2.Final.jar:1.0.2.Final] at org.jberet.runtime.runner.BatchletRunner.run(BatchletRunner.java:61) [jberet-core-1.0.2.Final.jar:1.0.2.Final] at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:208) [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.runJobElement(CompositeExecutionRunner.java:128) [jberet-core-1.0.2.Final.jar:1.0.2.Final] at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:184) [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.runJobElement(CompositeExecutionRunner.java:128) [jberet-core-1.0.2.Final.jar:1.0.2.Final] at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:184) [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.2.0.Final.jar:8.2.0.Final] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_45] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_45] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_45] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_45] at java.lang. Thread .run( Thread .java:745) [rt.jar:1.8.0_45] at org.jboss.threads.JBossThread.run(JBossThread.java:122) Caused by: java.lang.IllegalStateException: JBERET000600: Failed to create artifact with ref name emailingContactBatchlet. Ensure CDI beans.xml is present and batch.xml, if any, is configured properly. at org.jberet.creation.ArtifactFactoryWrapper.getClassFromBatchXmlOrClassLoader(ArtifactFactoryWrapper.java:65) [jberet-core-1.0.2.Final.jar:1.0.2.Final] at org.jberet.creation.ArtifactFactoryWrapper.create(ArtifactFactoryWrapper.java:41) [jberet-core-1.0.2.Final.jar:1.0.2.Final] at org.jberet.runtime.context.JobContextImpl.createArtifact(JobContextImpl.java:194) [jberet-core-1.0.2.Final.jar:1.0.2.Final] ... 19 more Caused by: java.lang.ClassNotFoundException: emailingContactBatchlet from [Module "deployment.jboss-batch-processing.war:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final] at org.jberet.creation.ArtifactFactoryWrapper.getClassFromBatchXmlOrClassLoader(ArtifactFactoryWrapper.java:63) [jberet-core-1.0.2.Final.jar:1.0.2.Final] ... 21 more 12:46:44,592 INFO [org.jboss.as.quickstarts.batch.job.listener.JobListener] (Batch Thread - 2) Job import -file - Execution #2 finished. Status: FAILED 11. Restart the server. Refresh the browser. Press the button. See console: 13:02:38,562 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=1, name=Maqpcwlxzh, phone=(439)-717-604] 13:02:38,562 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=2, name=Qdostlilkb, phone=(444)-737-677] 13:02:38,562 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=3, name=Ljkayqfkkh, phone=(671)-394-583] 13:02:38,562 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=4, name=Fnasgvfxrg, phone=(835)-667-558] 13:02:38,563 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=5, name=Ubalsunbnx, phone=(780)-472-167] 13:02:38,563 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=6, name=Piyftzbbyu, phone=(348)-523-965] 13:02:38,563 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=7, name=Gobdqpmsbv, phone=(463)-946-411] 13:02:38,563 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=8, name=Fiowuekayh, phone=(703)-340-466] 13:02:38,563 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=9, name=Scrkctbxhv, phone=(182)-839-533] 13:02:38,563 INFO [org.jboss.as.quickstarts.batch.job.EmailingContactBatchlet] (Batch Thread - 1) EMAILING Contact [id=10, name=Rquvzulybx, phone=(945)-980-621] 13:02:38,564 INFO [org.jboss.as.quickstarts.batch.job.listener.JobListener] (Batch Thread - 1) Job import -file - Execution #1 finished. Status: COMPLETED

      It seems that wildfly 8.2. (or JBT server adapter?) doesn't support hot deployment for batch application.
      See steps to reproduce.
      If I change job.xml then it works fine. But if I add some new classes which are referenced from the job xml file then it doesn't it.

      I see both the modified jbo xml files and new class file in wildfly-8.2.0.Final/standalone/deployments/jboss-batch-processing.war folder but server restarting is still required.

      This is probably an upstream issue but we need to investigate this case and maybe document it somehow if this is an expecting behavior.

            alexeykazakov Alexey Kazakov
            alexeykazakov Alexey Kazakov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: