You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Tomasz Mazan <wi...@wp.pl> on 2007/11/23 23:22:58 UTC

Accessing my EJB remote interface from my MDB

I got to objects

CoreManager (session bean annotated with name "CoreManager") with @remote
interfaces and MDB in separated modules (jars/ears) but runs in the same
Geronimo 2.0.2 instance. At runtime MDB is notified what's CoreManager jndi
name, and should get it from context.

I got some questions:
1. Is there common context for those modules / beans ?
2. What's the name of CoreManager that I should pass to my MDB to get proper
core object?

I got MessageDrivenContext in my MDB but I doubt it could be helpful. 

Thanks in advance for your help

Beniamin
-- 
View this message in context: http://www.nabble.com/Accessing-my-EJB-remote-interface-from-my-MDB-tf4864045s134.html#a13919590
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Accessing my EJB remote interface from my MDB

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Nov 26, 2007 4:19 PM, Tomasz Mazan <wi...@wp.pl> wrote:

>   InitialContext ic = new InitialContext();
>   feedbackGate = (FeedbackGateRemote) ic.lookup("CoreManagerRemote");
>
> I get NamingException,
>
> but if I initialize context with additional properties application is
> working fine:
>
>   Properties properties = new Properties();
>   properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.RemoteInitialContextFactory");
>   properties.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");

This is not necessary, I believe.

>   InitialContext ic = new InitialContext(properties);
>   feedbackGate = (FeedbackGateRemote) ic.lookup("CoreManagerRemote");
>
> Is it impossibly to make the first solution working ?

Try out jndi.properties in one of your jars with these properties.
InitialContext should load them on demand.

I'd also expect that some form of jndi entry definition where entries
are externalized, i.e. they're in a different jndi tree would be
possible too, but I have never heard of it/used it in Geronimo.
Perhaps others will chime in and add the missing puzzles.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Accessing my EJB remote interface from my MDB

Posted by Tomasz Mazan <wi...@wp.pl>.
Jacek
When I try to get bean existing in different ear from my MDB (deployed on
the same Geronimo) using initial context like:

  InitialContext ic = new InitialContext();
  feedbackGate = (FeedbackGateRemote) ic.lookup("CoreManagerRemote");

I get NamingException,

but if I initialize context with additional properties application is
working fine:

  Properties properties = new Properties();
  properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
  properties.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
  InitialContext ic = new InitialContext(properties);
  feedbackGate = (FeedbackGateRemote) ic.lookup("CoreManagerRemote");

Is it impossibly to make the first solution working ?

Beniamin


Jacek Laskowski wrote:
> 
> On Nov 23, 2007 11:22 PM, Tomasz Mazan <wi...@wp.pl> wrote:
> 
>> CoreManager (session bean annotated with name "CoreManager") with @remote
>> interfaces and MDB in separated modules (jars/ears) but runs in the same
>> Geronimo 2.0.2 instance. At runtime MDB is notified what's CoreManager
>> jndi
>> name, and should get it from context.
> 
> 
>> 1. Is there common context for those modules / beans ?
> 
> What do you mean by "common context"? If you think of a common JNDI
> naming space, the answer is no - they're in different ears so they
> share only a few objects common objects of Geronimo that all ears
> share and they're different Java instances.
> 
>> 2. What's the name of CoreManager that I should pass to my MDB to get
>> proper
>> core object?
> 
> Exactly the same you'd use from your remote client, but the difference
> lies in the JNDI properties that are not necessary. Geronimo takes
> care of it.The jndi name is earfilename/ejbname{remote} or alike (will
> have to set up an example myself).
> 
> Jacek
> 
> -- 
> Jacek Laskowski
> http://www.JacekLaskowski.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Accessing-my-EJB-remote-interface-from-my-MDB-tf4864045s134.html#a13951517
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Accessing my EJB remote interface from my MDB

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Nov 23, 2007 11:22 PM, Tomasz Mazan <wi...@wp.pl> wrote:

> CoreManager (session bean annotated with name "CoreManager") with @remote
> interfaces and MDB in separated modules (jars/ears) but runs in the same
> Geronimo 2.0.2 instance. At runtime MDB is notified what's CoreManager jndi
> name, and should get it from context.


> 1. Is there common context for those modules / beans ?

What do you mean by "common context"? If you think of a common JNDI
naming space, the answer is no - they're in different ears so they
share only a few objects common objects of Geronimo that all ears
share and they're different Java instances.

> 2. What's the name of CoreManager that I should pass to my MDB to get proper
> core object?

Exactly the same you'd use from your remote client, but the difference
lies in the JNDI properties that are not necessary. Geronimo takes
care of it.The jndi name is earfilename/ejbname{remote} or alike (will
have to set up an example myself).

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl