You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by vrm <vi...@hotmail.com> on 2007/09/14 19:48:06 UTC

RE: jndi lookup in remote client for geronimo v2

I'm having the exact same issue. I've spent 2 days looking around and there
is no examples or documentations available for a Remote openejb client
accessing an EJB on Geronimo 2.

Anybody have an EAR for Geronimo2 and an Openejb-Client app accessing it? 

The Exception I get =
javax.naming.NameNotFoundException: /TheBean does not exist in the system. 
Check that the app was successfully deployed.

I've tried the following for InitialContext.lookup =
(artifactid)/(TheBean)/(TheInterface)
(artifactid)/(Interface)
(ejbBean)/(Interface)
(artifactid)/(TheBean)/(Full Path to Interface)
...and many more variations of this


My EJB Interface = 

@Remote
public interface TheInterface {


My Bean =
@Stateless
public class TheBean implements TheInterface {


Anybody get this to work or have examples, please post.




Xiao-fei Song wrote:
> 
> Hi,
> 
> Just wanted to let you know I modified a little bit about the code:
> 
>         props.setProperty("java.naming.factory.initial",
> "org.apache.openejb.client.RemoteInitialContextFactory");
>         props.setProperty("java.naming.provider.url", "127.0.0.1:4201");
>         props.setProperty("java.naming.security.principal", "system");
>         props.setProperty("java.naming.security.credentials", "manager");
>         
>         Context ic = new InitialContext(props);
>         System.out.println("ic = " + ic);
>         
>         Object objRef = ic.lookup("MySessionRemoteHome");
>         System.out.println("objRef = " + objRef);
>         
>         test.abc.MySessionRemoteHome home =
> (test.abc.MySessionRemoteHome)PortableRemoteObject.narrow(objRef,
> test.abc.MySessionRemoteHome.class);
>         System.out.println("home = " + home);
>         
>         test.abc.MySessionRemote remote = home.create();
>         System.out.println("remote = " + remote);
>         
>         String message = remote.getString();
>         System.out.println("message = " + message);
> 
> 
> and it works okay on geronimo 1.2 beta. So this really makes me confused,
> is this a regression or intended to be. Can someone in this alias please
> respond me?
> 
> Thanks,
> Chris
> 
> 
> Xiao-fei Song wrote:
>> 
>> Hi Mark,
>> 
>> Thanks for your response.
>> 
>> 1. For the time being, I don't really care if the client is really
>> "remote". From my tests, it looks like only "127.0.0.1" is accepted
>> otherwise the connects just failed. I don't know where the documentation
>> can be found on this.
>> 
>> 2. Yes I assume all the libraries are there for the EJB call. And they
>> are:
>> 
>> cglig-nodep
>> geronimo-kernel
>> openejb-core
>> openejb-client
>> j2ee.jar (from j2ee ri)
>> 
>> 3. Unfortunately it does not work with "ejb/MySessionRemoteHome" and here
>> is what I got:
>> 
>> ic = javax.naming.InitialContext@1e51060
>> Exception in thread "main" javax.naming.NameNotFoundException:
>> /ejb/MySessionRemoteHome does not exist in the system.  Check that the
>> app was successfully deployed.
>>         at
>> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
>>         at javax.naming.InitialContext.lookup(Unknown Source)
>>         at apachegclient.TestClient.main(TestClient.java:43)
>> 
>> 
>> I would say my first experiences with Genonimo is frustrated because I
>> just spent a whole day on a very simple task. Anyway, if you have the
>> sample code (both the ejb and the ejb client) that works with geronimo
>> v2, please send it to my email address.
>> 
>> Thanks,
>> Chris
>> 
>> 
>> 
>> Mark Aufdencamp wrote:
>>> 
>>> Hi Chris, 
>>> 
>>> I'll give it a shot at helping you.  I've been able to do this thanks to
>>> much help from others on this list.
>>> 
>>> Are you truly doing this as a remote client from a different machine
>>> than the server?  If so, the IP addres your using for the naming
>>> provider should be the server address, rather than the local loopback
>>> address.
>>> 
>>> Do you have all of the required remote client libraries in the class
>>> path for the remote EJB call?  I can look back at my notes and provide
>>> these if you need them.
>>> 
>>> I believe the remote name will probably be proceeded by "ejb".  As in
>>> "ejb/MySessionRemoteHome".
>>> 
>>> I can dig up some code of my own that works if you'ld like.
>>> 
>>> Hope this helps some.
>>> 
>>> Mark Aufdencamp
>>> Mark@Aufdencamp.com
>>> 
>>>> -------- Original Message --------
>>>> Subject: jndi lookup in remote client for geronimo v2
>>>> From: Xiao-fei Song <xf...@yahoo.com>
>>>> Date: Fri, June 29, 2007 7:04 am
>>>> To: user@geronimo.apache.org
>>>> 
>>>> Hi guys,
>>>> 
>>>> I have developed an EJB 2.x stateless session using netbeans, and I
>>>> want to write a very simple stand alone ejb client to access it in
>>>> geronimo v2. The code looks like below:
>>>> 
>>>> 
>>>>         props.setProperty("java.naming.factory.initial",
>>>> "org.openejb.client.RemoteInitialContextFactory");
>>>>         props.setProperty("java.naming.provider.url",
>>>> "127.0.0.1:4201");
>>>>         //props.setProperty("java.naming.security.principal",
>>>> "testuser");
>>>>         //props.setProperty("java.naming.security.credentials",
>>>> "testpassword");
>>>>         
>>>>         Context ic = new InitialContext(props);
>>>>         System.out.println("ic = " + ic);
>>>>         
>>>>         Object objRef = ic.lookup("MySessionRemoteHome");
>>>> 
>>>> I read the documentation and it looks like the only way to lookup in
>>>> the remote client is through jndi-name in openejb-jar.xml. And I have
>>>> done that as below:
>>>> 
>>>> <?xml version="1.0"?>
>>>>   <openejb-jar
>>>>     xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
>>>>     xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
>>>>     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">    
>>>>    
>>>>    <enterprise-beans>
>>>>       <session>
>>>>         <ejb-name>MySessionBean</ejb-name>
>>>>         <jndi-name>MySessionRemoteHome</jndi-name>
>>>>       </session>
>>>>     </enterprise-beans>
>>>>   </openejb-jar>
>>>> 
>>>> After the ejb is deployed to geronimo, I ran the client and found
>>>> below error:
>>>> 
>>>> ic = javax.naming.InitialContext@1e51060
>>>> Exception in thread "main" javax.naming.NameNotFoundException:
>>>> /MySessionRemoteHome does not exist in the system.  Check that the app
>>>> was successfully deployed.
>>>>         at
>>>> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
>>>>         at javax.naming.InitialContext.lookup(Unknown Source)
>>>>         at apachegclient.TestClient.main(TestClient.java:43)
>>>> 
>>>> 
>>>> Anyone has any idea what's going on?
>>>> 
>>>> Thanks,
>>>> Chris
>>>> 
>>>>        
>>>> ---------------------------------
>>>> Ready for the edge of your seat? Check out tonight's top picks on
>>>> Yahoo! TV. 
>>>>  
>>>> ---------------------------------
>>>> Now that's room service! Choose from over 150,000 hotels 
>>>> in 45,000 destinations on Yahoo! Travel to find your fit.
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/jndi-lookup-in-remote-client-for-geronimo-v2-tf3999496s134.html#a12680611
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: jndi lookup in remote client for geronimo v2

