You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by wanyna <wa...@hotmail.com> on 2007/09/21 11:47:05 UTC

ejb client jndi problem

I deploy ejb jar in geronimo2.0.1, this is a ejb2 test
http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar simple-ejb2-1.0.jar
, and this is a ejb3 test
http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar simple-ejb3-1.0.jar
.

Both of them deploy no error.

My client is a standalone application. Test code:
public class ClientTest {

	public static EchoRemote getEchoService(String url,
			String contextFactory) throws Exception {
		Context context = getInitialContext(contextFactory, url);
		Object obj = context.lookup("Echo");
		return (EchoRemote) obj;
	}

	public static CounterRemote getCounterService(String url,
			String contextFactory) throws Exception {
		Context context = getInitialContext(contextFactory, url);
		Object obj = context.lookup("SuperCounterBusinessRemote");
		return (CounterRemote) obj;
	}

	private static Context getInitialContext(String initContextFactory,
			String url) throws Exception {
		Properties properties = new Properties();
		properties.put(Context.INITIAL_CONTEXT_FACTORY, initContextFactory);
		properties.put(Context.PROVIDER_URL, url);

		return new InitialContext(properties);
	}
	
	public static void main(String[] args) throws Exception{
		String url = "ejbd://localhost:4201";
		String factory = "org.openejb.client.RemoteInitialContextFactory";
		EchoRemote echo = getEchoService(url, factory);
		assert("cba".equals(echo.echo("abc")));
//		CounterRemote counter = getCounterService(url, factory);
//		assert(counter.reset()==0);
//		assert(counter.increment()==1);
//		assert(counter.increment()==2);
//		assert(counter.reset()==0);
	}

}

exception:
Exception in thread "main" javax.naming.NameNotFoundException: /Echo does
not exist in the system.  Check that the app was successfully deployed.
	at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at test.ClientTest.getEchoService(ClientTest.java:17)
	at test.ClientTest.main(ClientTest.java:40)

What's the right jndi name?

I see some other messages talk about ejb jndi, but still can't resolve my
problem.

I deploy ejb2 test in geronimo 1.x, client lookup no problem. 
-- 
View this message in context: http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12813817
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: ejb client jndi problem

Posted by Lin Sun <li...@gmail.com>.
Hi,

David has put a sample out here that does pretty much what you want to do -

http://people.apache.org/~dblevins/tmp/examples/SimpleApp/src/test/java/org/apache/openejb/examples/counter/EchoImplTest.java

You might want to modify your code a bit and try again.   I was able to 
run the EchoImplTest on g 2.0.1.

Lin


wanyna wrote:
> I deploy ejb jar in geronimo2.0.1, this is a ejb2 test
> http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar simple-ejb2-1.0.jar
> , and this is a ejb3 test
> http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar simple-ejb3-1.0.jar
> .
> 
> Both of them deploy no error.
> 
> My client is a standalone application. Test code:
> public class ClientTest {
> 
> 	public static EchoRemote getEchoService(String url,
> 			String contextFactory) throws Exception {
> 		Context context = getInitialContext(contextFactory, url);
> 		Object obj = context.lookup("Echo");
> 		return (EchoRemote) obj;
> 	}
> 
> 	public static CounterRemote getCounterService(String url,
> 			String contextFactory) throws Exception {
> 		Context context = getInitialContext(contextFactory, url);
> 		Object obj = context.lookup("SuperCounterBusinessRemote");
> 		return (CounterRemote) obj;
> 	}
> 
> 	private static Context getInitialContext(String initContextFactory,
> 			String url) throws Exception {
> 		Properties properties = new Properties();
> 		properties.put(Context.INITIAL_CONTEXT_FACTORY, initContextFactory);
> 		properties.put(Context.PROVIDER_URL, url);
> 
> 		return new InitialContext(properties);
> 	}
> 	
> 	public static void main(String[] args) throws Exception{
> 		String url = "ejbd://localhost:4201";
> 		String factory = "org.openejb.client.RemoteInitialContextFactory";
> 		EchoRemote echo = getEchoService(url, factory);
> 		assert("cba".equals(echo.echo("abc")));
> //		CounterRemote counter = getCounterService(url, factory);
> //		assert(counter.reset()==0);
> //		assert(counter.increment()==1);
> //		assert(counter.increment()==2);
> //		assert(counter.reset()==0);
> 	}
> 
> }
> 
> exception:
> Exception in thread "main" javax.naming.NameNotFoundException: /Echo does
> not exist in the system.  Check that the app was successfully deployed.
> 	at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
> 	at test.ClientTest.getEchoService(ClientTest.java:17)
> 	at test.ClientTest.main(ClientTest.java:40)
> 
> What's the right jndi name?
> 
> I see some other messages talk about ejb jndi, but still can't resolve my
> problem.
> 
> I deploy ejb2 test in geronimo 1.x, client lookup no problem. 


Re: ejb client jndi problem

Posted by wanyna <wa...@hotmail.com>.
By using jndi name like
"simple-ejb3/Echo/org.apache.openejb.examples.counter.ejb3.EchoRemote",
client lookup success both ejb2 and ejb3 test.

I feel what's talk about in http://openejb.apache.org/jndi-names.html is not
easy to understand.
And the default jndi name mentioned in this page not match my test.

How can I use same jndi name of a ejb in a web app or a standalone app?


prasad wrote:
> 
> Discussion in the below thread may or may not help you. Check it out.
> 
> http://www.nabble.com/forum/ViewPost.jtp?post=12197581&framed=y&skin=134
> 
> Also see
> http://openejb.apache.org/jndi-names.html
> 
> Cheers
> Prasad
> 
> On 9/21/07, wanyna <wa...@hotmail.com> wrote:
>>
>> I deploy ejb jar in geronimo2.0.1, this is a ejb2 test
>> http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar
>> simple-ejb2-1.0.jar
>> , and this is a ejb3 test
>> http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar
>> simple-ejb3-1.0.jar
>> .
>>
>> Both of them deploy no error.
>>
>> My client is a standalone application. Test code:
>> public class ClientTest {
>>
>>         public static EchoRemote getEchoService(String url,
>>                         String contextFactory) throws Exception {
>>                 Context context = getInitialContext(contextFactory, url);
>>                 Object obj = context.lookup("Echo");
>>                 return (EchoRemote) obj;
>>         }
>>
>>         public static CounterRemote getCounterService(String url,
>>                         String contextFactory) throws Exception {
>>                 Context context = getInitialContext(contextFactory, url);
>>                 Object obj =
>> context.lookup("SuperCounterBusinessRemote");
>>                 return (CounterRemote) obj;
>>         }
>>
>>         private static Context getInitialContext(String
>> initContextFactory,
>>                         String url) throws Exception {
>>                 Properties properties = new Properties();
>>                 properties.put(Context.INITIAL_CONTEXT_FACTORY,
>> initContextFactory);
>>                 properties.put(Context.PROVIDER_URL, url);
>>
>>                 return new InitialContext(properties);
>>         }
>>
>>         public static void main(String[] args) throws Exception{
>>                 String url = "ejbd://localhost:4201";
>>                 String factory =
>> "org.openejb.client.RemoteInitialContextFactory";
>>                 EchoRemote echo = getEchoService(url, factory);
>>                 assert("cba".equals(echo.echo("abc")));
>> //              CounterRemote counter = getCounterService(url, factory);
>> //              assert(counter.reset()==0);
>> //              assert(counter.increment()==1);
>> //              assert(counter.increment()==2);
>> //              assert(counter.reset()==0);
>>         }
>>
>> }
>>
>> exception:
>> Exception in thread "main" javax.naming.NameNotFoundException: /Echo does
>> not exist in the system.  Check that the app was successfully deployed.
>>         at
>> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
>>         at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>         at test.ClientTest.getEchoService(ClientTest.java:17)
>>         at test.ClientTest.main(ClientTest.java:40)
>>
>> What's the right jndi name?
>>
>> I see some other messages talk about ejb jndi, but still can't resolve my
>> problem.
>>
>> I deploy ejb2 test in geronimo 1.x, client lookup no problem.
>> --
>> View this message in context:
>> http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12813817
>> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12892390
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: ejb client jndi problem

