WAS:WAS 6.1/7.0上EJB客戶端開發

1、EJB客戶端開發調用時所需要的Jar包

WAS 7.0的話,至少需要加

 <classpathentry kind="lib" path="X:/IBM/WebSphere/AppServer7.0/runtimes/com.ibm.ws.orb_7.0.0.jar"/>
 <classpathentry kind="lib" path="X:/IBM/WebSphere/AppServer7.0/runtimes/com.ibm.ws.ejb.thinclient_7.0.0.jar"/>

WAS 6.1的話,至少需要加

 <classpathentry kind="lib" path="X:/IBM/WebSphere/AppServer/runtimes/com.ibm.ws.webservices.thinclient_6.1.0.jar"/>
 <classpathentry kind="lib" path="X:/IBM/WebSphere/AppServer/runtimes/com.ibm.ws.admin.client_6.1.0.jar"/>
 <classpathentry kind="lib" path="D:/IBM/WebSphere/AppServer/lib/rsahelpers.jar"/>
 <classpathentry kind="lib" path="D:/IBM/WebSphere/AppServer/lib/rsadbutils.jar"/>
 <classpathentry kind="lib" path="X:/IBM/WebSphere/AppServer/plugins/com.ibm.ws.runtime_6.1.0.jar"/>
 <classpathentry kind="lib" path="X:/IBM/WebSphere/AppServer/plugins/com.ibm.ws.emf_2.1.0.jar"/>

 2、示例代碼

try {
	//##############################################################
	Hashtable env = new Hashtable();
	//String NAME_SYNTAX = "com.ibm.websphere.naming.name.syntax";
	//String NAME_SYNTAX_JNDI = "jndi";
	//env.put(NAME_SYNTAX, NAME_SYNTAX_JNDI);
	env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
	//env.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
	//env.put(Context.PROVIDER_URL, "iiop://localhost");
	InitialContext initialContext = new InitialContext(env);
	
	java.lang.Object objHome = initialContext.lookup(jndiName);
	AdditionHome home = (AdditionHome) 
		(javax.rmi.PortableRemoteObject.narrow(objHome, AdditionHome.class));
	 return home;
} catch (NamingException ex) {
	System.out.println("AdderEJBClient: JNDIlookup NamingException="+ex.getMessage() );
	throw ex;
} catch (Exception ex) {
	System.out.println("AdderEJBClient: JNDIlookup Exception="+ex.getMessage() );
	throw ex;
}

可用的ContextFactory:

INITIAL_CONTEXT_FACTORY=com.ibm.websphere.naming.WsnInitialContextFactory
PROVIDER_URL=iiop://localhost:2809

INITIAL_CONTEXT_FACTORY=com.sun.jndi.cosnaming.CNCtxFactory
PROVIDER_URL=iiop://localhost:9100

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章