Creating Ejbs in Spring MVC Project - Problems with Dependency Injection

Asked

Viewed 77 times

1

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

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

Place where the persistence.xml for communication with the bank.

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

My problem is this, I need to forncecer an EJB either will run by batch (Don’t blame me, it wasn’t my choice, I just work here rs), so I created a project proj_ejb that has the interfaces and implementations of EJB and has the proj_servicos as a dependency so that it is possible to use the same entities and reuse the methods of Repository and Service.

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

When I try to do the same inside the Ejbs (inject the Services with @Inject), he injects the Service however the Repository that’s inside the Service stays null, is not injected.

I’ve done several tests to replace the @Resource for @Inject within the Service but it didn’t work either. Ejbs are noted with @Remote.

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

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.