I was trying to create a hello world with JNoSQL, Mongo and Wildfly Swarm.
The use @Inject
of DocumentCollectionManager
is working, but it is not working with a Repository
.
This is how I'm injecting:
@Inject
private DocumentCollectionManager entityManager; // works
@Inject
@Database(DatabaseType.DOCUMENT)
private UserRepository userRepository; // do not work!
This is how I configured the producer:
@ApplicationScoped
public class MongoProducer {
private static final String DATABASE = "db";
@Inject
@ConfigurationUnit(name = "document", fileName = "jnosql.yaml")
private DocumentCollectionManagerFactory<MongoDBDocumentCollectionManager> entityManager;
@Produces
@Database(DatabaseType.DOCUMENT)
public DocumentCollectionManager getManager() {
return entityManager.get(DATABASE);
}
}
What can I do to automatic inject Repositories in my Wildfly Swarm application?
The throwed error:
2018-05-23 11:30:31,270 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."demo.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."demo.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1978)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type UserRepository with qualifiers @Database
at injection point [BackedAnnotatedField] @Inject @Database private com.example.demo.rest.HelloWorldEndpoint.userRepository
at com.example.demo.rest.HelloWorldEndpoint.userRepository(HelloWorldEndpoint.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:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
2018-05-23 11:30:31,278 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "demo.war")) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"demo.war\".WeldStartService" => "Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type UserRepository with qualifiers @Database
at injection point [BackedAnnotatedField] @Inject @Database private com.example.demo.rest.HelloWorldEndpoint.userRepository
at com.example.demo.rest.HelloWorldEndpoint.userRepository(HelloWorldEndpoint.java:0)
"}}
2018-05-23 11:30:31,279 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "demo.war" was rolled back with the following failure message:
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"demo.war\".WeldStartService" => "Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type UserRepository with qualifiers @Database
at injection point [BackedAnnotatedField] @Inject @Database private com.example.demo.rest.HelloWorldEndpoint.userRepository
at com.example.demo.rest.HelloWorldEndpoint.userRepository(HelloWorldEndpoint.java:0)
"}}
how is going?
There're same bugs in your code:
I created a PR: https://github.com/vepo/wildly-swarm-jnosql/pull/1