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");
}
}