[jboss-user] [EJB/JBoss] - finally, it works!!!!

ANDRIA-NTOANINA do-not-reply at jboss.com
Mon Nov 13 04:04:41 EST 2006


First, I look at my jmx-console and in the JNDIView service, I didn't found my EJB Beans. Why? I don't know. But I changed my plateform to J2EE 1.4(I first coded my beans using J2EE 5). Now, when I deploy the beans I found it in the jmx-console.
May be there is a problem using EJB3 with my JBoss 4.0.3. I don't know. The essential is it works.

CODING the client.

I create a simple Java Application. I m using Eclipse.
then I imported my ejb.jar and jbossall-client.jar into my project.

then there is my class implementation:

  | package maki.oim;
  | 
  | import java.rmi.RemoteException;
  | import java.util.Properties;
  | 
  | import javax.ejb.CreateException;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | import javax.rmi.PortableRemoteObject;
  | 
  | 
  | 
  | public class Test {
  | 
  | 	private static String driver="org.jnp.interfaces.NamingContextFactory";
  | 	private static String provider="jnp://localhost:1099";
  | 	private static String prefixe="org.jboss.naming";
  | 	public static ConvertisseurRemote getConvertisseurRemote()
  | 	{
  | 		try {
  | 				Properties env = new Properties();
  | 				env.put(Context.INITIAL_CONTEXT_FACTORY,driver);
  | 				env.put(Context.PROVIDER_URL,provider);
  | 				env.put(Context.URL_PKG_PREFIXES,prefixe);
  | 				InitialContext jndiContext;
  | 				
  | 					jndiContext = new InitialContext(env);
  | 				
  | 				Object ref = jndiContext.lookup("ConvertisseurBean");
  | 				ConvertisseurRemoteHome home =
  | 			
  | 				(ConvertisseurRemoteHome)PortableRemoteObject.narrow(ref,
  | 			
  | 						ConvertisseurRemoteHome.class);
  | 					return home.create();
  | 		} catch (NamingException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 			return null;
  | 		} catch (RemoteException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 			return null;
  | 		} catch (CreateException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 			return null;
  | 		}
  | 	}
  | 	/**
  | 	 * @param args
  | 	 */
  | 	public static void main(String[] args) {
  | 		try {
  | 			ConvertisseurRemote conv = getConvertisseurRemote();
  | 			System.out.println(conv.fmgToArriary(25));
  | 		} catch (RemoteException e) {
  | 				// TODO Auto-generated catch block
  | 				e.printStackTrace();
  | 			}
  | 	}
  | 
  | }
  | 

It works fine!! :)

I've tried coding an enterprise client using what jaikiran show but it crash.
May be there's something wrong in my code.Nethertheless, I'll retry and tell you if it success.

Thank you!!!

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

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



More information about the jboss-user mailing list