You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by veggen <th...@yahoo.com> on 2008/04/08 10:39:46 UTC
Desktop app communicating with EJB
I'll be working with OpenEJB/Tomcat and I know I'll be able to call EJBs from
a servlet, but what I need to know is if it will be possible for my desktop
app to communicate with EJBs?
Thanks.
--
View this message in context: http://www.nabble.com/Desktop-app-communicating-with-EJB-tp16549561p16549561.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Desktop app communicating with EJB
Posted by veggen <th...@yahoo.com>.
Thanks a lot David, you've been most helpful :)
David Blevins wrote:
>
>
> On Apr 8, 2008, at 12:39 PM, David Blevins wrote:
>>
>> On Apr 8, 2008, at 1:39 AM, veggen wrote:
>>>
>>> I'll be working with OpenEJB/Tomcat and I know I'll be able to call
>>> EJBs from
>>> a servlet, but what I need to know is if it will be possible for my
>>> desktop
>>> app to communicate with EJBs?
>>>
>
> Whoops, I just noticed you said you were on Tomcat. You need to use
> this connection info instead:
>
> Properties p = new Properties();
> p.put("java.naming.factory.initial",
> "org.openejb.client.RemoteInitialContextFactory");
> p.put("java.naming.provider.url", "http://<tomcat-host-and-port>/
> openejb/ejb");
> p.put("java.naming.security.principal", "myuser");
> p.put("java.naming.security.credentials", "mypass");
>
> InitialContext ctx = new InitialContext(p);
>
> MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
>
> And I forgot to mention, the principal and credentials part is
> optional, you don't need them unless your bean is setup to require
> authorization.
>
> -David
>
>
>
--
View this message in context: http://www.nabble.com/Desktop-app-communicating-with-EJB-tp16549561p16603939.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Desktop app communicating with EJB
Posted by David Blevins <da...@visi.com>.
On Apr 8, 2008, at 12:39 PM, David Blevins wrote:
>
> On Apr 8, 2008, at 1:39 AM, veggen wrote:
>>
>> I'll be working with OpenEJB/Tomcat and I know I'll be able to call
>> EJBs from
>> a servlet, but what I need to know is if it will be possible for my
>> desktop
>> app to communicate with EJBs?
>>
Whoops, I just noticed you said you were on Tomcat. You need to use
this connection info instead:
Properties p = new Properties();
p.put("java.naming.factory.initial",
"org.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://<tomcat-host-and-port>/
openejb/ejb");
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
And I forgot to mention, the principal and credentials part is
optional, you don't need them unless your bean is setup to require
authorization.
-David
Re: Desktop app communicating with EJB
Posted by David Blevins <da...@visi.com>.
On Apr 8, 2008, at 1:39 AM, veggen wrote:
>
> I'll be working with OpenEJB/Tomcat and I know I'll be able to call
> EJBs from
> a servlet, but what I need to know is if it will be possible for my
> desktop
> app to communicate with EJBs?
>
Yes. Put the openejb-client-*.jar and the javaee-api-5.0-1.jar in
your classpath and construct your client's InitialContext like so:
Properties p = new Properties();
p.put("java.naming.factory.initial",
"org.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "ejbd://localhost:4201");
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
The global JNDI names of beans are listed in the openejb.log file.
That's what you should use to do the lookup from a remote client
(don't append "java:/comp/env"). The names can be changed, see this
page for the various options: http://openejb.apache.org/3.0/jndi-names.html
-David