Creating EJBs in Spring MVC project - Problems with Dependency Injection

1

I have a Java application with Spring MVC that is divided into modules as follows.

proj_servicos = Mapped entities, Repository (communication with the bank) and Services (Where Repository is injected) classes.

Location where persistence.xml is for communication with the bank.

proj_web = It has the proj_servicos project as a dependency and is responsible for serving the system screens to the user.

My problem is this: I need to create an EJB whether it will be executed by batch (Do not blame me, it was not my choice, I only work here rs), so I created a proj_ejb project that has the interfaces and implementations of the EJB and has proj_servicos as a dependency so that you can use the same entities and reused the Repository and Service methods.

Repositories are annotated with @Resource and injected into the Service with @Resource as well. Services are also annotated with @Resource and injected into Controller with @Inject .

When I try to do the same within EJBs (inject Services with @Inject ), it injects the Service but the Repository that is inside the > Service gets null , is not injected.

I have already made several tests of replacing the @Resource with @Inject within the Service too but it did not work. The EJBs are annotated with @Remote .

Does anyone know what might be happening? How can I resolve this issue of Dependency Injections? Or am I trying to do something impossible?

    
asked by anonymous 15.12.2017 / 13:01

1 answer

0

Have you tried the @Autowired annotation? Take a look at this article link

    
21.12.2017 / 08:16