[jboss-user] [EJB 3.0] - Re: InitialContext reference and definition
pepelara
do-not-reply at jboss.com
Tue Jan 27 09:28:58 EST 2009
Hi,
How do I call a local interface?
This is then Global JNDI Namespace from then JMX Console of
JBoss 4.2.2 GA,
| +- CalculatorEAR (class: org.jnp.interfaces.NamingContext)
| | +- CalculatorBean (class: org.jnp.interfaces.NamingContext)
| | | +- local (proxy: $Proxy62 implements interface jboss.tutorial.Calculator,interface org.jboss.ejb3.JBossProxy)
|
and then client is,
| package jboss.tutorial;
|
| import java.util.Properties;
|
| import javax.ejb.EJB;
| import javax.naming.InitialContext;
| import javax.naming.Context;
|
| public class CalculatorClient {
|
| @EJB
| private static Calculator calculator;
|
| public CalculatorClient() {
| try {
| Properties props = new Properties();
| props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| props.put("java.naming.factory.url.pkgs", "jnp://localhost:1099");
| props.put("java.naming.provider.url", "jnp://localhost:1099");
| Context ctx = new InitialContext(props);
| calculator = (Calculator) ctx.lookup("CalculatorBean/local");
| } catch (Exception ex) {
| System.out.println("CouldnâÂÂt create calculator bean. "+
| ex.getMessage());
| }
| }
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| // TODO Auto-generated method stub
| CalculatorClient cClient = new CalculatorClient();
|
| System.out.println("1 + 1 = " + calculator.add(1, 1));
| System.out.println("1 - 1 = " + calculator.subtract(1, 1));
| }
| }
|
The output gives me the Exception,
| CouldnâÂÂt create calculator bean. CalculatorBean not bound
|
Regards,
pepelara
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204995#4204995
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204995
More information about the jboss-user
mailing list