Remote EJB from a non-Java EE web container
来源:互联网 发布:js数组遍历时删除元素 编辑:程序博客网 时间:2024/05/16 18:23
How do I access a Remote EJB (3.0 or 2.x) from a non-Java EE web container like Tomcat or Resin?
Accessing a Remote EJB from a non-Java EE web container is similar tothe stand-alone java client case. However, the complication is thatmost Java web servers set the default JNDI name provider for the JVM,which prevents our appserver naming provider from being instantiatedwhen the application uses the no-arg InitialContext() constructor. Thesolution is to explicitly instantiate an InitialContext(Hashtable) withthe properties for our naming provider, as contained inappserv-rt.jar's jndi.properties file.
Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
// optional. Defaults to localhost. Only needed if web server is running
// on a different host than the appserver
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// optional. Defaults to 3700. Only needed if target orb port is not 3700.
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ic = new InitialContext(props);
Step 2. Use the global JNDI name of the target Remote EJB in the lookup.
EJB 3.0 :
E.g., assuming a Remote 3.0 EJB with a global JNDI name of com.acme.FooRemoteBusiness
FooRemoteBusiness foo = (FooRemoteBusiness) ic.lookup("com.acme.FooRemoteBusiness");
EJB 2.x :
E.g., assuming a Remote 2.x EJB with a global JNDI name of com.acme.FooHome
Object obj = ic.lookup("com.acme.FooHome");
FooHome fooHome = (FooHome) PortableRemoteObject.narrow(obj, FooHome.class);
See step 3 of stand-alone client access for the list of required .jars.
(Asmentioned in Step 1, appserv-rt.jar is needed to correclty bootstrapthe naming provider within our appserver implementation. javaee.jarcontains the API classes for Java EE 5. E.g., assuming the applicationclasses are in /home/user1/myclasses and the main client class isacme.MyClient :
java -classpath $APS_HOME/lib/appserv-rt.jar:$APS_HOME/lib/javaee.jar:/home/user1/myclasses acme.MyClient
Note: appserv-rt.jar uses the JAR MANIFEST-CLASSPATH attribute to includeother dependent .jars within the lib directory. When setting yourclient classpath, it is best to directly refer to the appserv-rt.jarwithin the app server lib directory rather than copying it to anotherlocation. If you do copy appserv-rt.jar, you'll need to copy additional.jars such as appserv-deployment-client.jar and appserv-ext.jar. Thefull set of .jars that might be needed by appserv-rt.jar is located inits META-INF/MANIFEST.MF file.
Ifyour stand-alone client makes use of JMS, you'll also need to add$APS_HOME/lib/install/applications/jmsra/imqjmsra.jar,$APS_HOME/lib/appserv-admin.jar and $APS_HOME/lib/appserv-ws.jar
Ifyour stand-alone client makes use of the Java Persistence API (e.g. itcalls a Remote EJB that returns a Java Persistence API entity ), you'llalso need to add $APS_HOME/lib/toplink-essentials.jar
)
Builds from this point on will contain a required bug fix.
See https://glassfish.dev.java.net/issues/show_bug.cgi?id=920 for more details.
- Remote EJB from a non-Java EE web container
- Java容器(Web Container, EJB Container)
- EJB invocations from a remote client using JNDI
- EJB invocations from a remote client using JNDI
- EJB invocations from a remote client using JNDI
- Use a “remote” EJB in Camel routes
- EJB学习笔记-4-web应用访问EJB(remote)
- Java EE Web开发
- Container exited with a non-zero exit code 127
- Tomcat web工程 调用 JBOSS EJB local及remote
- java.lang.IllegalArgumentException: Object returned from onCreateLoader must not be a non-static inn
- java.lang.IllegalArgumentException: Object returned from onCreateLoader must not be a non-static inn
- Java - Why non-static variable cannot be referenced from a static context?
- 对比: Java EE EJB和 Spring Java Bean
- Java EE 迎合 Web 2.0
- Java EE 迎合 Web 2.0
- Java EE meets Web 2.0
- java web service+eclipse ee
- Java SE 6 新特性: XML API 与 Web 服务
- netbeans6.5体验感受
- 我的桌面
- 找到工作了,新的目标!!!
- Tomcat6远程调用GlassFish V2的session bean
- Remote EJB from a non-Java EE web container
- 建立并打印1到n^2的自然数构成的魔方阵
- 就这样把自己卖了(1)
- 并发式面向对象网络服务器的实现
- 就这样把自己卖了(2)
- ScriptManager属性:RegisterAsyncPostBackControl及EnablePartialRendering
- MODIF ID 的使用
- 打印10行杨辉三角
- 我又回来了