Injection dependency of .jar subproject

0

I have a EJB application that has a lib jar as a built-in dependency for code reuse. My .jar has a class that has been annotated with @RequestScoped , and I need to retrieve it in my ejb.

I'm using the following line, does anyone know why it does not work?

MinhaClasse o = CDI.current().select(MinhaClasse .class).get();
return o.getNome();

Error Code:

  Caused by: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308: Unable to resolve any beans for Type: class br.com.meuprojeto.jpa.MinhaClasse; Qualifiers: []
    
asked by anonymous 24.03.2017 / 21:39

1 answer

0

The MyClass class is not eligible for the CDI.

  • Make sure you are using the CDI @RequestScoped (javax.enterprise.context).
  • Use @Inject to perform the injection. How an EJB is Managed by the container, the Bean will be injected normally.
  • Ensure that your JAR has the beans.xml file in the META-INF folder.
  • If none of this works out, you can still create a method annotated with @Produces that returns an instance of the class MyClass. As the method parameter you can receive whatever is required to create the instance (the items received per parameter must be eligible for the CDI).

        
    13.04.2017 / 18:14