java - Can I look up an EJB via JNDI and invoke methods using reflection? -


i'm using ejb 3.1. need references 1 of ejbs in servlet , i'd rather not put ejb interface jar on class path code compile.

is possible ejb via jndi , find method want invoke using reflection without ever typing object interface?

yes, if you're looking local ejb interface, can , invoke local ejb within same application using reflection.

this should work if you're using direct lookup or ejb ref lookup because java ee spec requires application server make ejb module classes available wars within same application. ejb spec doesn't require support local interfaces across applications, if that's you're doing, you'll have check application server vendor.

this not work in general remote ejb interfaces because client proxy needs created. if you're using rmi-iiop (ejb 2.x remote or ejb 3 extending java.rmi.remote), might able cast ejb lookup result javax.rmi.corba.stub , use _servant_preinvoke or _invoke methods same generated stub method do.

(ultimately, lot of caveats avoid compile-time dependency. it's not worth fragility, recommend finding way solve , compile normally.)


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -