0

I created a simple ItemReader:

public class SimpleReader extends AbstractItemReader {

    @Inject @BatchProperty
    private String number;

    @Inject
    JobContext jobContext;

    @Override
    public Object readItem() throws Exception {
        // .....
    }
}

When I deploy this code to JBoss EAP 6 I get the following Injection Errors:

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies
for type [String] with qualifiers [@BatchProperty] at injection point
[[field] @Inject @BatchProperty private ....SimpleReader.number]

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies 
for type [JobContext] with qualifiers [@Default] at injection point 
[[field] @Inject ....SimpleWriter.jobContext]

If I understand correctly, Spring-Batch is not yet initialized, when Weld starts injecting. How can I initialize Spring-Batch, so that this injection works?

  • This means that there is no `JobContext` in your bean context. Do you have a `Producer` for the `JobContext`? If you want to inject the `JobContext` directly from the spring lib, make sure the jar contains a `beans.xml`. Read [where to put beans.xml](http://stackoverflow.com/questions/13056336/cdi-beans-xml-where-do-i-put-you) for more info. – Peter Apr 15 '16 at 11:40
  • I do have a beans.xml. Other injections work fine. From JSR-352 Specification: Note: the batch runtime must ensure @ Inject works with @ BatchProperty, whether or not the execution environment includes an implementation of JSR 299 or 330. This means the batch properties may always be injected." – Malte Finsterwalder Apr 16 '16 at 20:41
  • Ok, but the `JobContext` comes from the sping lib, right? Does the spring archive have a `beans.xml` as well? – Peter Apr 17 '16 at 20:01

0 Answers0