Jasper issue with weblogic and java batch

0

Hi,

I have a piece of code that I'd like to run-it on Weblogic 12.2:

JasperPrint print = null;
 
try {
            logger.debug("start create JasperPrint");
            print = JasperFillManager.fillReport(jasperReport, params, connection);
            logger.debug("end create JasperPrint");
    } catch (Throwable e) {
            logger.debug("fail create JasperPrint !!!! ", e);
}

This piece of code is running into a batch context:

JobOperator operator = BatchRuntime.getJobOperator();
 
Properties props = new Properties();
props.put("zzzz", ....);
props.put("zzz1", ....);
operator.start("job_....", props);

the problem is:

<com.ibm.jbatch.container.impl.BaseStepControllerImpl> <BaseStepControllerImpl> <execute> <Caught exception executing step: com.ibm.jbatch.container.exception.BatchContainerRuntimeException: Failure in Read-Process-Write Loop
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.invokeChunk(ChunkStepControllerImpl.java:686)
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.invokeCoreStep(ChunkStepControllerImpl.java:764)
at com.ibm.jbatch.container.impl.BaseStepControllerImpl.execute(BaseStepControllerImpl.java:144)
at com.ibm.jbatch.container.impl.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:112)
at com.ibm.jbatch.container.impl.FlowControllerImpl.execute(FlowControllerImpl.java:72)
at com.ibm.jbatch.container.impl.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:112)
at com.ibm.jbatch.container.impl.JobThreadRootControllerImpl.originateExecutionOnThread(JobThreadRootControllerImpl.java:110)
at com.ibm.jbatch.container.impl.FlowInSplitThreadRootControllerImpl.originateExecutionOnThread(FlowInSplitThreadRootControllerImpl.java:42)
at com.ibm.jbatch.container.util.BatchWorkUnit.run(BatchWorkUnit.java:80)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at weblogic.work.concurrent.TaskWrapper.call(TaskWrapper.java:151)
at weblogic.work.concurrent.future.AbstractFutureImpl.runTask(AbstractFutureImpl.java:391)
at weblogic.work.concurrent.future.AbstractFutureImpl.doRun(AbstractFutureImpl.java:436)
at weblogic.work.concurrent.future.ManagedFutureImpl.run(ManagedFutureImpl.java:28)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:617)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:397)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused by: com.ibm.jbatch.container.exception.BatchContainerRuntimeException: Error happend when try to create a EMail notification.
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.processItem(ChunkStepControllerImpl.java:436)
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.readAndProcess(ChunkStepControllerImpl.java:262)
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.invokeChunk(ChunkStepControllerImpl.java:622)

...Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.extensions.ExtensionsEnvironment
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:271)
at net.sf.jasperreports.engine.util.MessageUtil.getMessageProvider(MessageUtil.java:70)
at net.sf.jasperreports.engine.JRRuntimeException.resolveMessage(JRRuntimeException.java:166)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:146)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:138)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at java.lang.String.valueOf(String.java:2982)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:695)
at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
at java.lang.Throwable.printStackTrace(Throwable.java:667)
at java.lang.Throwable.printStackTrace(Throwable.java:721)
at org.apache.log4j.DefaultThrowableRenderer.render(DefaultThrowableRenderer.java:60)
at org.apache.log4j.spi.ThrowableInformation.getThrowableStrRep(ThrowableInformation.java:87)
at org.apache.log4j.spi.LoggingEvent.getThrowableStrRep(LoggingEvent.java:413)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:313)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:285)

- I have all required jasper jars packaed into my ear.

- I've tried that java.awt.deadless=true... no positive result (anyway, I'm on windows)

- Strange thing: if I'm starting the server in debug mode, and I'm starting the batch from outside the server (simple junit class, with look-up for job initializer), it works.

