Remote lookup using @ejb annotation

前端 未结 3 1978
-上瘾入骨i
-上瘾入骨i 2021-02-09 18:11

I have 2 servers instances of Jboss 5, each of which is deployed with two EAR\'s. Say Client.Ear and Server.Ear. Server Ear expose some ejb\'s. I want to inject this to ClientE

相关标签:
3条回答
  • 2021-02-09 18:22

    @EJB annotation can only be used if the applications are deployed in the same sever instance. @EJB annotation won't work if you are trying to make cross server instance call or remote server call. So, in your case, annotation injection won't work.

    So, what are the solutions ?

    Option 1) Use old style programmatic JNDI look up

    Option 2) Create managed bean as per CDI (Context Dependency Injection) and configure all the JNDI properties there. And @inject the managed bean into your client.

    0 讨论(0)
  • 2021-02-09 18:37

    I found a forum post that answers your question: https://community.jboss.org/thread/228789

    In it he refers to https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance

    And to accomplish the jndi lookup with the @EJB annotaion he uses

    @EJB(lookup = "ejb:earname/modulename/BeanClass!fully.qualified.RemoteInterface")
    private RemoteInterface bean;
    
    0 讨论(0)
  • 2021-02-09 18:37

    I know this little too late . Including this for further reference

    You can use the portable look up String format EJBs use RMI over IIOP and has standard mapping EJB architecture to CORBA So you can lookup by server host and portnumber by

    @EJB(lookup = "corbaname:iiop:example.com:3701#java:global/mycrud/mycrud-dss-ejb/InformeBean!com.myorg.ejb.InformeRemote")
    

    References: https://docs.oracle.com/javase/8/docs/technotes/guides/idl/corba.html https://docs.oracle.com/javase/8/docs/technotes/guides/idl/INStutorial.html

    0 讨论(0)
提交回复
热议问题