You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Tiburtius, Ashwanth" <as...@iwd.iowa.gov> on 2017/03/10 18:09:54 UTC

JavvEE Batch

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
ashwanth.tiburtius@iwd.iowa.gov
Ph: 515-281-3378

-- 
________________________________________
An Equal Opportunity Employer/Program
Auxiliary aids and services are available upon request for individuals with 
disabilities.

Re: JavvEE Batch

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

did you test 7.0.2 or coming 7.0.3 (
http://tomee-openejb.979440.n4.nabble.com/VOTE-Apache-TomEE-7-0-3-td4681228.html#a4681278)
?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-03-10 19:09 GMT+01:00 Tiburtius, Ashwanth <ashwanth.tiburtius@iwd.iowa.
gov>:

> 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(Ope
> nEJBLifecycle.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.createApplica
> tion(Assembler.java:913)
>         at
> org.apache.openejb.assembler.classic.Assembler.createApplica
> tion(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.lifecycleEve
> nt(GlobalListenerSupport.java:133)
>         at
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(Li
> fecycleBase.java:94)
>         at
> org.apache.catalina.core.StandardContext.startInternal(Stand
> ardContext.java:5087)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at
> org.apache.catalina.core.ContainerBase.addChildInternal(Cont
> ainerBase.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(ThreadPool
> Executor.java:1142)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
> lExecutor.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.throwUnsatis
> fiedResolutionException(InjectionExceptionUtil.java:65)
>         at
> org.apache.webbeans.container.InjectionResolver.checkInjecti
> onPoint(InjectionResolver.java:234)
>         at
> org.apache.webbeans.container.BeanManagerImpl.validate(BeanM
> anagerImpl.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.validateInjectionPo
> ints(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
> ashwanth.tiburtius@iwd.iowa.gov
> Ph: 515-281-3378
>
> --
> ________________________________________
> An Equal Opportunity Employer/Program
> Auxiliary aids and services are available upon request for individuals with
> disabilities.
>