Java – Remote lookup using @ejb annotation

ejbjava

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 ClientEar via annotation. Using JNDI lookup i did it fine and it works. But using annotation i always get javax.naming.NamingException.
However when injecting session beans accross deployment artifacts the global JNDI name has to be used for injection and i used that also like
@EJB(mappedName ="java:global/Server/component/ApplicationService!com.test.server.ApplicationServiceInterface")

But it seems like I am not providing the provider_url of the remote server to bound it to the client ear instance.
How could i configure jndi properties, ie provider_url, initial context properites with the annotation @ EJB?

Best Answer

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;
Related Topic