Hello everyone, I am working on a poc project with the goal of migrating the batch processes from Websphere and Tomee. I am developing a very simple JavaEE Batch project to begin with. During server startup, the JobContext is not getting injected in any of the batch artifacts. Following is the code snippet and the configuration files. I will be glad to share more information. Would really appreciate if someone could help me understand what I am missing here.
Also the Tomee Examples in the http://tomee.apache.org/examples/ had been a tremendous help to us in the past when we migrated our web application. It would be great if there is an example for batch capabilities as well. Thank you. Following is the Batchlet class. import javax.batch.api.Batchlet; import javax.batch.runtime.BatchRuntime; import javax.batch.runtime.context.JobContext; import javax.enterprise.context.Dependent; import javax.inject.Named; @Dependent @Named("MyBatchlet") public class MyBatchlet implements Batchlet { @Inject private JobContext jobCtx; @Override public String process() throws Exception { final String fileName = this.jobCtx.getProperties().getProperty("output_file"); System.out.println("" + (new File(fileName)).length()); return "COMPLETED"; } @Override public void stop() throws Exception { } } *Error:* SEVERE: CDI Beans module deployment failed org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [ javax.batch.runtime.context.Jo bContext] is not found with the qualifiers Qualifiers: [@javax.enterprise.inject.Default()] for injection into Field Injection Point, field name : jobCtx, Bean Owner : [MyBatchlet, WebBeansType:MANAGED, Name:MyBatchlet, API Types:[gov.iowa.wd.ui. tax.batch.job.test.MyBatchlet,java.lang.Object,javax.batch.api.Batchlet], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inj ect.Named]] at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:327) at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196) at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:189) at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:41) at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:913) at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:717) at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1298) at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1124) at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5087) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [javax.batch.runtime.context.JobContext] is not found with the qualifiers Qualifiers: [@javax.enterprise.inject.Default()] for injection into Field Injection Point, field name : jobCtx, Bean Owner : [MyBatchlet, WebBeansType:MANAGED, Name:MyBatchlet, API Types:[gov.iowa.wd.ui. tax.batch.job.test.MyBatchlet,java.lang.Object,javax.batch.api.Batchlet], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inj ect.Named]] at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:65) at org.apache.webbeans.container.InjectionResolver.checkInjectionPoint(InjectionResolver.java:234) at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1199) at org.apache.webbeans.util.WebBeansUtil.validate(WebBeansUtil.java:1709) at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:913) at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:824) at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:307) ... 21 more *JSL:* <?xml version="1.0" encoding="UTF-8"?> <job id="simplejob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> <properties> <property name="input_file" value="input.txt"/> <property name="output_file" value="output.txt"/> </properties> <step id="mychunk" next="mytask"> <chunk> <reader ref="MyReader"></reader> <processor ref="MyProcessor"></processor> <writer ref="MyWriter"></writer> </chunk> </step> <step id="mytask"> <batchlet ref="MyBatchlet"></batchlet> <end on="COMPLETED"/> </step> </job> *Versions:* Tomee version - apache-tomee-plume-7.0.0-M3 JRE - jre1.8.0_25 Primefaces - 6.0 JSF - 2.2.12 Thanks, Jude. IWD - IT [email protected] Ph: 515-281-3378 -- ________________________________________ An Equal Opportunity Employer/Program Auxiliary aids and services are available upon request for individuals with disabilities.