Posted by Prasad Kashyap <go...@gmail.com>.
Discussion in the below thread may or may not help you. Check it out.

http://www.nabble.com/forum/ViewPost.jtp?post=12197581&framed=y&skin=134

Also see
http://openejb.apache.org/jndi-names.html

Cheers
Prasad

On 9/21/07, wanyna <wa...@hotmail.com> wrote:
>
> I deploy ejb jar in geronimo2.0.1, this is a ejb2 test
> http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar simple-ejb2-1.0.jar
> , and this is a ejb3 test
> http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar simple-ejb3-1.0.jar
> .
>
> Both of them deploy no error.
>
> My client is a standalone application. Test code:
> public class ClientTest {
>
>         public static EchoRemote getEchoService(String url,
>                         String contextFactory) throws Exception {
>                 Context context = getInitialContext(contextFactory, url);
>                 Object obj = context.lookup("Echo");
>                 return (EchoRemote) obj;
>         }
>
>         public static CounterRemote getCounterService(String url,
>                         String contextFactory) throws Exception {
>                 Context context = getInitialContext(contextFactory, url);
>                 Object obj = context.lookup("SuperCounterBusinessRemote");
>                 return (CounterRemote) obj;
>         }
>
>         private static Context getInitialContext(String initContextFactory,
>                         String url) throws Exception {
>                 Properties properties = new Properties();
>                 properties.put(Context.INITIAL_CONTEXT_FACTORY, initContextFactory);
>                 properties.put(Context.PROVIDER_URL, url);
>
>                 return new InitialContext(properties);
>         }
>
>         public static void main(String[] args) throws Exception{
>                 String url = "ejbd://localhost:4201";
>                 String factory = "org.openejb.client.RemoteInitialContextFactory";
>                 EchoRemote echo = getEchoService(url, factory);
>                 assert("cba".equals(echo.echo("abc")));
> //              CounterRemote counter = getCounterService(url, factory);
> //              assert(counter.reset()==0);
> //              assert(counter.increment()==1);
> //              assert(counter.increment()==2);
> //              assert(counter.reset()==0);
>         }
>
> }
>
> exception:
> Exception in thread "main" javax.naming.NameNotFoundException: /Echo does
> not exist in the system.  Check that the app was successfully deployed.
>         at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
>         at javax.naming.InitialContext.lookup(InitialContext.java:351)
>         at test.ClientTest.getEchoService(ClientTest.java:17)
>         at test.ClientTest.main(ClientTest.java:40)
>
> What's the right jndi name?
>
> I see some other messages talk about ejb jndi, but still can't resolve my
> problem.
>
> I deploy ejb2 test in geronimo 1.x, client lookup no problem.
> --
> View this message in context: http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12813817
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>

Re: AW: ejb client jndi problem

Posted by wanyna <wa...@hotmail.com>.
Thanks.
In my test simple-ejb2-1.0.jar wrapped in an ear, test passed with jndi name 
"simple-ejb2-1.0.jar/Echo/org.apache.openejb.examples.counter.ejb2.Echo".

I am used to configure jndi name in openejb-jar.xml or other j2ee server's
application description file. Whaterver ejb wrapped in, and what type client
is, the same is jndi name.  I feel it's simple and easy to use.

I'm glad to hear you will make this consistent in next version.
But can you tell me why openejb3's jndi name was designed more complex now? 



