0

I have a requirement where in there are two maven modules as below.

Portal 1. EJBModule 2. Framework 3. UIModule

Whenever I make a call to @RestController in UIModule it invokes a Service in Framework which uses lookup as below and gets the EJB bean.

initContext.lookup(ejbServiceId);

and uses that bean with reflection to call the a particular method.

My requirement is to replace the EJB layer with its beans to Spring Beans.

I can create a Spring bean but could not invoke it using initContext lookup, I tried creating a New Spring module and Adding dependency to framework ( But in this approach I need some model objects if I add the model objects to this new spring module it is creating a circular maven dependency).

Prasanna
  • 81
  • 1
  • 13
  • Just let Spring do the lookup and expose the given result as a bean. THen in the bean that originally does the lookup, just inject a bean of that type. This is also explained in the Spring Reference guide. Or if it is all EJB3 it should be quite easy to transform that into regular beans. – M. Deinum Jun 01 '20 at 09:28
  • Thanks for the reply, Can u please let me know - How to do lookup for spring beans ? Can I create Spring beans in EJBModule (Explained the module structure in question) and Lookup those beans in Framework module without adding maven dependency of EJBModule to Framework. – Prasanna Jun 01 '20 at 10:52
  • Why would you need a lookup for Spring Beans. Spring should lookup EJBs, the ejb stuff shouldn't change (or you should make eveything a bean). Why would you want to mix EJB and Spring (generally that is trouble waiting to happen)_. – M. Deinum Jun 01 '20 at 11:19
  • My EJBModule and Framework where the lookup happening are not related in terms of maven dependencies.. Somehow It is getting those EJB's using lookup but to achieve the same with Spring i have to add it as a maven dependency to Framework.. Which I dont want to do that .. because I have other objects which will create a circular maven dependency – Prasanna Jun 01 '20 at 11:25
  • 2
    There has to be **some** dependency (be it an API etc.) else it simply won't compile. You simply cannot use a class without having it on the classpath in some way. If that is impossible then your design is simply flawed or what you are trying to achieve is too complex (which I suspect because you are mixing 2 DI things already which is always a bit fishy). – M. Deinum Jun 01 '20 at 11:27

0 Answers0