WELD-001408 Unfulfilled dependencies for type [LdapService] with qualifiers [@Named] at injection point

Hi I am trying to deploy EAR on my 12c (12.1.3) server with no success.

My LdapService class is a standalone EJB with a standard args constructor (this project is an ejb package)

@Stateless
public class LdapService {

@Inject
public LdapService() {

} ...

      

I am trying to inject it into another class, for example:

public class UserService {

private static final Logger logger = LoggerFactory.getLogger(UserService.class.getCanonicalName());
@Inject
private LdapService registerService;

@EJB(beanName = "Janus-session-1.0.jar#UserBean")
private TUserBean userBean;

...}

      

bean is annotated with @EJB, which is recognized by CDI, but the injection point is throwing me this error at @Inject:

Deployment failed. There was a message: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [LdapService] with qualifiers [@Default] at injection point [[field] @Inject net.ab4cus.project.business.TransactionService.registerService] ... Possible dependencies [[Session bean [class net.ab4cus.project.auth.LdapService with qualifiers [@Any @Default]]; local interfaces are [LdapService]]

If in LdapService use @Named ("LdapService") and then at insertion point use:

@Inject @Named("LdapService") private LdapService registerService;

      

Then I got this error:

Deployment failed. The message was: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependency for type [LdapService] with qualifiers [@Named] on injection point [[field] @Inject @Named net.ab4cus.project.business.UserService. registerService]

How can I resolve this error and clear up the ambiguity? or what is the correct way to do @Inject for other beans?

Thank.

EDIT ------------------------------------------- ------ -------------------------------------------- -

I was able to deploy EAR, but now there are other CDI related bugs.

My EAR content is an EJB module (with beans and all the business logic) and two WARs (one for WebServices and one for Web FronEnd using Vaadin).

WebServices is RESTFull, and no matter what WS I try to use, always get this error:

java.lang.NullPointerException
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:94)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:314)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604)
Truncated. see log file for complete stacktrace

      

If I try with frontend, anytime a bean, I get this error (for each bean):

SEVERE: 
java.lang.IllegalArgumentException: Can not set net.ab4cus.project.session.TUserBean field net.ab4cus.project.business.UserService.userBean to net.ab4cus.project.session.UserBean_o7pydo_NoIntfViewImpl
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)

      

I'm trying to resolve this but don't know yet: /

+3


source to share


1 answer


Solution for my first error:

-Remove @Stateless and @Inject from LdapService and default constructor

public class LdapService {

}...

      



-Create an interface for LdapService and @ Insert this interface into UserService

public class UserService {

private static final Logger logger = LoggerFactory.getLogger(UserService.class.getCanonicalName());
@Inject
private LdapServiceInterface registerService;

@EJB(beanName = "Janus-session-1.0.jar#UserBean")
private TUserBean userBean;

...}

      

+6


source







All Articles