djencks wrote:
> 
> 
> On Sep 25, 2007, at 6:47 PM, wanyna wrote:
> 
>>
>> Thanks.
>> By using jndi name like
>> "simple-ejb3/Echo/ 
>> org.apache.openejb.examples.counter.ejb3.EchoRemote",
>> client lookup success both ejb2 and ejb3 test.
>>
>> But when I wrap this ejb jar in an ear, my test application failed  
>> again.
>> What's correct jndi name in this case?
> 
> (I could be wrong in my answer).  In an ear, the first component of  
> the jndi name is the ejb jar name.  So if your ejb jar is called  
> simple-ejb3.jar, the jndi name would be
> 
> simple-ejb3.jar/Echo/org.apache.openejb.examples.counter.ejb3.EchoRemote
> 
> For a standalone ejb jar, the first component is the artifactId  
> specified in the geronimo plan for the app.  If you don't supply a  
> plan or don't supply a moduleId for the plan (it might be required,  
> I'm not sure), the default is the name of the jar with the extension  
> removed, in this case simple.ejb3.
> 
> So, you can get the same name in and out of the ear by setting the  
> artifactId to simple-ejb3.jar in the geronimo plan.
> 
> We're considering if and how to make this more consistent in 2.0.2  
> and/or 2.1
> 
> thanks
> david jencks
> 
>>
>>
>>
>>
>> Ueberbach, Michael wrote:
>>>
>>> Hi,
>>>
>>> I don't know exactly your situation, please check the following
>>> conditions:
>>> - you deployed a EJB 3.0 application in an xxx-ejb.jar
>>> - you configured an openejb-jar.xml deployment plan where you set an
>>> artifactId for your app, let's say "MyApp"
>>> - you have a session bean you want connect to, let's say  
>>> "MySessionBean"
>>> - you have build a remote interface for your session bean (EJB 3.0  
>>> means a
>>> simple interface), let's say "MySessionRemote"
>>>
>>> then the following is the right jndi name to get a connection to  
>>> your bean
>>>
>>> "MyApp/MySessionBean/my.package.MySessionRemote"
>>>
>>> You have to use the fully qualified class name for the Interface!
>>>
>>> Regards
>>> Michael
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: wanyna [mailto:wanyna@hotmail.com]
>>> Gesendet: Freitag, 21. September 2007 11:47
>>> An: user@geronimo.apache.org
>>> Betreff: ejb client jndi problem
>>>
>>>
>>> I deploy ejb jar in geronimo2.0.1, this is a ejb2 test
>>> http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar
>>> simple-ejb2-1.0.jar , and this is a ejb3 test
>>> http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar
>>> simple-ejb3-1.0.jar .
>>>
>>> Both of them deploy no error.
>>>
>>> My client is a standalone application. Test code:
>>> public class ClientTest {
>>>
>>> 	public static EchoRemote getEchoService(String url,
>>> 			String contextFactory) throws Exception {
>>> 		Context context = getInitialContext(contextFactory, url);
>>> 		Object obj = context.lookup("Echo");
>>> 		return (EchoRemote) obj;
>>> 	}
>>>
>>> 	public static CounterRemote getCounterService(String url,
>>> 			String contextFactory) throws Exception {
>>> 		Context context = getInitialContext(contextFactory, url);
>>> 		Object obj = context.lookup("SuperCounterBusinessRemote");
>>> 		return (CounterRemote) obj;
>>> 	}
>>>
>>> 	private static Context getInitialContext(String initContextFactory,
>>> 			String url) throws Exception {
>>> 		Properties properties = new Properties();
>>> 		properties.put(Context.INITIAL_CONTEXT_FACTORY,  
>>> initContextFactory);
>>> 		properties.put(Context.PROVIDER_URL, url);
>>>
>>> 		return new InitialContext(properties);
>>> 	}
>>> 	
>>> 	public static void main(String[] args) throws Exception{
>>> 		String url = "ejbd://localhost:4201";
>>> 		String factory = "org.openejb.client.RemoteInitialContextFactory";
>>> 		EchoRemote echo = getEchoService(url, factory);
>>> 		assert("cba".equals(echo.echo("abc")));
>>> //		CounterRemote counter = getCounterService(url, factory);
>>> //		assert(counter.reset()==0);
>>> //		assert(counter.increment()==1);
>>> //		assert(counter.increment()==2);
>>> //		assert(counter.reset()==0);
>>> 	}
>>>
>>> }
>>>
>>> exception:
>>> Exception in thread "main" javax.naming.NameNotFoundException: / 
>>> Echo does
>>> not exist in the system.  Check that the app was successfully  
>>> deployed.
>>> 	at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java: 
>>> 237)
>>> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>> 	at test.ClientTest.getEchoService(ClientTest.java:17)
>>> 	at test.ClientTest.main(ClientTest.java:40)
>>>
>>> What's the right jndi name?
>>>
>>> I see some other messages talk about ejb jndi, but still can't  
>>> resolve my
>>> problem.
>>>
>>> I deploy ejb2 test in geronimo 1.x, client lookup no problem.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/ejb-client-jndi-problem- 
>>> tf4492931s134.html#a12813817
>>> Sent from the Apache Geronimo - Users mailing list archive at  
>>> Nabble.com.
>>>
>>>
>>
>> -- 
>> View this message in context: http://www.nabble.com/ejb-client-jndi- 
>> problem-tf4492931s134.html#a12892325
>> Sent from the Apache Geronimo - Users mailing list archive at  
>> Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12916830
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: AW: ejb client jndi problem

