0

I try to integrate CDI spring-data-jpa in Java EE environment.

I created a very simple repository:

public interface SampleRepository extends JpaRepository<Sample, String> {
}

I also added the CDI producer for the EntityManager:

@ApplicationScoped
class EntityManagerProducer {

    @PersistenceContext
    private EntityManager entityManager;

    @Produces
    @RequestScoped
    EntityManager createEntityManager() {
        return entityManager;
    }

}

Then I want to inject this repository to another CDI bean:

@ApplicationScoped
public class SampleService {

    private SampleRepository sampleRepository;

    public SampleService() {
    }

    @Inject
    public SampleService(SampleRepository sampleRepository) {
        this.sampleRepository = sampleRepository;
    }

}

and also into EJB. For JBoss EAP 7.1 application server it works great - the repository is injected correctly for CDI bean or EJB and I can run queries on the database. However, for WebSphere, I am getting the following exception during startup and the application cannot start:

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type SampleRepository with qualifiers @Default at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public com.sample.ejb.SampleEJB(SampleRepository) at com.sample.ejb.SampleEJB.(SampleEJB.java:0)

at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:362) at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284) at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:137) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:158) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:501) at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:61) at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:59) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55) at java.util.concurrent.FutureTask.run(FutureTask.java:277) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.lang.Thread.run(Thread.java:812)

Adam
  • 884
  • 7
  • 29

0 Answers0