JBoss Community

Hey I want simple steps to run an ejb sample application?

reply from swaroop kumar in Beginner's Corner - View the full discussion

I checked with the jmx-console and jboss-web console and the i checked the JNDI names by using "JNDIView" 

 

 

package

 

com.myeclipse.ejb3;

 

 

 

 

 

 

import

 

javax.naming.Context;

import

 

javax.naming.InitialContext;

import

 

javax.naming.NamingEnumeration;

import

 

javax.naming.NamingException;

import

 

java.util.*;

 

 

 

 

public

 

class MyBeanClient {

 

 

public static void main(String[] args) {

 

try {

Hashtable env =

new Hashtable();

env.put(

"java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");

 

//env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); //not required

env.put(

"java.naming.provider.url","localhost:1099");

 

final String jndiName = "MyBean/remote";

Context context =

new InitialContext(env);

System.

out.println("about to look up jndi name " + jndiName);

 

MyBeanRemote beanRemote = (com.myeclipse.ejb3.MyBeanRemote) context.lookup(jndiName);

beanRemote.doSomething();

System.

out.println("finished lookup");

}

catch (NamingException e) {

e.printStackTrace();

}

}

}

 

 

REMOTE CLASS

 

 

 

 

package

 

 

com.myeclipse.ejb3;

 

 

 

 

 

import

 

 

javax.ejb.Remote;

 

 

@Remote

 

 

 

public

 

 

interface

MyBeanRemote {

 

 

public void

doSomething() ;

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community