Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I come from the JBoss world so I'm not completely sure about it. But can you really inject a remote interface in that way? There must be a lookup defined, I think. However for a local-interface your call should work. And if you use remote-interfaces you should use </p> <p><code> @EJB(lookup="jnp://wholeclustername/YourBean/remote")</code></p> <p>and your DNS must point your network to both machines.</p> <p>Another possible workaround can be a @Produce-method and an @Inject where you do the lookup in the producer-method. </p> <p>Edit:</p> <p>Yes, unfortunately. I face these hacks from time to time, too:(</p> <p>Maybe there's another workaround or a solution, I'm not firm enough in Weblogic. If you wanna decouple it from your source you can also use an interceptor and inject a slsb instance each call, maybe because of your failover it work with a @PostConstruct, too. I dont know:</p> <p><code> public class LookUpEJBInterceptor {</p> <pre><code>@AroundInvoke public Object around(InvocationContext ctx){ try { Class&lt;?&gt; clazzOfEJBImplementation = ctx.getTarget().getClass(); //look for your field, I just check for the EJB annotation but that's not enough for (Field f : clazzOfEJBImplementation.getDeclaredFields()){ if(f.isAnnotationPresent(EJB.class)){ f.setAccessible(true); f.set(ctx.getTarget(), lookupEJB()); } } return ctx.proceed(); } catch (Exception e) { e.printStackTrace(); throw new EJBException(); } } /** * get your ejb * * @return * @throws NamingException */ private Object lookupEJB() throws NamingException{ return new InitialContext().lookup("Your ejb lookup"); } </code></pre> <p></code></p> <p>Second edit:</p> <p>If you can use AspectJ you can construct a hack like this: <code></p> <pre><code>pointcut checkEJB(OurEJBInterface r): call(void OurEJBInterface.yourVoid()) &amp;&amp; target(r); void around (OurEJBInterface r) : yourVoid(r){ r = lookupYourEJB(); return proceed(r); } private Object lookupEJB() throws NamingException{ return new InitialContext().lookup("Your ejb lookup"); } </code></pre> <p></code></p> <p>But both are only hacks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload