1
votes

I working with jee and wildfly for few days now i have problem. I created something like this:

@Stateless
public class BookService {

@EJB
private BookDao bookDao;

public void addBook(Book book) {
    bookDao.saveBook(book);
}

public Optional<Book> getBookById(Long id) {
    return bookDao.getBookById(id);
}

public void updateBook(Book book) {
    bookDao.updateBook(book);
}

@Produces
@Named("books")
public List<Book> getAllBooks() {
    return bookDao.getAllBooks();
}
}

Next I tryied to use #{books} in jsf but i got exception:

2017-05-23 08:49:07,447] Artifact ear:ear: Error during artifact deployment. See server log for details.

[2017-05-23 08:49:07,448] Artifact ear:ear: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"Lab6.ear\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"Lab6.ear\".WeldStartService: Failed to start service

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001414: Bean name is ambiguous. Name books resolves to beans:

  • Producer Method [List] with qualifiers [@Default @Named @Any] declared as [[BackedAnnotatedMethod] @Produces @Named public app.service.BookService.getAllBooks()],

  • Producer Method [List] with qualifiers [@Default @Named @Any] declared as [[BackedAnnotatedMethod] @Produces @Named public app.service.BookService.getAllBooks()]"},"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"Lab6.ear\".WeldStartService"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}

What is the source of problem.

2
Please share information on your deployment structure. I suppose I'll be EAR and you have some dependency twice resulting in two identical producers. Make double sure that the BookService is on one place in your deployment only.Siliarus

2 Answers

1
votes

This looks like you have built your EAR file components incorrectly:

  • the EJB jar is in the EAR file itself;
  • the EJB jar is also in the WEB-INF/lib directory of your WAR file

This will give you two copies of the same bean.

0
votes

The error comes from the fact that you have 2 beans of type Book. To clarify see this example here, how the Class and the producer are two beens with the same name. And here another example of the same tipycall mistake. Check them both. You have another bean with the name books soomewhere in your code