[jboss-user] [JNDI/Naming/Network] - Re: access ejb frm a standalone java client:java.lang.ClassN

yhqian99 do-not-reply at jboss.com
Sun Mar 29 10:31:10 EDT 2009


Here is my client code:


package test;

import javax.naming.*;
import java.util.*;
import com.*;
public class TestHelloEJB
{
	public static void main(String[] args)
	{
		//JBoss' default remote jndi: <ejb-name>/remote
		final String jndiName = "HelloEJB/remote";
		try
		{			 
			Properties  p = new Properties();			
			p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
			p.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
			p.put("java.naming.provider.url", "localhost:1099");
			InitialContext ctx = new InitialContext(p);		 

			HelloEJBRemote helloEJB = (HelloEJBRemote)ctx.lookup(jndiName);
			String message = helloEJB.sayHello("Tom");
			System.out.println( message);		
		}catch( NamingException e)
		{
			e.printStackTrace();
		}

	}

}

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4221779#4221779

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4221779



More information about the jboss-user mailing list