eclipse 3.4 - ejb - jboss - jndi-name [message #221771] |
Wed, 24 September 2008 14:14 |
Silvan Spross Messages: 2 Registered: July 2009 |
Junior Member |
|
|
hi all
i have problems to get an ejb working in my client.
first a short overview, i have:
an ejb remote:
--
import javax.ejb.Remote;
@Remote
public interface Computer {
public double compute(double a, double b);
}
--
an ejb:
--
import javax.ejb.Stateless;
@Stateless(mappedName = "Computer")
public class ComputerBean implements Computer {
public ComputerBean() {
// TODO Auto-generated constructor stub
}
public double compute(double a, double b) {
return a + b;
}
}
--
and a 'client':
--
import java.util.Hashtable;
import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
public class ComputerUser {
@EJB
private static Computer computer;
public ComputerUser(){
}
public static void main(String[] args) {
ComputerUser client = new ComputerUser();
client.doTest();
}
public void doTest()
{
try {
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "127.0.0.1:1099");
InitialContext ic = new InitialContext(env);
computer = (Computer)ic.lookup("java:comp/env/ejb/Computer");
} catch (Exception e){
System.out.println(e);
}
System.out.println(computer);
System.out.println(computer.compute(1,2));
}
}
--
i have an 'EAR', a 'bean' and a 'client' project. both are added to the
EAR project and the deployment to the installed jboss 4.2 server works
without errors.
now if i try to debug the 'client' (ComputerUser) he can't find the
Computer Bean:
javax.naming.NameNotFoundException: comp not bound
someone any idea what i'm doing wrong?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03128 seconds