Posted by David Jencks <da...@yahoo.com>.
On Sep 25, 2007, at 6:47 PM, wanyna wrote:

>
> Thanks.
> By using jndi name like
> "simple-ejb3/Echo/ 
> org.apache.openejb.examples.counter.ejb3.EchoRemote",
> client lookup success both ejb2 and ejb3 test.
>
> But when I wrap this ejb jar in an ear, my test application failed  
> again.
> What's correct jndi name in this case?

(I could be wrong in my answer).  In an ear, the first component of  
the jndi name is the ejb jar name.  So if your ejb jar is called  
simple-ejb3.jar, the jndi name would be

simple-ejb3.jar/Echo/org.apache.openejb.examples.counter.ejb3.EchoRemote

For a standalone ejb jar, the first component is the artifactId  
specified in the geronimo plan for the app.  If you don't supply a  
plan or don't supply a moduleId for the plan (it might be required,  
I'm not sure), the default is the name of the jar with the extension  
removed, in this case simple.ejb3.

So, you can get the same name in and out of the ear by setting the  
artifactId to simple-ejb3.jar in the geronimo plan.

We're considering if and how to make this more consistent in 2.0.2  
and/or 2.1

thanks
david jencks

>
>
>
>
> Ueberbach, Michael wrote:
>>
>> Hi,
>>
>> I don't know exactly your situation, please check the following
>> conditions:
>> - you deployed a EJB 3.0 application in an xxx-ejb.jar
>> - you configured an openejb-jar.xml deployment plan where you set an
>> artifactId for your app, let's say "MyApp"
>> - you have a session bean you want connect to, let's say  
>> "MySessionBean"
>> - you have build a remote interface for your session bean (EJB 3.0  
>> means a
>> simple interface), let's say "MySessionRemote"
>>
>> then the following is the right jndi name to get a connection to  
>> your bean
>>
>> "MyApp/MySessionBean/my.package.MySessionRemote"
>>
>> You have to use the fully qualified class name for the Interface!
>>
>> Regards
>> Michael
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: wanyna [mailto:wanyna@hotmail.com]
>> Gesendet: Freitag, 21. September 2007 11:47
>> An: user@geronimo.apache.org
>> Betreff: ejb client jndi problem
>>
>>
>> I deploy ejb jar in geronimo2.0.1, this is a ejb2 test
>> http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar
>> simple-ejb2-1.0.jar , and this is a ejb3 test
>> http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar
>> simple-ejb3-1.0.jar .
>>
>> Both of them deploy no error.
>>
>> My client is a standalone application. Test code:
>> public class ClientTest {
>>
>> 	public static EchoRemote getEchoService(String url,
>> 			String contextFactory) throws Exception {
>> 		Context context = getInitialContext(contextFactory, url);
>> 		Object obj = context.lookup("Echo");
>> 		return (EchoRemote) obj;
>> 	}
>>
>> 	public static CounterRemote getCounterService(String url,
>> 			String contextFactory) throws Exception {
>> 		Context context = getInitialContext(contextFactory, url);
>> 		Object obj = context.lookup("SuperCounterBusinessRemote");
>> 		return (CounterRemote) obj;
>> 	}
>>
>> 	private static Context getInitialContext(String initContextFactory,
>> 			String url) throws Exception {
>> 		Properties properties = new Properties();
>> 		properties.put(Context.INITIAL_CONTEXT_FACTORY,  
>> initContextFactory);
>> 		properties.put(Context.PROVIDER_URL, url);
>>
>> 		return new InitialContext(properties);
>> 	}
>> 	
>> 	public static void main(String[] args) throws Exception{
>> 		String url = "ejbd://localhost:4201";
>> 		String factory = "org.openejb.client.RemoteInitialContextFactory";
>> 		EchoRemote echo = getEchoService(url, factory);
>> 		assert("cba".equals(echo.echo("abc")));
>> //		CounterRemote counter = getCounterService(url, factory);
>> //		assert(counter.reset()==0);
>> //		assert(counter.increment()==1);
>> //		assert(counter.increment()==2);
>> //		assert(counter.reset()==0);
>> 	}
>>
>> }
>>
>> exception:
>> Exception in thread "main" javax.naming.NameNotFoundException: / 
>> Echo does
>> not exist in the system.  Check that the app was successfully  
>> deployed.
>> 	at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java: 
>> 237)
>> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
>> 	at test.ClientTest.getEchoService(ClientTest.java:17)
>> 	at test.ClientTest.main(ClientTest.java:40)
>>
>> What's the right jndi name?
>>
>> I see some other messages talk about ejb jndi, but still can't  
>> resolve my
>> problem.
>>
>> I deploy ejb2 test in geronimo 1.x, client lookup no problem.
>> --
>> View this message in context:
>> http://www.nabble.com/ejb-client-jndi-problem- 
>> tf4492931s134.html#a12813817
>> Sent from the Apache Geronimo - Users mailing list archive at  
>> Nabble.com.
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/ejb-client-jndi- 
> problem-tf4492931s134.html#a12892325
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Re: AW: ejb client jndi problem

