[jboss-user] [JBossWS] - EJB3.0 Client code

aggarwalanil2004@gmail.com do-not-reply at jboss.com
Mon Oct 2 08:55:42 EDT 2006


Hi 
I am using EJB3.0 in my project
I wrote code of remote interface and bean 
I am using JBoss as application server.
I am not able to run the client code successfully
It is throwing followingexception :
PLZ help me ...

setting IC Propsjavax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
	at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at com.client.EJB3Client.main(EJB3Client.java:41)




Below is client code
package com.client;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
//import javax.ejb.EJB;

import com.ejb3.HelloEJB;

public class EJB3Client {

		public static void main(String[] args) {
		
		try {
			Context context =new InitialContext();
			HelloEJB helloejb = (HelloEJB)context.
								lookup("com.ejb3.HelloEJB");
			
			String st = helloejb.sayHello();
			
			System.out.print("client :" + st);
			
		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}


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

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



More information about the jboss-user mailing list