Posted by David Blevins <db...@visi.com>.
On Sep 18, 2007, at 6:57 PM, vrm wrote:

>
> After alot of messing around, I found the answer to my problem. The  
> correct
> way to reference an EJB from an openejb-client is to use the  
> following =
>
> artifactid.jar/beanname/fullpathtointerface
>
> so in my case, inside the EAR was TheEJB.jar =
>
> TheEJB.jar/TheBean/com.mydomain.ejbtest.TheInterface
>
> That seemed to work. Not sure if its my error in setting up the  
> EAR, but
> using the ".jar" at the end solved the problem.

Great to hear it's working.

I think there may be a difference in the default artifactId for an  
ejb jar in an ear vs a standalone ejb jar.  I was chatting with David  
J. about this and we determined that the default artifactId for an  
ejb jar is the same regardless if it was in an ear or out... but it  
doesn't seem like this is the case.  It seems you clearly get  
MyEjbs.jar in an ear and MyEjbs (no .jar) out of an ear.

This is likely something we should fix.

-David

>
>
>
>
> vrm wrote:
>>
>> Thanks for the examples - Is there any difference between the Context
>> Lookup in an EJB-JAR vs an EAR ?
>>
>> I'm still getting a naming exception and I followed both the examples
>> exactly. Here are some files associated with my configuration =
>>
>> ---------------
>> If my geronimo-application.xml =
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <application
>> xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.2">
>> 	<environment xmlns="http://geronimo.apache.org/xml/ns/ 
>> deployment-1.2">
>>         <moduleId>
>>             <groupId>com.mydomain.ejbtest</groupId>
>>             <artifactId>EjbTest</artifactId>
>>             <version>1.0o</version>
>>             <type>ear</type>
>>         </moduleId>
>>     </environment>
>> </application>
>>
>> ---------------
>> openejb-jar.xml =
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
>> 	<environment xmlns="http://geronimo.apache.org/xml/ns/ 
>> deployment-1.2">
>> 		<moduleId>
>> 			<groupId>com.mydomain.ejbtest</groupId>
>> 			<artifactId>TheEJB</artifactId>
>> 			<version>1.1</version>
>> 			<type>car</type>
>> 		</moduleId>
>> 		<dependencies>
>>             <dependency>
>> 	            <groupId>com.mydomain.ejbtest</groupId>
>> 	            <artifactId>MyQueueConnectionFactory</artifactId>
>>             	<version>1.0</version>
>> 	            <type>rar</type>
>>         	</dependency>
>>             <dependency>
>>                 <groupId>com.mydomain.ejbtest</groupId>
>>                 <artifactId>MysqlDatabase</artifactId>
>>             	<version>1.0</version>
>> 	            <type>rar</type>
>>             </dependency>
>> 		</dependencies>
>> 		<hidden-classes/>
>> 		<non-overridable-classes/>
>> 	</environment>
>> </openejb-jar>
>>
>>
>> ---------------
>> The EJB Bean =
>>
>> @Stateless(name="TheBean")
>> @Remote(TheInterface.class)
>> public class TheBean implements TheInterface{
>>
>>
>> ---------------
>> The Interface =
>>
>> @Remote
>> public interface TheInterface {
>>
>>
>> ---------------
>> The Client =
>>
>> Properties ejbprop = new Properties();
>> ejbprop.put 
>> ("java.naming.factory.initial","org.apache.openejb.client.RemoteIniti 
>> alContextFactory");
>> ejbprop.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
>> javax.naming.InitialContext ctx = new
>> javax.naming.InitialContext(EJBprops);
>> TheInterface obj =
>> (TheInterface)ctx.lookup("TheEJB/TheBean/ 
>> com.mydomain.ejbtest.TheInterface");
>>
>>
>>
>> 				
>>
>> Jarek Gawor-2 wrote:
>>>
>>> I have some tests in Geronimo that might help.
>>>
>>> If you have a EJB 2.x take a look at:
>>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/ 
>>> webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/
>>>
>>> And for the client take a look at the testEJB() function in
>>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/ 
>>> webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/src/test/java/org/ 
>>> apache/geronimo/testsuite/testset/JaxRPCTest.java?view=markup
>>>
>>> If you have EJB 3.0 take a look at:
>>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/ 
>>> webservices-testsuite/jaxws-tests/jaxws-ejb/
>>>
>>> And for the client take a look at the testEJB() function in
>>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/ 
>>> webservices-testsuite/jaxws-tests/jaxws-ejb/src/test/java/org/ 
>>> apache/geronimo/testsuite/testset/JaxWSTest.java?view=markup
>>>
>>> Jarek
>>>
>>> On 9/14/07, vrm <vi...@hotmail.com> wrote:
>>>>
>>>> I'm having the exact same issue. I've spent 2 days looking  
>>>> around and
>>>> there
>>>> is no examples or documentations available for a Remote openejb  
>>>> client
>>>> accessing an EJB on Geronimo 2.
>>>>
>>>> Anybody have an EAR for Geronimo2 and an Openejb-Client app  
>>>> accessing
>>>> it?
>>>>
>>>> The Exception I get =
>>>> javax.naming.NameNotFoundException: /TheBean does not exist in the
>>>> system.
>>>> Check that the app was successfully deployed.
>>>>
>>>> I've tried the following for InitialContext.lookup =
>>>> (artifactid)/(TheBean)/(TheInterface)
>>>> (artifactid)/(Interface)
>>>> (ejbBean)/(Interface)
>>>> (artifactid)/(TheBean)/(Full Path to Interface)
>>>> ...and many more variations of this
>>>>
>>>>
>>>> My EJB Interface =
>>>>
>>>> @Remote
>>>> public interface TheInterface {
>>>>
>>>>
>>>> My Bean =
>>>> @Stateless
>>>> public class TheBean implements TheInterface {
>>>>
>>>>
>>>> Anybody get this to work or have examples, please post.
>>>>
>>>>
>>>>
>>>>
>>>> Xiao-fei Song wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> Just wanted to let you know I modified a little bit about the  
>>>>> code:
>>>>>
>>>>>         props.setProperty("java.naming.factory.initial",
>>>>> "org.apache.openejb.client.RemoteInitialContextFactory");
>>>>>         props.setProperty("java.naming.provider.url",
>>>> "127.0.0.1:4201");
>>>>>         props.setProperty("java.naming.security.principal",  
>>>>> "system");
>>>>>         props.setProperty("java.naming.security.credentials",
>>>> "manager");
>>>>>
>>>>>         Context ic = new InitialContext(props);
>>>>>         System.out.println("ic = " + ic);
>>>>>
>>>>>         Object objRef = ic.lookup("MySessionRemoteHome");
>>>>>         System.out.println("objRef = " + objRef);
>>>>>
>>>>>         test.abc.MySessionRemoteHome home =
>>>>> (test.abc.MySessionRemoteHome)PortableRemoteObject.narrow(objRef,
>>>>> test.abc.MySessionRemoteHome.class);
>>>>>         System.out.println("home = " + home);
>>>>>
>>>>>         test.abc.MySessionRemote remote = home.create();
>>>>>         System.out.println("remote = " + remote);
>>>>>
>>>>>         String message = remote.getString();
>>>>>         System.out.println("message = " + message);
>>>>>
>>>>>
>>>>> and it works okay on geronimo 1.2 beta. So this really makes me
>>>> confused,
>>>>> is this a regression or intended to be. Can someone in this alias
>>>> please
>>>>> respond me?
>>>>>
>>>>> Thanks,
>>>>> Chris
>>>>>
>>>>>
>>>>> Xiao-fei Song wrote:
>>>>>>
>>>>>> Hi Mark,
>>>>>>
>>>>>> Thanks for your response.
>>>>>>
>>>>>> 1. For the time being, I don't really care if the client is  
>>>>>> really
>>>>>> "remote". From my tests, it looks like only "127.0.0.1" is  
>>>>>> accepted
>>>>>> otherwise the connects just failed. I don't know where the
>>>> documentation
>>>>>> can be found on this.
>>>>>>
>>>>>> 2. Yes I assume all the libraries are there for the EJB call. And
>>>> they
>>>>>> are:
>>>>>>
>>>>>> cglig-nodep
>>>>>> geronimo-kernel
>>>>>> openejb-core
>>>>>> openejb-client
>>>>>> j2ee.jar (from j2ee ri)
>>>>>>
>>>>>> 3. Unfortunately it does not work with "ejb/ 
>>>>>> MySessionRemoteHome" and
>>>> here
>>>>>> is what I got:
>>>>>>
>>>>>> ic = javax.naming.InitialContext@1e51060
>>>>>> Exception in thread "main" javax.naming.NameNotFoundException:
>>>>>> /ejb/MySessionRemoteHome does not exist in the system.  Check  
>>>>>> that
>>>> the
>>>>>> app was successfully deployed.
>>>>>>         at
>>>>>> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java: 
>>>>>> 231)
>>>>>>         at javax.naming.InitialContext.lookup(Unknown Source)
>>>>>>         at apachegclient.TestClient.main(TestClient.java:43)
>>>>>>
>>>>>>
>>>>>> I would say my first experiences with Genonimo is frustrated  
>>>>>> because
>>>> I
>>>>>> just spent a whole day on a very simple task. Anyway, if you  
>>>>>> have the
>>>>>> sample code (both the ejb and the ejb client) that works with
>>>> geronimo
>>>>>> v2, please send it to my email address.
>>>>>>
>>>>>> Thanks,
>>>>>> Chris
>>>>>>
>>>>>>
>>>>>>
>>>>>> Mark Aufdencamp wrote:
>>>>>>>
>>>>>>> Hi Chris,
>>>>>>>
>>>>>>> I'll give it a shot at helping you.  I've been able to do this
>>>> thanks to
>>>>>>> much help from others on this list.
>>>>>>>
>>>>>>> Are you truly doing this as a remote client from a different  
>>>>>>> machine
>>>>>>> than the server?  If so, the IP addres your using for the naming
>>>>>>> provider should be the server address, rather than the local
>>>> loopback
>>>>>>> address.
>>>>>>>
>>>>>>> Do you have all of the required remote client libraries in  
>>>>>>> the class
>>>>>>> path for the remote EJB call?  I can look back at my notes and
>>>> provide
>>>>>>> these if you need them.
>>>>>>>
>>>>>>> I believe the remote name will probably be proceeded by  
>>>>>>> "ejb".  As
>>>> in
>>>>>>> "ejb/MySessionRemoteHome".
>>>>>>>
>>>>>>> I can dig up some code of my own that works if you'ld like.
>>>>>>>
>>>>>>> Hope this helps some.
>>>>>>>
>>>>>>> Mark Aufdencamp
>>>>>>> Mark@Aufdencamp.com
>>>>>>>
>>>>>>>> -------- Original Message --------
>>>>>>>> Subject: jndi lookup in remote client for geronimo v2
>>>>>>>> From: Xiao-fei Song <xf...@yahoo.com>
>>>>>>>> Date: Fri, June 29, 2007 7:04 am
>>>>>>>> To: user@geronimo.apache.org
>>>>>>>>
>>>>>>>> Hi guys,
>>>>>>>>
>>>>>>>> I have developed an EJB 2.x stateless session using  
>>>>>>>> netbeans, and I
>>>>>>>> want to write a very simple stand alone ejb client to access  
>>>>>>>> it in
>>>>>>>> geronimo v2. The code looks like below:
>>>>>>>>
>>>>>>>>
>>>>>>>>         props.setProperty("java.naming.factory.initial",
>>>>>>>> "org.openejb.client.RemoteInitialContextFactory");
>>>>>>>>         props.setProperty("java.naming.provider.url",
>>>>>>>> "127.0.0.1:4201");
>>>>>>>>         //props.setProperty("java.naming.security.principal",
>>>>>>>> "testuser");
>>>>>>>>         //props.setProperty("java.naming.security.credentials",
>>>>>>>> "testpassword");
>>>>>>>>
>>>>>>>>         Context ic = new InitialContext(props);
>>>>>>>>         System.out.println("ic = " + ic);
>>>>>>>>
>>>>>>>>         Object objRef = ic.lookup("MySessionRemoteHome");
>>>>>>>>
>>>>>>>> I read the documentation and it looks like the only way to  
>>>>>>>> lookup
>>>> in
>>>>>>>> the remote client is through jndi-name in openejb-jar.xml.  
>>>>>>>> And I
>>>> have
>>>>>>>> done that as below:
>>>>>>>>
>>>>>>>> <?xml version="1.0"?>
>>>>>>>>   <openejb-jar
>>>>>>>>     xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
>>>>>>>>     xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
>>>>>>>>     xmlns:sys="http://geronimo.apache.org/xml/ns/ 
>>>>>>>> deployment-1.2">
>>>>>>>>
>>>>>>>>    <enterprise-beans>
>>>>>>>>       <session>
>>>>>>>>         <ejb-name>MySessionBean</ejb-name>
>>>>>>>>         <jndi-name>MySessionRemoteHome</jndi-name>
>>>>>>>>       </session>
>>>>>>>>     </enterprise-beans>
>>>>>>>>   </openejb-jar>
>>>>>>>>
>>>>>>>> After the ejb is deployed to geronimo, I ran the client and  
>>>>>>>> found
>>>>>>>> below error:
>>>>>>>>
>>>>>>>> ic = javax.naming.InitialContext@1e51060
>>>>>>>> Exception in thread "main" javax.naming.NameNotFoundException:
>>>>>>>> /MySessionRemoteHome does not exist in the system.  Check  
>>>>>>>> that the
>>>> app
>>>>>>>> was successfully deployed.
>>>>>>>>         at
>>>>>>>> org.apache.openejb.client.JNDIContext.lookup 
>>>>>>>> (JNDIContext.java:231)
>>>>>>>>         at javax.naming.InitialContext.lookup(Unknown Source)
>>>>>>>>         at apachegclient.TestClient.main(TestClient.java:43)
>>>>>>>>
>>>>>>>>
>>>>>>>> Anyone has any idea what's going on?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Chris
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------
>>>>>>>> Ready for the edge of your seat? Check out tonight's top  
>>>>>>>> picks on
>>>>>>>> Yahoo! TV.
>>>>>>>>
>>>>>>>> ---------------------------------
>>>>>>>> Now that's room service! Choose from over 150,000 hotels
>>>>>>>> in 45,000 destinations on Yahoo! Travel to find your fit.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/jndi-lookup-in-remote-client-for-geronimo- 
>>>> v2-tf3999496s134.html#a12680611
>>>> Sent from the Apache Geronimo - Users mailing list archive at
>>>> Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/jndi-lookup-in- 
> remote-client-for-geronimo-v2-tf3999496s134.html#a12769437
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>
>


Re: jndi lookup in remote client for geronimo v2

Posted by vrm <vi...@gmail.com>.
After alot of messing around, I found the answer to my problem. The correct
way to reference an EJB from an openejb-client is to use the following =

artifactid.jar/beanname/fullpathtointerface

so in my case, inside the EAR was TheEJB.jar =

TheEJB.jar/TheBean/com.mydomain.ejbtest.TheInterface

That seemed to work. Not sure if its my error in setting up the EAR, but
using the ".jar" at the end solved the problem.




vrm wrote:
> 
> Thanks for the examples - Is there any difference between the Context
> Lookup in an EJB-JAR vs an EAR ?
> 
> I'm still getting a naming exception and I followed both the examples
> exactly. Here are some files associated with my configuration =
> 
> ---------------
> If my geronimo-application.xml =
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <application
> xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.2">
> 	<environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
>         <moduleId>
>             <groupId>com.mydomain.ejbtest</groupId>
>             <artifactId>EjbTest</artifactId>
>             <version>1.0o</version>
>             <type>ear</type>
>         </moduleId>
>     </environment>
> </application>
> 
> ---------------
> openejb-jar.xml =
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
> 	<environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
> 		<moduleId>
> 			<groupId>com.mydomain.ejbtest</groupId>
> 			<artifactId>TheEJB</artifactId>
> 			<version>1.1</version>
> 			<type>car</type>
> 		</moduleId>
> 		<dependencies>
>             <dependency>
> 	            <groupId>com.mydomain.ejbtest</groupId>
> 	            <artifactId>MyQueueConnectionFactory</artifactId>
>             	<version>1.0</version>
> 	            <type>rar</type>
>         	</dependency>
>             <dependency>
>                 <groupId>com.mydomain.ejbtest</groupId>
>                 <artifactId>MysqlDatabase</artifactId>
>             	<version>1.0</version>
> 	            <type>rar</type>
>             </dependency>
> 		</dependencies>
> 		<hidden-classes/>
> 		<non-overridable-classes/>
> 	</environment>
> </openejb-jar>
> 
> 
> ---------------
> The EJB Bean =
> 
> @Stateless(name="TheBean")
> @Remote(TheInterface.class)
> public class TheBean implements TheInterface{
> 
> 
> ---------------
> The Interface =
> 
> @Remote
> public interface TheInterface {
> 
> 
> ---------------
> The Client =
> 
> Properties ejbprop = new Properties();
> ejbprop.put("java.naming.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory");
> ejbprop.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
> javax.naming.InitialContext ctx = new
> javax.naming.InitialContext(EJBprops);
> TheInterface obj =
> (TheInterface)ctx.lookup("TheEJB/TheBean/com.mydomain.ejbtest.TheInterface");
> 
> 
> 
> 				
> 
> Jarek Gawor-2 wrote:
>> 
>> I have some tests in Geronimo that might help.
>> 
>> If you have a EJB 2.x take a look at:
>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/
>> 
>> And for the client take a look at the testEJB() function in
>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/src/test/java/org/apache/geronimo/testsuite/testset/JaxRPCTest.java?view=markup
>> 
>> If you have EJB 3.0 take a look at:
>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-ejb/
>> 
>> And for the client take a look at the testEJB() function in
>> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-ejb/src/test/java/org/apache/geronimo/testsuite/testset/JaxWSTest.java?view=markup
>> 
>> Jarek
>> 
>> On 9/14/07, vrm <vi...@hotmail.com> wrote:
>>>
>>> I'm having the exact same issue. I've spent 2 days looking around and
>>> there
>>> is no examples or documentations available for a Remote openejb client
>>> accessing an EJB on Geronimo 2.
>>>
>>> Anybody have an EAR for Geronimo2 and an Openejb-Client app accessing
>>> it?
>>>
>>> The Exception I get =
>>> javax.naming.NameNotFoundException: /TheBean does not exist in the
>>> system.
>>> Check that the app was successfully deployed.
>>>
>>> I've tried the following for InitialContext.lookup =
>>> (artifactid)/(TheBean)/(TheInterface)
>>> (artifactid)/(Interface)
>>> (ejbBean)/(Interface)
>>> (artifactid)/(TheBean)/(Full Path to Interface)
>>> ...and many more variations of this
>>>
>>>
>>> My EJB Interface =
>>>
>>> @Remote
>>> public interface TheInterface {
>>>
>>>
>>> My Bean =
>>> @Stateless
>>> public class TheBean implements TheInterface {
>>>
>>>
>>> Anybody get this to work or have examples, please post.
>>>
>>>
>>>
>>>
>>> Xiao-fei Song wrote:
>>> >
>>> > Hi,
>>> >
>>> > Just wanted to let you know I modified a little bit about the code:
>>> >
>>> >         props.setProperty("java.naming.factory.initial",
>>> > "org.apache.openejb.client.RemoteInitialContextFactory");
>>> >         props.setProperty("java.naming.provider.url",
>>> "127.0.0.1:4201");
>>> >         props.setProperty("java.naming.security.principal", "system");
>>> >         props.setProperty("java.naming.security.credentials",
>>> "manager");
>>> >
>>> >         Context ic = new InitialContext(props);
>>> >         System.out.println("ic = " + ic);
>>> >
>>> >         Object objRef = ic.lookup("MySessionRemoteHome");
>>> >         System.out.println("objRef = " + objRef);
>>> >
>>> >         test.abc.MySessionRemoteHome home =
>>> > (test.abc.MySessionRemoteHome)PortableRemoteObject.narrow(objRef,
>>> > test.abc.MySessionRemoteHome.class);
>>> >         System.out.println("home = " + home);
>>> >
>>> >         test.abc.MySessionRemote remote = home.create();
>>> >         System.out.println("remote = " + remote);
>>> >
>>> >         String message = remote.getString();
>>> >         System.out.println("message = " + message);
>>> >
>>> >
>>> > and it works okay on geronimo 1.2 beta. So this really makes me
>>> confused,
>>> > is this a regression or intended to be. Can someone in this alias
>>> please
>>> > respond me?
>>> >
>>> > Thanks,
>>> > Chris
>>> >
>>> >
>>> > Xiao-fei Song wrote:
>>> >>
>>> >> Hi Mark,
>>> >>
>>> >> Thanks for your response.
>>> >>
>>> >> 1. For the time being, I don't really care if the client is really
>>> >> "remote". From my tests, it looks like only "127.0.0.1" is accepted
>>> >> otherwise the connects just failed. I don't know where the
>>> documentation
>>> >> can be found on this.
>>> >>
>>> >> 2. Yes I assume all the libraries are there for the EJB call. And
>>> they
>>> >> are:
>>> >>
>>> >> cglig-nodep
>>> >> geronimo-kernel
>>> >> openejb-core
>>> >> openejb-client
>>> >> j2ee.jar (from j2ee ri)
>>> >>
>>> >> 3. Unfortunately it does not work with "ejb/MySessionRemoteHome" and
>>> here
>>> >> is what I got:
>>> >>
>>> >> ic = javax.naming.InitialContext@1e51060
>>> >> Exception in thread "main" javax.naming.NameNotFoundException:
>>> >> /ejb/MySessionRemoteHome does not exist in the system.  Check that
>>> the
>>> >> app was successfully deployed.
>>> >>         at
>>> >> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
>>> >>         at javax.naming.InitialContext.lookup(Unknown Source)
>>> >>         at apachegclient.TestClient.main(TestClient.java:43)
>>> >>
>>> >>
>>> >> I would say my first experiences with Genonimo is frustrated because
>>> I
>>> >> just spent a whole day on a very simple task. Anyway, if you have the
>>> >> sample code (both the ejb and the ejb client) that works with
>>> geronimo
>>> >> v2, please send it to my email address.
>>> >>
>>> >> Thanks,
>>> >> Chris
>>> >>
>>> >>
>>> >>
>>> >> Mark Aufdencamp wrote:
>>> >>>
>>> >>> Hi Chris,
>>> >>>
>>> >>> I'll give it a shot at helping you.  I've been able to do this
>>> thanks to
>>> >>> much help from others on this list.
>>> >>>
>>> >>> Are you truly doing this as a remote client from a different machine
>>> >>> than the server?  If so, the IP addres your using for the naming
>>> >>> provider should be the server address, rather than the local
>>> loopback
>>> >>> address.
>>> >>>
>>> >>> Do you have all of the required remote client libraries in the class
>>> >>> path for the remote EJB call?  I can look back at my notes and
>>> provide
>>> >>> these if you need them.
>>> >>>
>>> >>> I believe the remote name will probably be proceeded by "ejb".  As
>>> in
>>> >>> "ejb/MySessionRemoteHome".
>>> >>>
>>> >>> I can dig up some code of my own that works if you'ld like.
>>> >>>
>>> >>> Hope this helps some.
>>> >>>
>>> >>> Mark Aufdencamp
>>> >>> Mark@Aufdencamp.com
>>> >>>
>>> >>>> -------- Original Message --------
>>> >>>> Subject: jndi lookup in remote client for geronimo v2
>>> >>>> From: Xiao-fei Song <xf...@yahoo.com>
>>> >>>> Date: Fri, June 29, 2007 7:04 am
>>> >>>> To: user@geronimo.apache.org
>>> >>>>
>>> >>>> Hi guys,
>>> >>>>
>>> >>>> I have developed an EJB 2.x stateless session using netbeans, and I
>>> >>>> want to write a very simple stand alone ejb client to access it in
>>> >>>> geronimo v2. The code looks like below:
>>> >>>>
>>> >>>>
>>> >>>>         props.setProperty("java.naming.factory.initial",
>>> >>>> "org.openejb.client.RemoteInitialContextFactory");
>>> >>>>         props.setProperty("java.naming.provider.url",
>>> >>>> "127.0.0.1:4201");
>>> >>>>         //props.setProperty("java.naming.security.principal",
>>> >>>> "testuser");
>>> >>>>         //props.setProperty("java.naming.security.credentials",
>>> >>>> "testpassword");
>>> >>>>
>>> >>>>         Context ic = new InitialContext(props);
>>> >>>>         System.out.println("ic = " + ic);
>>> >>>>
>>> >>>>         Object objRef = ic.lookup("MySessionRemoteHome");
>>> >>>>
>>> >>>> I read the documentation and it looks like the only way to lookup
>>> in
>>> >>>> the remote client is through jndi-name in openejb-jar.xml. And I
>>> have
>>> >>>> done that as below:
>>> >>>>
>>> >>>> <?xml version="1.0"?>
>>> >>>>   <openejb-jar
>>> >>>>     xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
>>> >>>>     xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
>>> >>>>     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
>>> >>>>
>>> >>>>    <enterprise-beans>
>>> >>>>       <session>
>>> >>>>         <ejb-name>MySessionBean</ejb-name>
>>> >>>>         <jndi-name>MySessionRemoteHome</jndi-name>
>>> >>>>       </session>
>>> >>>>     </enterprise-beans>
>>> >>>>   </openejb-jar>
>>> >>>>
>>> >>>> After the ejb is deployed to geronimo, I ran the client and found
>>> >>>> below error:
>>> >>>>
>>> >>>> ic = javax.naming.InitialContext@1e51060
>>> >>>> Exception in thread "main" javax.naming.NameNotFoundException:
>>> >>>> /MySessionRemoteHome does not exist in the system.  Check that the
>>> app
>>> >>>> was successfully deployed.
>>> >>>>         at
>>> >>>> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
>>> >>>>         at javax.naming.InitialContext.lookup(Unknown Source)
>>> >>>>         at apachegclient.TestClient.main(TestClient.java:43)
>>> >>>>
>>> >>>>
>>> >>>> Anyone has any idea what's going on?
>>> >>>>
>>> >>>> Thanks,
>>> >>>> Chris
>>> >>>>
>>> >>>>
>>> >>>> ---------------------------------
>>> >>>> Ready for the edge of your seat? Check out tonight's top picks on
>>> >>>> Yahoo! TV.
>>> >>>>
>>> >>>> ---------------------------------
>>> >>>> Now that's room service! Choose from over 150,000 hotels
>>> >>>> in 45,000 destinations on Yahoo! Travel to find your fit.
>>> >>>
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/jndi-lookup-in-remote-client-for-geronimo-v2-tf3999496s134.html#a12680611
>>> Sent from the Apache Geronimo - Users mailing list archive at
>>> Nabble.com.
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/jndi-lookup-in-remote-client-for-geronimo-v2-tf3999496s134.html#a12769437
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: jndi lookup in remote client for geronimo v2

Posted by vrm <vi...@gmail.com>.
Thanks for the examples - Is there any difference between the Context Lookup
in an EJB-JAR vs an EAR ?

I'm still getting a naming exception and I followed both the examples
exactly. Here are some files associated with my configuration =

---------------
If my geronimo-application.xml =

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.2">
	<environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
        <moduleId>
            <groupId>com.mydomain.ejbtest</groupId>
            <artifactId>EjbTest</artifactId>
            <version>1.0o</version>
            <type>ear</type>
        </moduleId>
    </environment>
</application>

---------------
openejb-jar.xml =

<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
	<environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
		<moduleId>
			<groupId>com.mydomain.ejbtest</groupId>
			<artifactId>TheEJB</artifactId>
			<version>1.1</version>
			<type>car</type>
		</moduleId>
		<dependencies>
            <dependency>
	            <groupId>com.mydomain.ejbtest</groupId>
	            <artifactId>MyQueueConnectionFactory</artifactId>
            	<version>1.0</version>
	            <type>rar</type>
        	</dependency>
            <dependency>
                <groupId>com.mydomain.ejbtest</groupId>
                <artifactId>MysqlDatabase</artifactId>
            	<version>1.0</version>
	            <type>rar</type>
            </dependency>
		</dependencies>
		<hidden-classes/>
		<non-overridable-classes/>
	</environment>
</openejb-jar>


---------------
The EJB Bean =

@Stateless(name="TheBean")
@Remote(TheInterface.class)
public class TheBean implements TheInterface{


---------------
The Interface =

@Remote
public interface TheInterface {


---------------
The Client =

Properties ejbprop = new Properties();
ejbprop.put("java.naming.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory");
ejbprop.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
javax.naming.InitialContext ctx = new javax.naming.InitialContext(EJBprops);
TheInterface obj =
(TheInterface)ctx.lookup("TheEJB/TheBean/com.mydomain.ejbtest.TheInterface");



				

Jarek Gawor-2 wrote:
> 
> I have some tests in Geronimo that might help.
> 
> If you have a EJB 2.x take a look at:
> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/
> 
> And for the client take a look at the testEJB() function in
> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/src/test/java/org/apache/geronimo/testsuite/testset/JaxRPCTest.java?view=markup
> 
> If you have EJB 3.0 take a look at:
> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-ejb/
> 
> And for the client take a look at the testEJB() function in
> http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-ejb/src/test/java/org/apache/geronimo/testsuite/testset/JaxWSTest.java?view=markup
> 
> Jarek
> 
> On 9/14/07, vrm <vi...@hotmail.com> wrote:
>>
>> I'm having the exact same issue. I've spent 2 days looking around and
>> there
>> is no examples or documentations available for a Remote openejb client
>> accessing an EJB on Geronimo 2.
>>
>> Anybody have an EAR for Geronimo2 and an Openejb-Client app accessing it?
>>
>> The Exception I get =
>> javax.naming.NameNotFoundException: /TheBean does not exist in the
>> system.
>> Check that the app was successfully deployed.
>>
>> I've tried the following for InitialContext.lookup =
>> (artifactid)/(TheBean)/(TheInterface)
>> (artifactid)/(Interface)
>> (ejbBean)/(Interface)
>> (artifactid)/(TheBean)/(Full Path to Interface)
>> ...and many more variations of this
>>
>>
>> My EJB Interface =
>>
>> @Remote
>> public interface TheInterface {
>>
>>
>> My Bean =
>> @Stateless
>> public class TheBean implements TheInterface {
>>
>>
>> Anybody get this to work or have examples, please post.
>>
>>
>>
>>
>> Xiao-fei Song wrote:
>> >
>> > Hi,
>> >
>> > Just wanted to let you know I modified a little bit about the code:
>> >
>> >         props.setProperty("java.naming.factory.initial",
>> > "org.apache.openejb.client.RemoteInitialContextFactory");
>> >         props.setProperty("java.naming.provider.url",
>> "127.0.0.1:4201");
>> >         props.setProperty("java.naming.security.principal", "system");
>> >         props.setProperty("java.naming.security.credentials",
>> "manager");
>> >
>> >         Context ic = new InitialContext(props);
>> >         System.out.println("ic = " + ic);
>> >
>> >         Object objRef = ic.lookup("MySessionRemoteHome");
>> >         System.out.println("objRef = " + objRef);
>> >
>> >         test.abc.MySessionRemoteHome home =
>> > (test.abc.MySessionRemoteHome)PortableRemoteObject.narrow(objRef,
>> > test.abc.MySessionRemoteHome.class);
>> >         System.out.println("home = " + home);
>> >
>> >         test.abc.MySessionRemote remote = home.create();
>> >         System.out.println("remote = " + remote);
>> >
>> >         String message = remote.getString();
>> >         System.out.println("message = " + message);
>> >
>> >
>> > and it works okay on geronimo 1.2 beta. So this really makes me
>> confused,
>> > is this a regression or intended to be. Can someone in this alias
>> please
>> > respond me?
>> >
>> > Thanks,
>> > Chris
>> >
>> >
>> > Xiao-fei Song wrote:
>> >>
>> >> Hi Mark,
>> >>
>> >> Thanks for your response.
>> >>
>> >> 1. For the time being, I don't really care if the client is really
>> >> "remote". From my tests, it looks like only "127.0.0.1" is accepted
>> >> otherwise the connects just failed. I don't know where the
>> documentation
>> >> can be found on this.
>> >>
>> >> 2. Yes I assume all the libraries are there for the EJB call. And they
>> >> are:
>> >>
>> >> cglig-nodep
>> >> geronimo-kernel
>> >> openejb-core
>> >> openejb-client
>> >> j2ee.jar (from j2ee ri)
>> >>
>> >> 3. Unfortunately it does not work with "ejb/MySessionRemoteHome" and
>> here
>> >> is what I got:
>> >>
>> >> ic = javax.naming.InitialContext@1e51060
>> >> Exception in thread "main" javax.naming.NameNotFoundException:
>> >> /ejb/MySessionRemoteHome does not exist in the system.  Check that the
>> >> app was successfully deployed.
>> >>         at
>> >> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
>> >>         at javax.naming.InitialContext.lookup(Unknown Source)
>> >>         at apachegclient.TestClient.main(TestClient.java:43)
>> >>
>> >>
>> >> I would say my first experiences with Genonimo is frustrated because I
>> >> just spent a whole day on a very simple task. Anyway, if you have the
>> >> sample code (both the ejb and the ejb client) that works with geronimo
>> >> v2, please send it to my email address.
>> >>
>> >> Thanks,
>> >> Chris
>> >>
>> >>
>> >>
>> >> Mark Aufdencamp wrote:
>> >>>
>> >>> Hi Chris,
>> >>>
>> >>> I'll give it a shot at helping you.  I've been able to do this thanks
>> to
>> >>> much help from others on this list.
>> >>>
>> >>> Are you truly doing this as a remote client from a different machine
>> >>> than the server?  If so, the IP addres your using for the naming
>> >>> provider should be the server address, rather than the local loopback
>> >>> address.
>> >>>
>> >>> Do you have all of the required remote client libraries in the class
>> >>> path for the remote EJB call?  I can look back at my notes and
>> provide
>> >>> these if you need them.
>> >>>
>> >>> I believe the remote name will probably be proceeded by "ejb".  As in
>> >>> "ejb/MySessionRemoteHome".
>> >>>
>> >>> I can dig up some code of my own that works if you'ld like.
>> >>>
>> >>> Hope this helps some.
>> >>>
>> >>> Mark Aufdencamp
>> >>> Mark@Aufdencamp.com
>> >>>
>> >>>> -------- Original Message --------
>> >>>> Subject: jndi lookup in remote client for geronimo v2
>> >>>> From: Xiao-fei Song <xf...@yahoo.com>
>> >>>> Date: Fri, June 29, 2007 7:04 am
>> >>>> To: user@geronimo.apache.org
>> >>>>
>> >>>> Hi guys,
>> >>>>
>> >>>> I have developed an EJB 2.x stateless session using netbeans, and I
>> >>>> want to write a very simple stand alone ejb client to access it in
>> >>>> geronimo v2. The code looks like below:
>> >>>>
>> >>>>
>> >>>>         props.setProperty("java.naming.factory.initial",
>> >>>> "org.openejb.client.RemoteInitialContextFactory");
>> >>>>         props.setProperty("java.naming.provider.url",
>> >>>> "127.0.0.1:4201");
>> >>>>         //props.setProperty("java.naming.security.principal",
>> >>>> "testuser");
>> >>>>         //props.setProperty("java.naming.security.credentials",
>> >>>> "testpassword");
>> >>>>
>> >>>>         Context ic = new InitialContext(props);
>> >>>>         System.out.println("ic = " + ic);
>> >>>>
>> >>>>         Object objRef = ic.lookup("MySessionRemoteHome");
>> >>>>
>> >>>> I read the documentation and it looks like the only way to lookup in
>> >>>> the remote client is through jndi-name in openejb-jar.xml. And I
>> have
>> >>>> done that as below:
>> >>>>
>> >>>> <?xml version="1.0"?>
>> >>>>   <openejb-jar
>> >>>>     xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
>> >>>>     xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
>> >>>>     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
>> >>>>
>> >>>>    <enterprise-beans>
>> >>>>       <session>
>> >>>>         <ejb-name>MySessionBean</ejb-name>
>> >>>>         <jndi-name>MySessionRemoteHome</jndi-name>
>> >>>>       </session>
>> >>>>     </enterprise-beans>
>> >>>>   </openejb-jar>
>> >>>>
>> >>>> After the ejb is deployed to geronimo, I ran the client and found
>> >>>> below error:
>> >>>>
>> >>>> ic = javax.naming.InitialContext@1e51060
>> >>>> Exception in thread "main" javax.naming.NameNotFoundException:
>> >>>> /MySessionRemoteHome does not exist in the system.  Check that the
>> app
>> >>>> was successfully deployed.
>> >>>>         at
>> >>>> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
>> >>>>         at javax.naming.InitialContext.lookup(Unknown Source)
>> >>>>         at apachegclient.TestClient.main(TestClient.java:43)
>> >>>>
>> >>>>
>> >>>> Anyone has any idea what's going on?
>> >>>>
>> >>>> Thanks,
>> >>>> Chris
>> >>>>
>> >>>>
>> >>>> ---------------------------------
>> >>>> Ready for the edge of your seat? Check out tonight's top picks on
>> >>>> Yahoo! TV.
>> >>>>
>> >>>> ---------------------------------
>> >>>> Now that's room service! Choose from over 150,000 hotels
>> >>>> in 45,000 destinations on Yahoo! Travel to find your fit.
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/jndi-lookup-in-remote-client-for-geronimo-v2-tf3999496s134.html#a12680611
>> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/jndi-lookup-in-remote-client-for-geronimo-v2-tf3999496s134.html#a12682887
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: jndi lookup in remote client for geronimo v2

Posted by Jarek Gawor <jg...@gmail.com>.
I have some tests in Geronimo that might help.

If you have a EJB 2.x take a look at:
http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/

And for the client take a look at the testEJB() function in
http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxrpc-tests/jaxrpc-ejb/src/test/java/org/apache/geronimo/testsuite/testset/JaxRPCTest.java?view=markup

If you have EJB 3.0 take a look at:
http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-ejb/

And for the client take a look at the testEJB() function in
http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-ejb/src/test/java/org/apache/geronimo/testsuite/testset/JaxWSTest.java?view=markup

Jarek

On 9/14/07, vrm <vi...@hotmail.com> wrote:
>
> I'm having the exact same issue. I've spent 2 days looking around and there
> is no examples or documentations available for a Remote openejb client
> accessing an EJB on Geronimo 2.
>
> Anybody have an EAR for Geronimo2 and an Openejb-Client app accessing it?
>
> The Exception I get =
> javax.naming.NameNotFoundException: /TheBean does not exist in the system.
> Check that the app was successfully deployed.
>
> I've tried the following for InitialContext.lookup =
> (artifactid)/(TheBean)/(TheInterface)
> (artifactid)/(Interface)
> (ejbBean)/(Interface)
> (artifactid)/(TheBean)/(Full Path to Interface)
> ...and many more variations of this
>
>
> My EJB Interface =
>
> @Remote
> public interface TheInterface {
>
>
> My Bean =
> @Stateless
> public class TheBean implements TheInterface {
>
>
> Anybody get this to work or have examples, please post.
>
>
>
>
> Xiao-fei Song wrote:
> >
> > Hi,
> >
> > Just wanted to let you know I modified a little bit about the code:
> >
> >         props.setProperty("java.naming.factory.initial",
> > "org.apache.openejb.client.RemoteInitialContextFactory");
> >         props.setProperty("java.naming.provider.url", "127.0.0.1:4201");
> >         props.setProperty("java.naming.security.principal", "system");
> >         props.setProperty("java.naming.security.credentials", "manager");
> >
> >         Context ic = new InitialContext(props);
> >         System.out.println("ic = " + ic);
> >
> >         Object objRef = ic.lookup("MySessionRemoteHome");
> >         System.out.println("objRef = " + objRef);
> >
> >         test.abc.MySessionRemoteHome home =
> > (test.abc.MySessionRemoteHome)PortableRemoteObject.narrow(objRef,
> > test.abc.MySessionRemoteHome.class);
> >         System.out.println("home = " + home);
> >
> >         test.abc.MySessionRemote remote = home.create();
> >         System.out.println("remote = " + remote);
> >
> >         String message = remote.getString();
> >         System.out.println("message = " + message);
> >
> >
> > and it works okay on geronimo 1.2 beta. So this really makes me confused,
> > is this a regression or intended to be. Can someone in this alias please
> > respond me?
> >
> > Thanks,
> > Chris
> >
> >
> > Xiao-fei Song wrote:
> >>
> >> Hi Mark,
> >>
> >> Thanks for your response.
> >>
> >> 1. For the time being, I don't really care if the client is really
> >> "remote". From my tests, it looks like only "127.0.0.1" is accepted
> >> otherwise the connects just failed. I don't know where the documentation
> >> can be found on this.
> >>
> >> 2. Yes I assume all the libraries are there for the EJB call. And they
> >> are:
> >>
> >> cglig-nodep
> >> geronimo-kernel
> >> openejb-core
> >> openejb-client
> >> j2ee.jar (from j2ee ri)
> >>
> >> 3. Unfortunately it does not work with "ejb/MySessionRemoteHome" and here
> >> is what I got:
> >>
> >> ic = javax.naming.InitialContext@1e51060
> >> Exception in thread "main" javax.naming.NameNotFoundException:
> >> /ejb/MySessionRemoteHome does not exist in the system.  Check that the
> >> app was successfully deployed.
> >>         at
> >> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
> >>         at javax.naming.InitialContext.lookup(Unknown Source)
> >>         at apachegclient.TestClient.main(TestClient.java:43)
> >>
> >>
> >> I would say my first experiences with Genonimo is frustrated because I
> >> just spent a whole day on a very simple task. Anyway, if you have the
> >> sample code (both the ejb and the ejb client) that works with geronimo
> >> v2, please send it to my email address.
> >>
> >> Thanks,
> >> Chris
> >>
> >>
> >>
> >> Mark Aufdencamp wrote:
> >>>
> >>> Hi Chris,
> >>>
> >>> I'll give it a shot at helping you.  I've been able to do this thanks to
> >>> much help from others on this list.
> >>>
> >>> Are you truly doing this as a remote client from a different machine
> >>> than the server?  If so, the IP addres your using for the naming
> >>> provider should be the server address, rather than the local loopback
> >>> address.
> >>>
> >>> Do you have all of the required remote client libraries in the class
> >>> path for the remote EJB call?  I can look back at my notes and provide
> >>> these if you need them.
> >>>
> >>> I believe the remote name will probably be proceeded by "ejb".  As in
> >>> "ejb/MySessionRemoteHome".
> >>>
> >>> I can dig up some code of my own that works if you'ld like.
> >>>
> >>> Hope this helps some.
> >>>
> >>> Mark Aufdencamp
> >>> Mark@Aufdencamp.com
> >>>
> >>>> -------- Original Message --------
> >>>> Subject: jndi lookup in remote client for geronimo v2
> >>>> From: Xiao-fei Song <xf...@yahoo.com>
> >>>> Date: Fri, June 29, 2007 7:04 am
> >>>> To: user@geronimo.apache.org
> >>>>
> >>>> Hi guys,
> >>>>
> >>>> I have developed an EJB 2.x stateless session using netbeans, and I
> >>>> want to write a very simple stand alone ejb client to access it in
> >>>> geronimo v2. The code looks like below:
> >>>>
> >>>>
> >>>>         props.setProperty("java.naming.factory.initial",
> >>>> "org.openejb.client.RemoteInitialContextFactory");
> >>>>         props.setProperty("java.naming.provider.url",
> >>>> "127.0.0.1:4201");
> >>>>         //props.setProperty("java.naming.security.principal",
> >>>> "testuser");
> >>>>         //props.setProperty("java.naming.security.credentials",
> >>>> "testpassword");
> >>>>
> >>>>         Context ic = new InitialContext(props);
> >>>>         System.out.println("ic = " + ic);
> >>>>
> >>>>         Object objRef = ic.lookup("MySessionRemoteHome");
> >>>>
> >>>> I read the documentation and it looks like the only way to lookup in
> >>>> the remote client is through jndi-name in openejb-jar.xml. And I have
> >>>> done that as below:
> >>>>
> >>>> <?xml version="1.0"?>
> >>>>   <openejb-jar
> >>>>     xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
> >>>>     xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
> >>>>     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
> >>>>
> >>>>    <enterprise-beans>
> >>>>       <session>
> >>>>         <ejb-name>MySessionBean</ejb-name>
> >>>>         <jndi-name>MySessionRemoteHome</jndi-name>
> >>>>       </session>
> >>>>     </enterprise-beans>
> >>>>   </openejb-jar>
> >>>>
> >>>> After the ejb is deployed to geronimo, I ran the client and found
> >>>> below error:
> >>>>
> >>>> ic = javax.naming.InitialContext@1e51060
> >>>> Exception in thread "main" javax.naming.NameNotFoundException:
> >>>> /MySessionRemoteHome does not exist in the system.  Check that the app
> >>>> was successfully deployed.
> >>>>         at
> >>>> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:231)
> >>>>         at javax.naming.InitialContext.lookup(Unknown Source)
> >>>>         at apachegclient.TestClient.main(TestClient.java:43)
> >>>>
> >>>>
> >>>> Anyone has any idea what's going on?
> >>>>
> >>>> Thanks,
> >>>> Chris
> >>>>
> >>>>
> >>>> ---------------------------------
> >>>> Ready for the edge of your seat? Check out tonight's top picks on
> >>>> Yahoo! TV.
> >>>>
> >>>> ---------------------------------
> >>>> Now that's room service! Choose from over 150,000 hotels
> >>>> in 45,000 destinations on Yahoo! Travel to find your fit.
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/jndi-lookup-in-remote-client-for-geronimo-v2-tf3999496s134.html#a12680611
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>

Re: jndi lookup in remote client for geronimo v2

Posted by David Blevins <da...@visi.com>.
On Sep 14, 2007, at 10:48 AM, vrm wrote:

>
> I'm having the exact same issue. I've spent 2 days looking around  
> and there
> is no examples or documentations available for a Remote openejb client
> accessing an EJB on Geronimo 2.
>
> Anybody have an EAR for Geronimo2 and an Openejb-Client app  
> accessing it?
>
> The Exception I get =
> javax.naming.NameNotFoundException: /TheBean does not exist in the  
> system.
> Check that the app was successfully deployed.
>
> I've tried the following for InitialContext.lookup =
> (artifactid)/(TheBean)/(TheInterface)
> (artifactid)/(Interface)
> (ejbBean)/(Interface)
> (artifactid)/(TheBean)/(Full Path to Interface)
> ...and many more variations of this
>
>
> My EJB Interface =
>
> @Remote
> public interface TheInterface {
>
>
> My Bean =
> @Stateless
> public class TheBean implements TheInterface {
>
>
> Anybody get this to work or have examples, please post.

I have an example here:

http://people.apache.org/~dblevins/tmp/examples/

Works in 2.0.1.  You deploy the prebuilt SimpleApp-1.0.jar, then you  
can run the EchoImplTest.java.

-David