Posted by wanyna <wa...@hotmail.com>.
Thanks.
By using jndi name like
"simple-ejb3/Echo/org.apache.openejb.examples.counter.ejb3.EchoRemote",
client lookup success both ejb2 and ejb3 test.

But when I wrap this ejb jar in an ear, my test application failed again.
What's correct jndi name in this case?




Ueberbach, Michael wrote:
> 
> Hi, 
> 
> I don't know exactly your situation, please check the following
> conditions:   
> - you deployed a EJB 3.0 application in an xxx-ejb.jar
> - you configured an openejb-jar.xml deployment plan where you set an
> artifactId for your app, let's say "MyApp"
> - you have a session bean you want connect to, let's say "MySessionBean"
> - you have build a remote interface for your session bean (EJB 3.0 means a
> simple interface), let's say "MySessionRemote"
> 
> then the following is the right jndi name to get a connection to your bean
> 
> "MyApp/MySessionBean/my.package.MySessionRemote"
> 
> You have to use the fully qualified class name for the Interface!
> 
> Regards
> Michael
>  
> 
> -----Ursprüngliche Nachricht-----
> Von: wanyna [mailto:wanyna@hotmail.com] 
> Gesendet: Freitag, 21. September 2007 11:47
> An: user@geronimo.apache.org
> Betreff: ejb client jndi problem
> 
> 
> I deploy ejb jar in geronimo2.0.1, this is a ejb2 test
> http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar
> simple-ejb2-1.0.jar , and this is a ejb3 test
> http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar
> simple-ejb3-1.0.jar .
> 
> Both of them deploy no error.
> 
> My client is a standalone application. Test code:
> public class ClientTest {
> 
> 	public static EchoRemote getEchoService(String url,
> 			String contextFactory) throws Exception {
> 		Context context = getInitialContext(contextFactory, url);
> 		Object obj = context.lookup("Echo");
> 		return (EchoRemote) obj;
> 	}
> 
> 	public static CounterRemote getCounterService(String url,
> 			String contextFactory) throws Exception {
> 		Context context = getInitialContext(contextFactory, url);
> 		Object obj = context.lookup("SuperCounterBusinessRemote");
> 		return (CounterRemote) obj;
> 	}
> 
> 	private static Context getInitialContext(String initContextFactory,
> 			String url) throws Exception {
> 		Properties properties = new Properties();
> 		properties.put(Context.INITIAL_CONTEXT_FACTORY, initContextFactory);
> 		properties.put(Context.PROVIDER_URL, url);
> 
> 		return new InitialContext(properties);
> 	}
> 	
> 	public static void main(String[] args) throws Exception{
> 		String url = "ejbd://localhost:4201";
> 		String factory = "org.openejb.client.RemoteInitialContextFactory";
> 		EchoRemote echo = getEchoService(url, factory);
> 		assert("cba".equals(echo.echo("abc")));
> //		CounterRemote counter = getCounterService(url, factory);
> //		assert(counter.reset()==0);
> //		assert(counter.increment()==1);
> //		assert(counter.increment()==2);
> //		assert(counter.reset()==0);
> 	}
> 
> }
> 
> exception:
> Exception in thread "main" javax.naming.NameNotFoundException: /Echo does
> not exist in the system.  Check that the app was successfully deployed.
> 	at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
> 	at test.ClientTest.getEchoService(ClientTest.java:17)
> 	at test.ClientTest.main(ClientTest.java:40)
> 
> What's the right jndi name?
> 
> I see some other messages talk about ejb jndi, but still can't resolve my
> problem.
> 
> I deploy ejb2 test in geronimo 1.x, client lookup no problem. 
> --
> View this message in context:
> http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12813817
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
> 
> 

