java - What is the right way to look up EJB component? -
have been trying run first ejb project couple of days far. ejb project has source code:
package calc; import javax.ejb.remote; @remote public interface sessionbeanremote { public int add(int a,int b); } package calc; import javax.ejb.stateless; @stateless(name="mysessionbean",mappedname="mycalculator") public class sessionbean implements sessionbeanremote { public int add(int a,int b){ return +b; } }
secondly, have simple java project can call ejb component :
properties props = new properties(); props.put(context.initial_context_factory,"com.sun.enterprise.naming. serialinitcontextfactory"); props.setproperty("org.omg.corba.orbinitialhost", "localhost"); props.setproperty("org.omg.corba.orbinitialport", "3700"); initialcontext ctx = new initialcontext(props); sessionbeanremote bean = (sessionbeanremote) ctx.lookup("mycalculator"); int result = bean.add(3, 4); system.out.println(result); ctx.close();
jar used : gf-client.jar, no need add other jars glassfish community commended
exception caught :
java.lang.nosuchmethoderror: com.sun.corba.ee.spi.orbutil.fsm.fsmimpl.(lcom/sun/corba/ee/spi/orbutil/fsm/stateengine;lcom/sun/corba/ee/spi/orbutil/fsm/state;z)v
2 other questions :
context.lookup("java:global:/componentaddress")
vscontext.loopup("mappedname")
difference between them, when use each ?props.setproperty("org.omg.corba.orbinitialhost", "192.168.1.100")
vs.props.setproperty("org.omg.corba.orbinitialhost", "localhost")
simply problem came down glassfish version 3.0, downloaded latest version 3.1.2 , works brilliant .
Comments
Post a Comment