Test EJB3 with WebLogic 12c
import Javax.naming.initialcontext;import javax.naming.namingexception;import ejb3test. Helloworld;import weblogic.jndi.WLInitialContextFactory; Public classTest { Public Static voidMain (string[] args) throws Namingexception {Java.util.Properties prop=Newjava.util.Properties (); Prop.setproperty (Javax.naming.Context.INITIAL_CONTEXT_FACTORY, wlinitialcontextfactory.class. GetName ()); Prop.setproperty (Javax.naming.Context.PROVIDER_URL,"t3://localhost:7001"); InitialContext IC=NewInitialContext (prop); HelloWorld h= (HelloWorld) ic.lookup ("Helloworldbean#ejb3test. HelloWorld"); System. out. println (H.sayhello ("Somebody"));////somebody say Hello. }}
How to generate EJBS:
The EJB contains an interface and an implementation class
Package ejb3test; Public Interface HelloWorld { public string SayHello (string name); }
" Helloworldbean " ) @Remote ({HelloWorld. class publicclass Helloworldbean implements HelloWorld { public string SayHello (string name) { return name+" say Hello. " ; }}
Packing HelloWorld Helloworldbean to Helloapp.jar (normal jar) and deployed to WebLogic server
HelloWorld to Helloi.jar for Test class invocation
Test encountered a problem
Org.omg.CORBA.MARSHAL:vmcid:SUN minor code:211 Completed:maybe .....
Solutions
One is to introduce Weblogic.jar directly (as if this version is supported)
or CD to Oracle\middleware\oracle_home\wlserver\server\lib, perform Java-jar Wljarbuilder.jar, and finally generate Wljarbuilder.jar introduced into the test Class {The official operation: http://docs.oracle.com/cd/E24329_01/web.1211/e24378/jarbuilder.htm#SACLT421}
Org.omg.CORBA.MARSHAL:vmcid:SUN Minor code:211 Completed:maybe