标签:
用weblogic 12c 测试 ejb3
import javax.naming.InitialContext; import javax.naming.NamingException; import ejb3test.HelloWorld; import weblogic.jndi.WLInitialContextFactory; public class Test { public static void main(String[] args) throws NamingException { java.util.Properties prop = new java.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 = new InitialContext(prop); HelloWorld h = (HelloWorld)ic.lookup("HelloWorldBean#ejb3test.HelloWorld"); System.out.println(h.sayHello("somebody "));////somebody say Hello . } }
如何生成ejb:
ejb 中 包含一个接口 和一个实现类
package ejb3test; public interface HelloWorld { public String sayHello(String name); }
package ejb3test; import javax.ejb.Remote; import javax.ejb.Stateless; @Stateless(mappedName = "HelloWorldBean") @Remote ({HelloWorld.class}) public class HelloWorldBean implements HelloWorld { public String sayHello(String name) { return name+" say Hello ."; } }
打包 HelloWorld HelloWorldBean 到 HelloApp.jar (普通jar即可) 并且部署到 weblogic服务器上
打包 HelloWorld 到 HelloI.jar 供 Test 类调用
测试遇到问题
org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe.....
解决办法
其一 直接引入weblogic.jar(好像这个版本是支持的)
或者 cd 到 Oracle\Middleware\Oracle_Home\wlserver\server\lib 下,执行 java -jar wljarbuilder.jar ,最后生成 wljarbuilder.jar 引入到测试类中即可 { 官方给的操作:http://docs.oracle.com/cd/E24329_01/web.1211/e24378/jarbuilder.htm#SACLT421 }
org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe
标签:
原文地址:http://www.cnblogs.com/rojas/p/4613723.html