cdi does not find daos(spring data +ejb+cdi)

Asked

Viewed 163 times

0

the situation is as follows , I am using spring boot and The first thing I did was disable tom cat and use wildfly(10)

I used spring data to create the Daos

public interface AutoresDao extends JpaRepository<Autor, Long >{}

ai I decided to do an integration with ejb + cdi, then started the problems cdi can’t find these Daos.

@Stateless public class Autorbusiness {

@Inject
private AutoresDao autoresDao;

and finally use in Resource

@RestController

@Requestmapping("/authors") public class Autoresresources {

@Inject
private AutorBusiness autorBusiness;

the wildfly finds and records both the autorBusiness and the good book

inserir a descrição da imagem aqui

but then he gives this mistake Aki

20:31:04,602 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."SpringBootBasic.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."SpringBootBasic.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
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: org.jboss.Weld.exceptions.Deploymentexception: Exception List with 2 exceptions: Exception 0 : org.jboss.Weld.exceptions.Deploymentexception: WELD-001408: Unsatisfied dependencies for type Autoresdao with Qualifiers @Default at Injection point [Backedannotatedfield] @Inject private com.restApi.business.AutorBusiness.autoresDao at com.restApi.business.AutorBusiness.autoresDao(Autorbusiness.java:0)

at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
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)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

Exception 1 : org.jboss.Weld.exceptions.Deploymentexception: WELD-001408: Unsatisfied dependencies for type Comment with Qualifiers @Default at Injection point [Backedannotatedfield] @Inject private com.restApi.business.LivroBusiness.comentBd at com.restApi.business.LivroBusiness.comentBd(Livrobusiness.java:0)

at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
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)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

at org.jboss.weld.bootstrap.ConcurrentValidator.validateBeans(ConcurrentValidator.java:76)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:479)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:445)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:96)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
... 3 more

20:31:04,619 ERROR [org.jboss.as.controller.management-Operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("Deployment" => "Springbootbasic.War")]) - Failure Description: { "WFLYCTL0080: Failed services" => {"jboss.deployment.Unit. " Springbootbasic.War ". Weldstartservice" => "org.jboss.Msc.service.Startexception in service jboss.deployment.Unit. " Springbootbasic.War ". Weldstartservice: Failed to start service Caused by: org.jboss.Weld.exceptions.Deploymentexception: Exception List with 2 exceptions: Exception 0 : org.jboss.Weld.exceptions.Deploymentexception: WELD-001408: Unsatisfied dependencies for type Autoresdao with Qualifiers @Default at Injection point [Backedannotatedfield] @Inject private com.restApi.business.AutorBusiness.autoresDao at com.restApi.business.AutorBusiness.autoresDao(Autorbusiness.java:0)

at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
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)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

Exception 1 : org.jboss.Weld.exceptions.Deploymentexception: WELD-001408: Unsatisfied dependencies for type Comment with Qualifiers @Default at Injection point [Backedannotatedfield] @Inject private com.restApi.business.LivroBusiness.comentBd at com.restApi.business.LivroBusiness.comentBd(Livrobusiness.java:0)

at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
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)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

"}, "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.Unit. " Springbootbasic.War ". Weldstartservice"], "WFLYCTL0180: Services with Missing/unavailable dependencies" => Undefined }

follows also myapplication.properties, I created a Data Source on standalone.xml of the wildfly, it’s fated

spring.datasource.jndi-name = java:jboss/datasources/restDS

and finally follows the directory

inserir a descrição da imagem aqui

If anyone has a solution to this I gather from the bottom of my S2

1 answer

0


The Comentdao dependency of the Livrobusiness class is not eligible for CDI.

To make it eligible you can include the Beans.xml file in your project, WEB-INF(War) or META-INF(jar) folder, but this makes all classes in your project eligible and controllable by the container.

Another option is to include a CDI scope in the classes you want to make them eligible, Comment on your case..

The possible scopes are:

  1. Applicationscoped - The state of the bean remains during the application life.
  2. Sessionscoped - The Bean’s life cycle is linked to the user.
  3. Requestscoped - A new bean will be created for each request.
  4. Dependent - Depends on the scope of who injects the bean.
  5. Conversationscoped - Allows the Bean to transition between a cycle of Requestscoped life and a Sessionscoped programmatically.

For if a DAO I point out the Dependent scope.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.