You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "amol.p.dongare" <ad...@3ds.com> on 2013/09/03 07:09:24 UTC

How to access EJB through JNDI lookup from non EJB class in the same server

Hello,

I want to access EJB 2.0 from non bean class through JNDI lookup(both are
running in same JVM). But it throws javax.naming.NameNotFoundException: Name
"*comp/env/ejb/testrefer*" not found. 

Please help
My JNDI lookup code is 

                      *  Properties props = new Properties();
			
			//props.put(Context.INITIAL_CONTEXT_FACTORY,
					"org.apache.openejb.client.RemoteInitialContextFactory");
			//props.put("java.naming.provider.url",
"http://localhost:8080/tomee/ejb");
						
			InitialContext ctx = new InitialContext();
			TransferRemore obj = ctx.lookup("java:comp/env/ejb/testrefer");*


Please suggest workaround.
			



--
View this message in context: http://openejb.979440.n4.nabble.com/How-to-access-EJB-through-JNDI-lookup-from-non-EJB-class-in-the-same-server-tp4664958.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: How to access EJB through JNDI lookup from non EJB class in the same server

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Use remote name (in the log, should be TransferRemoreRemote)
Le 3 sept. 2013 07:12, "amol.p.dongare" <ad...@3ds.com> a écrit :

> Hello,
>
> I want to access EJB 2.0 from non bean class through JNDI lookup(both are
> running in same JVM). But it throws javax.naming.NameNotFoundException:
> Name
> "*comp/env/ejb/testrefer*" not found.
>
> Please help
> My JNDI lookup code is
>
>                       *  Properties props = new Properties();
>
>                         //props.put(Context.INITIAL_CONTEXT_FACTORY,
>
> "org.apache.openejb.client.RemoteInitialContextFactory");
>                         //props.put("java.naming.provider.url",
> "http://localhost:8080/tomee/ejb");
>
>                         InitialContext ctx = new InitialContext();
>                         TransferRemore obj =
> ctx.lookup("java:comp/env/ejb/testrefer");*
>
>
> Please suggest workaround.
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/How-to-access-EJB-through-JNDI-lookup-from-non-EJB-class-in-the-same-server-tp4664958.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: How to access EJB through JNDI lookup from non EJB class in the same server

Posted by "amol.p.dongare" <ad...@3ds.com>.
Thanks. 

I found the solution - 
Set the following property to IntialContext object 
                 Properties props = new Properties();	
		 props.put(Context.INITIAL_CONTEXT_FACTORY, 
				"org.apache.openejb.client.RemoteInitialContextFactory");
                 InitialContext ctx = new InitialContext(props);


Thanks again,



--
View this message in context: http://openejb.979440.n4.nabble.com/How-to-access-EJB-through-JNDI-lookup-from-non-EJB-class-in-the-same-server-tp4664958p4664961.html
Sent from the OpenEJB User mailing list archive at Nabble.com.