0

I am trying to run a JSR352 java batch program in Java SE mode using JBERET implementation. I can see my main() method getting executed. It is in this main() method i get handle of a job operator and starting the job.

public static void main(String[] args) {

    LoggingConfig logConfiguration = new LoggingConfig();

    logger.info("Begining Batch with JBeret approach");

    JobOperator jo = BatchRuntime.getJobOperator();
    long id = jo.start("PilotJob", null);

    logger.info("End of Batch");

}

but, I do not see any log statements inside my reader, processor, writer or listeners getting printed.

I have a logging.properties defined and loaded from my projects src/main/resources/META-INF folder. The log statements in my main() method is getting printed according to it but, the log statements in my reader/writer/processor and listeners aren't printing at all.

public class LoggingConfig {
    public LoggingConfig() {
        try {
            // Load a properties file from class path that way can't be achieved
            // with java.util.logging.config.file

              final LogManager logManager = LogManager.getLogManager(); 
              try (final InputStream is = getClass().getResourceAsStream("/META-INF/logging.properties")) 
              {
                  logManager.readConfiguration(is);
              }

        } catch (Exception e) {
            System.out.println("Error while reading Log configuration file");
            e.printStackTrace();
        }
    }
}

Why isn't my log statements (java log library) in my java batch program to be printed ?

Here are the logs from the main() method. I can clearly see that a job has been started but, not sure why the log statements of the batch program isn't getting printed.

    INFO: App Begining Batch with JBeret approach - v1.0
    INFO: org.jboss.weld.Version WELD-000900: 2.2.15 (Final)
    INFO: org.jboss.weld.Bootstrap WELD-ENV-000014: Falling back to Java Reflection for bean-discovery-mode="annotated" discovery. Add org.jboss:jandex to the classpath to speed-up startup.
    INFO: org.jboss.weld.Bootstrap WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
    WARN: org.jboss.weld.Interceptor WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled
    WARN: org.jboss.weld.Interceptor WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
    DEBUG: org.jboss.weld.Bootstrap WELD-000100: Weld initialized. Validating beans
    DEBUG: org.jboss.weld.Reflection WELD-000620: interface javax.enterprise.inject.Intercepted is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.
    DEBUG: org.jboss.weld.Reflection WELD-000620: interface javax.enterprise.inject.Decorated is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.        
    FINE: javax.batch.runtime.BatchRuntime Loaded BatchContainerServiceProvider with className = org.jberet.operations.JobOperatorImpl
    TRACE: org.jberet JBERET000022: resume is not implemented for local transactions
    DEBUG: org.jberet JBERET000017: Persisted org.jberet.runtime.JobInstanceImpl@6 with id 6
    DEBUG: org.jberet JBERET000017: Persisted org.jberet.runtime.JobExecutionImpl@6 with id 6
    INFO: App End of Batch

Here is a Listener code which has both a Sysout and Log statement. Both of them aren't getting printed in my Eclipse console.

import java.util.logging.Logger;

import javax.batch.api.listener.AbstractJobListener;

public class PilotLibJobListener extends AbstractJobListener {

    private final static Logger logger = Logger.getLogger("PilotLibJobListener");   

    public void beforeJob() {
        BatchListenerRecorder.batchListenersCountDownLatch.countDown();
        System.out.println("Before Job");
        logger.info("MyJobListener.beforeJob");
    }

    @Override
    public void afterJob() {
        BatchListenerRecorder.batchListenersCountDownLatch.countDown();
        logger.info("MyJobListener.afterJob");
    }

}
yathirigan
  • 5,619
  • 22
  • 66
  • 104

1 Answers1

0

To query job execution status, you can just call the appropriate API on JobOperator, e.g., public JobExecution getJobExecution(long executionId). The returned JobExecution object contains the latest data.

For job repository, you can choose in-memory job repository, if a jdbc job repository is too heavy-weight for your app. But with the default H2 database, you can configure to have embedded, or file-based H2 database, instead of the client-server mode, in order to limit resource consumption.

For logging issues, can you create a JIRA issue, or github issue, and attach a reproducible test app?

cheng
  • 1,076
  • 6
  • 6
  • my jberet properties have a H2 DB configured as job repo but, my issue is more towards the log statements within my java batch program not getting printed. I can see that the log statements in main program getting printed but, not the ones in the jsr352 classes (reader/writer/processor/listener) – yathirigan Sep 28 '17 at 02:49
  • I have tried setting the system property org.jboss.logging.provider as suggested in this https://developer.jboss.org/thread/272789 but, still not working. i have created a github issue https://github.com/jberet/jsr352/issues/102 with this problem – yathirigan Sep 28 '17 at 03:36