This content has been marked as final.
Show 8 replies
-
1. Re: Injecting Remote EJBs
cavani Jan 7, 2008 9:34 AM (in response to starf666)I am using this:
Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://192.168.1.1:1099"); Context ctx = new InitialContext(env); return (ManagementService) ctx.lookup("tlon/ManagementServiceBean/remote");
where there is two ears on different AS instance (and machines). "tlon" is the name of second EAR. "ManagementService" interface is deployed in both. Both application are Seam basead.
I think (but don't tryed) tou could use factory or unwrap annotation to encapsulate and use in annotation for injection.
Thanks, -
2. Re: Injecting Remote EJBs
cavani Jan 7, 2008 9:59 AM (in response to starf666)Something like this:
@Name("managedRemoteServer") @Scope(ScopeType.STATELESS) public class ManagedRemoteServer { @Unwrap public ManagementService getRemoteServer() { try { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://192.168.1.1:1099"); Context ctx = new InitialContext(env); return (ManagementService) ctx.lookup("tlon/ManagementServiceBean/remote"); } catch (Exception e) { e.printStackTrace(); } return null; } }
And:@In private ManagementService remoteServer;
Obs.: I didn't test this... -
3. Re: Injecting Remote EJBs
cavani Jan 7, 2008 10:11 AM (in response to starf666)[sorry... I will stop....]
I think that this is your answer:
In addition, EJB 3.0 dependency injection only works in the local JNDI. Hence you cannot inject objects from remote servers.
from:
http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/injection/index.html
Thanks, -
4. Re: Injecting Remote EJBs
andyd Jan 7, 2008 3:34 PM (in response to starf666)You may be able to acheive what you want to using the web services support, but it isn't something I have experience using.
-
5. Re: Injecting Remote EJBs
starf666 Jan 8, 2008 4:10 AM (in response to starf666)Thanks for the answers so far.
[sorry... I will stop....] I think that this is your answer: Quote: In addition, EJB 3.0 dependency injection only works in the local JNDI. Hence you cannot inject objects from remote servers. from: http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/injection/index.html
I guess that's the answer albeit I hoped it wouldn't. Would clustering get me anywhere? I don't know much about it. I am not sure I could use different resources on different cluster nodes. A part of the whole application must run on a Windows server while the web part should be able to run on linux. Else I will have to do the lookup manually, what would mess up my code a bit.
P.S.: Is injection of remote EJBs not possible in JBoss (4.2) or is it not possible in EJB3 in general? Wouldn't it be a cool feature? -
6. Re: Injecting Remote EJBs
pmuir Jan 8, 2008 5:25 AM (in response to starf666)Ask about remote EJB injection on the EJB3 forum ;)
Cavani's second answer is the right way to expose a remote ejb to Seam. -
7. Re: Injecting Remote EJBs
starf666 Jan 8, 2008 6:12 AM (in response to starf666)So this has nothing to do with seam? I didn't expect this to be so unlikely in the development of enterprise (web) systems.
-
8. Re: Injecting Remote EJBs
pmuir Jan 8, 2008 6:26 AM (in response to starf666)Injection of EJB3s using @EJB is not Seam, no. I suspect you will get a better informed response on the EJB3 forum.