Search code examples
javaspringglassfishejbglassfish-4

Glassfish4 tries to inject EJB in Spring context


I am trying to upgrade to Glassfish 4 for an application that uses a combination of EJBs and Spring beans. This worked fine on Glassfish3.

When i try to deploy I get errors of this type:

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type SomethingLogic with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private com.my.application.server.service.SomethingServiceSession.somethingLogic

At first, I got these in non-spring beans when trying to @Inject a Spring bean (EJBs/webservices/servlets). After changing all @Inject's to @Autowired, the non-spring classes no longer give the error, but I start getting the same errors on the purely Spring beans (so @Inject of a Spring bean to another Spring bean gives the error.)

This leads me to believe that Glassfish will try to look for a EJB when encountering @Inject, no matter if it's in the context of EJB or not, and no matter if the bean to be injected is a EJB or a Spring bean.

Is this the case, and how do I avoid this?


Solution

  • Managed to solve my problem, by adding bean-discovery-mode="none" to my various beans.xml files.