You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by rcabaco <rc...@gmail.com> on 2008/01/29 20:58:52 UTC

Re: InitialContext JNDI Lookup

Hello

I am having a similar problem. I use the following:
- OpenEJB 3.0 beta 1
- Tomcat

I deploy the ejb jar and everything goes according to plan. I am now stuck
trying to get a Remote EJB. In the tutorials i've seen that the ejbd service
should be running to perform a remote local but i don't know how to start it
and haven't found any information on how to do it when OpenEJB is running in
Tomcat.

Any thoughts?



Tom Purcell wrote:
> 
> Hello
> 
> Here is my current lookup code. (Notice I've tried the two suggested
> formats):
> 
>         InitialContext ctx = null;
>         try {
>             Properties env = new Properties();
>             env.put("java.naming.factory.initial",
> "org.apache.openejb.client.RemoteInitialContextFactory");
>             env.put("java.naming.factory.host", "127.0.0.1");
>             env.put("java.naming.factory.port", "4201");
>             env.put("java.naming.security.principal", "system");
>             env.put("java.naming.security.credentials", "manager");
>             ctx = new InitialContext(env);
>             System.out.println("Got Context: " + ctx);
>         }
>         catch ( NamingException ne ) {
>             ne.printStackTrace();
>         }
>         String lookupStr = "";
>         ConferenceCallSchedulerRemote ccsRemote = null;
>         try{
>             lookupStr = "ConferenceCallSchedulerLocalLocal";
>             ccsRemote =
> (ConferenceCallSchedulerRemote)ctx.lookup(lookupStr);
>             System.out.println("Worked: " + lookupStr);
>         }
>         catch ( NamingException ne ) {
>             ne.printStackTrace();
>         }
> 
>         try{
>             lookupStr = "ConferenceCallSchedulerRemote";
>             ccsRemote =
> (ConferenceCallSchedulerRemote)ctx.lookup(lookupStr);
>             System.out.println("Worked: " + lookupStr);
>         }
>         catch ( NamingException ne ) {
>             ne.printStackTrace();
>         }
> 
> And current results:
> Got Context: javax.naming.InitialContext@157f0dc
> javax.naming.NameNotFoundException: /ConferenceCallSchedulerLocalLocal
> does not exist in the system.  Check that the app was successfully
> deployed.
>     at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:211)
>     at javax.naming.InitialContext.lookup(InitialContext.java:351)
>     at com.chariotsolutions.soalab.ccs.test.RMITest.main(RMITest.java:285)
> javax.naming.NameNotFoundException: /ConferenceCallSchedulerRemote does
> not exist in the system.  Check that the app was successfully deployed.
>     at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:211)
>     at javax.naming.InitialContext.lookup(InitialContext.java:351)
>     at com.chariotsolutions.soalab.ccs.test.RMITest.main(RMITest.java:294)
> 
> 
> 
> Mohammad Nour El-Din wrote:
>> 
>> Hi Tom...
>> 
>> Would you please try ConferenceCallSchedulerRemote and
>> ConferenceCallSchedulerLocalLocal. Notice the name by which you lookup
>> the
>> local business interface, it has an extra Local postfix. BTW can you send
>> the properties you give to the initial context.
>> 
>> On 2/22/07, Tom Purcell <tp...@chariotsolutions.com> wrote:
>> 
>>>
>>> Hello
>>>
>>> Thanks for the response. Here's my bean and the interfaces:
>>>
>>> @Stateless
>>> public class ConferenceCallSchedulerBean implements
>>> ConferenceCallSchedulerLocal, ConferenceCallSchedulerRemote{
>>>    <methods>
>>> {
>>>
>>> @Local
>>> public interface ConferenceCallSchedulerLocal{
>>>    <methods>
>>> {
>>>
>>> @Remote
>>> public interface ConferenceCallSchedulerRemote{
>>>    <methods>
>>> {
>>>
>>> Here are the look up strings I tried:
>>>            lookupStr =
>>>
>>> "java:comp/env/com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr =
>>> "java:comp/env/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:comp/env/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:comp/env/ConferenceCallScheduler";
>>>            lookupStr =
>>> "com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler
>>> /ConferenceCallSchedulerRemote";
>>>            lookupStr =
>>> "ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "ConferenceCallSchedulerRemote";
>>>            lookupStr = "ConferenceCallScheduler";
>>>            lookupStr =
>>>
>>> "java:comp/com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr =
>>> "java:comp/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:comp/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:comp/ConferenceCallScheduler";
>>>            lookupStr =
>>>
>>> "java:/com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr =
>>> "java:/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:/ConferenceCallScheduler";
>>>
>>> I also tried a bean definition that looked like this:
>>>
>>> @Stateless(name="ConferenceCallScheduler",
>>> mappedName="ejb/ConferenceCallScheduler")
>>> public class ConferenceCallSchedulerBean implements
>>> ConferenceCallSchedulerLocal, ConferenceCallSchedulerRemote{
>>>    <methods>
>>> {
>>>
>>> With these lookups:
>>>            lookupStr =
>>> "java:comp/env/ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:comp/env/ejb/ConferenceCallScheduler";
>>>            lookupStr =
>>> "java:comp/ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:comp/ejb/ConferenceCallScheduler";
>>>            lookupStr =
>>> "java:/ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "java:/ejb/ConferenceCallScheduler";
>>>            lookupStr =
>>> "ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>            lookupStr = "ejb/ConferenceCallScheduler";
>>>
>>> Thanks
>>> Tom
>>>
>>>
>>>
>>> Mohammad Nour El-Din wrote:
>>> >
>>> > Hi Tom...
>>> >
>>> > What combinations you have used ? does this EJB supports EJB2.1 home
>>> and
>>> > object interfaces or EJB3.0 business interface(s) ?
>>> >
>>> >
>>> >
>>> > On 2/22/07, Tom Purcell <tp...@chariotsolutions.com> wrote:
>>> >
>>> >>
>>> >> Hello
>>> >>
>>> >> I have created an EJB3 stateless session bean using annotations (no
>>> >> deployment descriptors) and packed it into a jar and packed the jar
>>> into
>>> >> an
>>> >> ear (there is no web app yet and, therefore, no war). The ear
>>> >> successfully
>>> >> deploys to a Geronimo/Tomcat 2.0-M2 server.
>>> >>
>>> >> The problem I'm having is in the lookup from my client. I'm new to
>>> >> OpenEJB
>>> >> and Geronimo but not to EJB. I'm setting properties, giving them to
>>> the
>>> >> InitialContext and doing a lookup. But a lookup on what? What is the
>>> >> format
>>> >> for the JNDI name I wnat to find? I've tried a number of combinations
>>> >> with
>>> >> no luck.
>>> >>
>>> >> Thanks
>>> >> Tom
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/InitialContext-JNDI-Lookup-tf3273209s2756.html#a9101357
>>> >> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> > Thanks
>>> > - Mohammad Nour
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/InitialContext-JNDI-Lookup-tf3273209s2756.html#a9101836
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> -- 
>> Thanks
>> - Mohammad Nour
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/InitialContext-JNDI-Lookup-tp9101357p15168032.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: InitialContext JNDI Lookup

Posted by rcabaco <rc...@gmail.com>.
The friendly guys at #openejb on freenode provided me with a nice solution.
The EJB lookup can be done through http in the following way:

Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
properties.put(Context.PROVIDER_URL,"http://127.0.0.1:8080/openejb/ejb/");
this.initialContext = new InitialContext(properties);

And then a simple initialContext.lookup("EJBIdentification") will do the
trick. If you're not using any jndi formatting the EJBIdentification would
be: <EJBName><InterfaceType> (e.g. MyEJBRemote)

Quite nice.



rcabaco wrote:
> 
> Hello
> 
> I am having a similar problem. I use the following:
> - OpenEJB 3.0 beta 1
> - Tomcat
> 
> I deploy the ejb jar and everything goes according to plan. I am now stuck
> trying to get a Remote EJB. In the tutorials i've seen that the ejbd
> service should be running to perform a remote local but i don't know how
> to start it and haven't found any information on how to do it when OpenEJB
> is running in Tomcat.
> 
> Any thoughts?
> 
> 
> 
> Tom Purcell wrote:
>> 
>> Hello
>> 
>> Here is my current lookup code. (Notice I've tried the two suggested
>> formats):
>> 
>>         InitialContext ctx = null;
>>         try {
>>             Properties env = new Properties();
>>             env.put("java.naming.factory.initial",
>> "org.apache.openejb.client.RemoteInitialContextFactory");
>>             env.put("java.naming.factory.host", "127.0.0.1");
>>             env.put("java.naming.factory.port", "4201");
>>             env.put("java.naming.security.principal", "system");
>>             env.put("java.naming.security.credentials", "manager");
>>             ctx = new InitialContext(env);
>>             System.out.println("Got Context: " + ctx);
>>         }
>>         catch ( NamingException ne ) {
>>             ne.printStackTrace();
>>         }
>>         String lookupStr = "";
>>         ConferenceCallSchedulerRemote ccsRemote = null;
>>         try{
>>             lookupStr = "ConferenceCallSchedulerLocalLocal";
>>             ccsRemote =
>> (ConferenceCallSchedulerRemote)ctx.lookup(lookupStr);
>>             System.out.println("Worked: " + lookupStr);
>>         }
>>         catch ( NamingException ne ) {
>>             ne.printStackTrace();
>>         }
>> 
>>         try{
>>             lookupStr = "ConferenceCallSchedulerRemote";
>>             ccsRemote =
>> (ConferenceCallSchedulerRemote)ctx.lookup(lookupStr);
>>             System.out.println("Worked: " + lookupStr);
>>         }
>>         catch ( NamingException ne ) {
>>             ne.printStackTrace();
>>         }
>> 
>> And current results:
>> Got Context: javax.naming.InitialContext@157f0dc
>> javax.naming.NameNotFoundException: /ConferenceCallSchedulerLocalLocal
>> does not exist in the system.  Check that the app was successfully
>> deployed.
>>     at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:211)
>>     at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>     at
>> com.chariotsolutions.soalab.ccs.test.RMITest.main(RMITest.java:285)
>> javax.naming.NameNotFoundException: /ConferenceCallSchedulerRemote does
>> not exist in the system.  Check that the app was successfully deployed.
>>     at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:211)
>>     at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>     at
>> com.chariotsolutions.soalab.ccs.test.RMITest.main(RMITest.java:294)
>> 
>> 
>> 
>> Mohammad Nour El-Din wrote:
>>> 
>>> Hi Tom...
>>> 
>>> Would you please try ConferenceCallSchedulerRemote and
>>> ConferenceCallSchedulerLocalLocal. Notice the name by which you lookup
>>> the
>>> local business interface, it has an extra Local postfix. BTW can you
>>> send
>>> the properties you give to the initial context.
>>> 
>>> On 2/22/07, Tom Purcell <tp...@chariotsolutions.com> wrote:
>>> 
>>>>
>>>> Hello
>>>>
>>>> Thanks for the response. Here's my bean and the interfaces:
>>>>
>>>> @Stateless
>>>> public class ConferenceCallSchedulerBean implements
>>>> ConferenceCallSchedulerLocal, ConferenceCallSchedulerRemote{
>>>>    <methods>
>>>> {
>>>>
>>>> @Local
>>>> public interface ConferenceCallSchedulerLocal{
>>>>    <methods>
>>>> {
>>>>
>>>> @Remote
>>>> public interface ConferenceCallSchedulerRemote{
>>>>    <methods>
>>>> {
>>>>
>>>> Here are the look up strings I tried:
>>>>            lookupStr =
>>>>
>>>> "java:comp/env/com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr =
>>>> "java:comp/env/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:comp/env/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:comp/env/ConferenceCallScheduler";
>>>>            lookupStr =
>>>> "com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler
>>>> /ConferenceCallSchedulerRemote";
>>>>            lookupStr =
>>>> "ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "ConferenceCallSchedulerRemote";
>>>>            lookupStr = "ConferenceCallScheduler";
>>>>            lookupStr =
>>>>
>>>> "java:comp/com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr =
>>>> "java:comp/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:comp/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:comp/ConferenceCallScheduler";
>>>>            lookupStr =
>>>>
>>>> "java:/com.chariotsolutions.soalab.ccs.ejb.ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr =
>>>> "java:/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:/ConferenceCallScheduler";
>>>>
>>>> I also tried a bean definition that looked like this:
>>>>
>>>> @Stateless(name="ConferenceCallScheduler",
>>>> mappedName="ejb/ConferenceCallScheduler")
>>>> public class ConferenceCallSchedulerBean implements
>>>> ConferenceCallSchedulerLocal, ConferenceCallSchedulerRemote{
>>>>    <methods>
>>>> {
>>>>
>>>> With these lookups:
>>>>            lookupStr =
>>>> "java:comp/env/ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:comp/env/ejb/ConferenceCallScheduler";
>>>>            lookupStr =
>>>> "java:comp/ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:comp/ejb/ConferenceCallScheduler";
>>>>            lookupStr =
>>>> "java:/ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "java:/ejb/ConferenceCallScheduler";
>>>>            lookupStr =
>>>> "ejb/ConferenceCallScheduler/ConferenceCallSchedulerRemote";
>>>>            lookupStr = "ejb/ConferenceCallScheduler";
>>>>
>>>> Thanks
>>>> Tom
>>>>
>>>>
>>>>
>>>> Mohammad Nour El-Din wrote:
>>>> >
>>>> > Hi Tom...
>>>> >
>>>> > What combinations you have used ? does this EJB supports EJB2.1 home
>>>> and
>>>> > object interfaces or EJB3.0 business interface(s) ?
>>>> >
>>>> >
>>>> >
>>>> > On 2/22/07, Tom Purcell <tp...@chariotsolutions.com> wrote:
>>>> >
>>>> >>
>>>> >> Hello
>>>> >>
>>>> >> I have created an EJB3 stateless session bean using annotations (no
>>>> >> deployment descriptors) and packed it into a jar and packed the jar
>>>> into
>>>> >> an
>>>> >> ear (there is no web app yet and, therefore, no war). The ear
>>>> >> successfully
>>>> >> deploys to a Geronimo/Tomcat 2.0-M2 server.
>>>> >>
>>>> >> The problem I'm having is in the lookup from my client. I'm new to
>>>> >> OpenEJB
>>>> >> and Geronimo but not to EJB. I'm setting properties, giving them to
>>>> the
>>>> >> InitialContext and doing a lookup. But a lookup on what? What is the
>>>> >> format
>>>> >> for the JNDI name I wnat to find? I've tried a number of
>>>> combinations
>>>> >> with
>>>> >> no luck.
>>>> >>
>>>> >> Thanks
>>>> >> Tom
>>>> >> --
>>>> >> View this message in context:
>>>> >>
>>>> http://www.nabble.com/InitialContext-JNDI-Lookup-tf3273209s2756.html#a9101357
>>>> >> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> > --
>>>> > Thanks
>>>> > - Mohammad Nour
>>>> >
>>>> >
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/InitialContext-JNDI-Lookup-tf3273209s2756.html#a9101836
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>> 
>>> 
>>> -- 
>>> Thanks
>>> - Mohammad Nour
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/InitialContext-JNDI-Lookup-tp9101357p15173897.html
Sent from the OpenEJB User mailing list archive at Nabble.com.