@Test
    public void testTestJasperFill() throws Exception {
try {
            log.debug("===== start test =======");
            Context context = getInitialContext();
            I...EJBRemote ejbRemote = (I...EJBRemote) context.lookup("...");
            ejbRemote .method("...", "....");
            log.debug("===== end test =======");
 
        } catch (NamingException e) {
            log.debug("", e);
        }
 
 
    private Context getInitialContext() throws NamingException {
        Hashtable env = new Hashtable();
        // WebLogic Server 10.x connection details
        env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
        env.put(Context.PROVIDER_URL, "t3://127.0.0.1:8000");
        env.put(Context.SECURITY_CREDENTIALS, "weblogic1");
        env.put(Context.SECURITY_PRINCIPAL, "weblogic");
        return new InitialContext(env);
    }

Moreover,

If I'm running

print = JasperFillManager.fillReport(jasperReport, params, connection);

outside batch context , it seems it doesn't throw anything...

immediately after that, I'm pressing the button to start the batch, and... I'm getting this beauty:

net.sf.jasperreports.engine.JRException: Could not instantiate report compiler: net.sf.jasperreports.engine.design.JRJavacCompiler.
at net.sf.jasperreports.engine.JasperCompileManager.getCompiler(JasperCompileManager.java:827)
at net.sf.jasperreports.engine.JasperCompileManager.getEvaluator(JasperCompileManager.java:380)
at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator(JRFillDataset.java:467)
at net.sf.jasperreports.engine.fill.BaseReportFiller.<init>(BaseReportFiller.java:152)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:239)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:69)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:201)
at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:216)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:85)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:863)
at x.x.x.batch.ItemProcessor.buildHtmlJasperNotif(ItemProcessor.java:117)
at x.x.x.ItemProcessor.processItem(ItemProcessor.java:355)
at com.ibm.jbatch.container.artifact.proxy.ItemProcessorProxy.processItem(ItemProcessorProxy.java:34)
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.processItem(ChunkStepControllerImpl.java:410)
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.readAndProcess(ChunkStepControllerImpl.java:262)
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.invokeChunk(ChunkStepControllerImpl.java:622)
at com.ibm.jbatch.container.impl.ChunkStepControllerImpl.invokeCoreStep(ChunkStepControllerImpl.java:764)
at com.ibm.jbatch.container.impl.BaseStepControllerImpl.execute(BaseStepControllerImpl.java:144)
at com.ibm.jbatch.container.impl.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:112)
at com.ibm.jbatch.container.impl.FlowControllerImpl.execute(FlowControllerImpl.java:72)
at com.ibm.jbatch.container.impl.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:112)
at com.ibm.jbatch.container.impl.JobThreadRootControllerImpl.originateExecutionOnThread(JobThreadRootControllerImpl.java:110)
at com.ibm.jbatch.container.impl.FlowInSplitThreadRootControllerImpl.originateExecutionOnThread(FlowInSplitThreadRootControllerImpl.java:42)
at com.ibm.jbatch.container.util.BatchWorkUnit.run(BatchWorkUnit.java:80)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at weblogic.work.concurrent.TaskWrapper.call(TaskWrapper.java:151)
at weblogic.work.concurrent.future.AbstractFutureImpl.runTask(AbstractFutureImpl.java:391)
at weblogic.work.concurrent.future.AbstractFutureImpl.doRun(AbstractFutureImpl.java:436)
at weblogic.work.concurrent.future.ManagedFutureImpl.run(ManagedFutureImpl.java:28)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:617)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:397)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused by: java.lang.NoSuchMethodException: net.sf.jasperreports.engine.design.JRJavacCompiler.<init>(net.sf.jasperreports.engine.JasperReportsContext)
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getConstructor(Class.java:1825)
at net.sf.jasperreports.engine.JasperCompileManager.getCompiler(JasperCompileManager.java:822)
... 37 more

Does anyone have any idea?

Thanks for anything..

adrian.carp's picture
Joined: Sep 8 2016 - 6:42am
Last seen: 9 months 4 weeks ago

1 Answer:

0

Hi, 

Issue solved as it was a classpath issue.

maven ear plugin added into war manifest file the entire classpath used for ejb module. So I end up with duplicated classloader.

No problem with jasper :)

adrian.carp's picture
Joined: Sep 8 2016 - 6:42am
Last seen: 9 months 4 weeks ago
Feedback