- 浏览: 704095 次
- 性别:
- 来自: 福建
文章分类
最新评论
-
羽翼的心动:
同意2楼的说法,我们公司之前一个项目用过pageoffice, ...
poi导出excel文件工具类 -
贝塔ZQ:
poi实现导出excel文件,蛮麻烦的,用pageoffice ...
poi导出excel文件工具类 -
aishiqiang:
为什么我的项目配置好证书后,每次使用jenkinst自动构建包 ...
关于使用https协议,cas认证PKIX path building failed错误解决方法 -
zhongmin2012:
谢谢分享,正在想看
AST解析java源文件相关jar包 -
mybestroy1108:
感谢分享!受益良多!
Jboss7 JMS demo
总结下远程调用ejb3的几种方式:
部署在jboss服务器上的ejb3应用程序:
部署在weblogic服务器上的ejb3应用:
当然属性信息可以放在一个jndi.properties属性文件中,如:
当然该文件放在src根目录下,然后我们在程序中就无需创建Properties的实例并设置相关熟悉,可以直接实例化InitialContext,调用默认的实例化构造函数,会默认查找src根目录下的jndi.properties属性文件。
当然在实际开发应用中不会直接通过以上方式来直接调用远程ejb3服务,在spring框架中可以通过JndiObjectFactoryBean来获得远程ejb3的实例,例如:
部署在jboss服务器上的ejb3应用程序:
/*设置属性信息*/ Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL, "jnp://localhost:1099");//部署在jboss服务器上的应用使用jnp协议 props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); try { InitialContext ctx=new InitialContext(props); /* 获得部署在Jboss服务器上的ejb3应用接口实例*/ IRmiExampleSerivce rmiSerivce = (IRmiExampleSerivce)ctx.lookup("IRmiExampleSerivceImpl/remote"); //不同的服务器jndi名称不一样 } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); }
部署在weblogic服务器上的ejb3应用:
/*设置属性信息*/ Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); props.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");//部署在weblogic服务器上的应用使用t3协议 props.put("java.naming.security.principal", "weblogic");//用户名 props.put("java.naming.security.credentials", "weblogic");//密码 try { InitialContext ctx=new InitialContext(props); /* 获得部署在Jboss服务器上的ejb3应用接口实例*/ IRmiExampleSerivce rmiSerivce = (IRmiExampleSerivce)ctx.lookup("IRmiExampleSerivce#com.rmi.IRmiExampleSerivce"); //不同的服务器jndi名称不一样 } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); }
当然属性信息可以放在一个jndi.properties属性文件中,如:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=localhost:1099
当然该文件放在src根目录下,然后我们在程序中就无需创建Properties的实例并设置相关熟悉,可以直接实例化InitialContext,调用默认的实例化构造函数,会默认查找src根目录下的jndi.properties属性文件。
当然在实际开发应用中不会直接通过以上方式来直接调用远程ejb3服务,在spring框架中可以通过JndiObjectFactoryBean来获得远程ejb3的实例,例如:
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> <property name="environment"> <props> <prop key="java.naming.provider.url">t3://127.0.0.1:7001</prop> <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> <prop key="java.naming.security.principal">weblogic</prop> <prop key="java.naming.security.credentials">weblogic</prop> </props> </property> </bean> <bean id="rmiExampleSerivce" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate" ref="jndiTemplate"/> <property name="jndiName" value="IRmiExampleSerivce#com.rmi.IRmiExampleSerivce"></property> </bean>
评论
1 楼
huazai_wow
2013-09-29
楼主 在吗?
请教一个问题啊? QQ:2598059791
在Servlet中
Properties props=new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "t3://221.181.173.95:7001");
props.setProperty(Context.SECURITY_PRINCIPAL, "huazai_wow");
props.setProperty(Context.SECURITY_CREDENTIALS, "huazai_wow");
Context context=new InitialContext(props);
SayHelloRemoteTypeRemote sayHelloRemoteTypeRemoteRef=
(SayHelloRemoteTypeRemote) context.lookup("huazai_wow#publicinterface.SayHelloRemoteTypeRemote");
sayHelloRemoteTypeRemoteRef.sayHelloMethodRemote();
context.close();
远程sessionBean
/**
*
* @author Administrator
* mappedName 属性值 代表在Weblogic中注册JNDI节点的名称
*
*/
@Stateless(mappedName="huazai_wow")
public class SayHelloRemoteType implements SayHelloRemoteTypeRemote {
public void sayHelloMethodRemote() {
System.out.println("高洪岩你好! 属于远程调用!");
}
}
在 weblogic 服务器 jndi 树节点中 可以看到这个树节点
但是运行的时候报这个错误啊?
2013-9-29 11:57:00 com.sun.corba.se.impl.encoding.CDRInputStream_1_0 read_value
警告: "IOP00810211: (MARSHAL) Exception from readValue on ValueHandler in CDRInputStream"
org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe
at com.sun.corba.se.impl.logging.ORBUtilSystemException.valuehandlerReadException(ORBUtilSystemException.java:6528)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1045)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:873)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:863)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_abstract_interface(CDRInputStream.java:269)
at com.sun.corba.se.impl.util.Utility.readAbstractAndNarrow(Utility.java:948)
at com.sun.corba.se.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1988)
at com.sun.corba.se.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2216)
at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1223)
at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:327)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:293)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:249)
at com.sun.corba.se.impl.corba.TCUtility.unmarshalIn(TCUtility.java:269)
at com.sun.corba.se.impl.corba.AnyImpl.read_value(AnyImpl.java:559)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:739)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_any(CDRInputStream.java:220)
at weblogic.corba.cos.naming._NamingContextAnyStub.resolve_any(_NamingContextAnyStub.java:81)
at weblogic.corba.j2ee.naming.ContextImpl.lookup(ContextImpl.java:267)
at weblogic.corba.j2ee.naming.ContextImpl.lookup(ContextImpl.java:227)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at controller.test.doPost(test.java:35)
at controller.test.doGet(test.java:21)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: publicinterface.SayHelloRemoteType_u66dq_SayHelloRemoteTypeRemoteRIntf
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.readObject(RemoteBusinessIntfProxy.java:266)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.se.impl.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1696)
at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1214)
at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:327)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:293)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034)
... 38 more
请教一个问题啊? QQ:2598059791
在Servlet中
Properties props=new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "t3://221.181.173.95:7001");
props.setProperty(Context.SECURITY_PRINCIPAL, "huazai_wow");
props.setProperty(Context.SECURITY_CREDENTIALS, "huazai_wow");
Context context=new InitialContext(props);
SayHelloRemoteTypeRemote sayHelloRemoteTypeRemoteRef=
(SayHelloRemoteTypeRemote) context.lookup("huazai_wow#publicinterface.SayHelloRemoteTypeRemote");
sayHelloRemoteTypeRemoteRef.sayHelloMethodRemote();
context.close();
远程sessionBean
/**
*
* @author Administrator
* mappedName 属性值 代表在Weblogic中注册JNDI节点的名称
*
*/
@Stateless(mappedName="huazai_wow")
public class SayHelloRemoteType implements SayHelloRemoteTypeRemote {
public void sayHelloMethodRemote() {
System.out.println("高洪岩你好! 属于远程调用!");
}
}
在 weblogic 服务器 jndi 树节点中 可以看到这个树节点
但是运行的时候报这个错误啊?
2013-9-29 11:57:00 com.sun.corba.se.impl.encoding.CDRInputStream_1_0 read_value
警告: "IOP00810211: (MARSHAL) Exception from readValue on ValueHandler in CDRInputStream"
org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe
at com.sun.corba.se.impl.logging.ORBUtilSystemException.valuehandlerReadException(ORBUtilSystemException.java:6528)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1045)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:873)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:863)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_abstract_interface(CDRInputStream.java:269)
at com.sun.corba.se.impl.util.Utility.readAbstractAndNarrow(Utility.java:948)
at com.sun.corba.se.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1988)
at com.sun.corba.se.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2216)
at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1223)
at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:327)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:293)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:249)
at com.sun.corba.se.impl.corba.TCUtility.unmarshalIn(TCUtility.java:269)
at com.sun.corba.se.impl.corba.AnyImpl.read_value(AnyImpl.java:559)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:739)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_any(CDRInputStream.java:220)
at weblogic.corba.cos.naming._NamingContextAnyStub.resolve_any(_NamingContextAnyStub.java:81)
at weblogic.corba.j2ee.naming.ContextImpl.lookup(ContextImpl.java:267)
at weblogic.corba.j2ee.naming.ContextImpl.lookup(ContextImpl.java:227)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at controller.test.doPost(test.java:35)
at controller.test.doGet(test.java:21)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: publicinterface.SayHelloRemoteType_u66dq_SayHelloRemoteTypeRemoteRIntf
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.readObject(RemoteBusinessIntfProxy.java:266)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.se.impl.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1696)
at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1214)
at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:327)
at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:293)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034)
... 38 more
发表评论
-
hibernate返回一个实际的类型安全java对象时遇到的错误
2009-04-08 17:14 1656hibernate返回一个实际的类型安全java对象时遇到这样 ... -
执行hql参数多余错误
2009-03-24 14:52 1872执行hql时,语句中含参数,若未设置参数,则出现错误: jav ... -
hibernate的hql 分页查询
2009-01-19 16:37 9554今天用hibernate做了个分页查询,放到博客上,就只当是备 ... -
MyEclipse中spring与hibernate冲突问题
2009-01-13 10:05 2159asm-1.2.3.jar与asm.jar 冲突问题 解决方法 ... -
实体关系之@ManyToMany
2009-01-10 08:21 21227Student.java package com.enti ... -
实体关系之@OneToMany
2009-01-08 08:14 18651Order.java package com.entity ... -
实体关系之@OneToOne
2009-01-06 16:44 16740Person.java package com.entit ... -
java.lang.NoClassDefFoundError: org/jboss/logging/
2009-01-06 10:20 2982应用:ejb3 SessionBean 测试 错误:jav ... -
ejb3.0 persistence.xml 介绍
2009-01-05 16:38 3775从qq空间转到javaeye,希望可以和更多的人互相交流学习! ... -
EntityManager--实体管理器
2009-01-05 16:32 7900这篇文章被我落在qq空间好寂寞啊,今天开始学习hiberant ...
相关推荐
onnxruntime-1.16.0-cp311-cp311-win_amd64.whl
基于springboot的流浪猫狗救助系统源码数据库文档.zip
摘 要 如今的信息时代,对信息的共享性,信息的流通性有着较高要求,因此传统管理方式就不适合。为了让美容院信息的管理模式进行升级,也为了更好的维护美容院信息,美容院管理系统的开发运用就显得很有必要。并且通过开发美容院管理系统,不仅可以让所学的SpringBoot框架得到实际运用,也可以掌握MySQL的使用方法,对自身编程能力也有一个检验和提升的过程。尤其是通过实践,可以对系统的开发流程加深印象,无论是前期的分析与设计,还是后期的编码测试等环节,都可以有一个深刻的了解。 美容院管理系统根据调研,确定其实现的功能主要包括美容用品管理,美容项目管理,美容部位管理,销量信息管理,订单管理,美容项目预约信息管理等功能。 借助于美容院管理系统这样的工具,让信息系统化,流程化,规范化是最终的发展结果,让其遵循实际操作流程的情况下,对美容院信息实施规范化处理,让美容院信息通过电子的方式进行保存,无论是管理人员检索美容院信息,维护美容院信息都可以便利化操作,真正缩短信息处理时间,节省人力和信息管理的成本。 关键字:美容院管理系统,SpringBoot框架,MySQL
numpy-1.21.1-cp39-cp39-linux_armv7l.whl
基于JavaWeb+springboot的宠物救助及领养平台源码数据库文档.zip
基于springboot员工在线餐饮管理系统源码数据库文档.zip
matplotlib-3.5.3-cp37-cp37m-linux_armv7l.whl
基于springboot+web的留守儿童网站源码数据库文档.zip
STM32神舟III号例程源码SysTick系统滴答(神舟III号-库函数版)提取方式是百度网盘分享地址
STM32开发相关软件ISP 程序下载STM32开发相关软件ISP 程序下载提取方式是百度网盘分享地址
onnxruntime-1.17.0-cp310-cp310-win_amd64.whl
Pillow-9.5.0-cp39-cp39-linux_armv7l.whl
基于springboot高性能计算中心的高性能集群共享平台源码数据库文档.zip
SciPy-1.11.1-cp311-cp311-linux_armv7l.whl
主机硬件信息邮件及微信推送
numpy-1.23.4-cp39-cp39-linux_armv7l.whl
基于springboot视频点播系统源码数据库文档.zip
基于springboot竞赛管理系统源码数据库文档.zip
环境说明: 开发语言:python Python版本:3.6.8 数据库:mysql 5.7数据库工具:Navicat11开发软件:pycharm
opencv_python-4.6.0.66-cp37-cp37m-linux_armv7l.whl