-- 
View this message in context: http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12892325
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


AW: ejb client jndi problem

Posted by "Ueberbach, Michael" <mi...@dbh.de>.
Hi, 

I don't know exactly your situation, please check the following conditions:   
- you deployed a EJB 3.0 application in an xxx-ejb.jar
- you configured an openejb-jar.xml deployment plan where you set an artifactId for your app, let's say "MyApp"
- you have a session bean you want connect to, let's say "MySessionBean"
- you have build a remote interface for your session bean (EJB 3.0 means a simple interface), let's say "MySessionRemote"

then the following is the right jndi name to get a connection to your bean

"MyApp/MySessionBean/my.package.MySessionRemote"

You have to use the fully qualified class name for the Interface!

Regards
Michael
 

-----Ursprüngliche Nachricht-----
Von: wanyna [mailto:wanyna@hotmail.com] 
Gesendet: Freitag, 21. September 2007 11:47
An: user@geronimo.apache.org
Betreff: ejb client jndi problem


I deploy ejb jar in geronimo2.0.1, this is a ejb2 test http://www.nabble.com/file/p12813817/simple-ejb2-1.0.jar simple-ejb2-1.0.jar , and this is a ejb3 test http://www.nabble.com/file/p12813817/simple-ejb3-1.0.jar simple-ejb3-1.0.jar .

Both of them deploy no error.

My client is a standalone application. Test code:
public class ClientTest {

	public static EchoRemote getEchoService(String url,
			String contextFactory) throws Exception {
		Context context = getInitialContext(contextFactory, url);
		Object obj = context.lookup("Echo");
		return (EchoRemote) obj;
	}

	public static CounterRemote getCounterService(String url,
			String contextFactory) throws Exception {
		Context context = getInitialContext(contextFactory, url);
		Object obj = context.lookup("SuperCounterBusinessRemote");
		return (CounterRemote) obj;
	}

	private static Context getInitialContext(String initContextFactory,
			String url) throws Exception {
		Properties properties = new Properties();
		properties.put(Context.INITIAL_CONTEXT_FACTORY, initContextFactory);
		properties.put(Context.PROVIDER_URL, url);

		return new InitialContext(properties);
	}
	
	public static void main(String[] args) throws Exception{
		String url = "ejbd://localhost:4201";
		String factory = "org.openejb.client.RemoteInitialContextFactory";
		EchoRemote echo = getEchoService(url, factory);
		assert("cba".equals(echo.echo("abc")));
//		CounterRemote counter = getCounterService(url, factory);
//		assert(counter.reset()==0);
//		assert(counter.increment()==1);
//		assert(counter.increment()==2);
//		assert(counter.reset()==0);
	}

}

exception:
Exception in thread "main" javax.naming.NameNotFoundException: /Echo does not exist in the system.  Check that the app was successfully deployed.
	at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:237)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at test.ClientTest.getEchoService(ClientTest.java:17)
	at test.ClientTest.main(ClientTest.java:40)

What's the right jndi name?

I see some other messages talk about ejb jndi, but still can't resolve my problem.

I deploy ejb2 test in geronimo 1.x, client lookup no problem. 
--
View this message in context: http://www.nabble.com/ejb-client-jndi-problem-tf4492931s134.html#a12813817
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.