ejb 远程调用
1,客户端代码:
package com.example.test; import java.util.Hashtable;
import java.util.Properties; import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException; import com.example.HelloWorldRemote; //import cn.ejb.HelloWorldRemote; public class HelloWorldTest {
public static void main(String[] args) {
Properties jndiProperties = new Properties();
// Hashtable jndiProperties = new Hashtable();
jndiProperties.put("jboss.naming.client.ejb.context", true);
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); //写这里不行!!!
// jndiProperties.put(Context.SECURITY_PRINCIPAL, "testUser");
// jndiProperties.put(Context.SECURITY_CREDENTIALS, "12345678"); try {
Context context = new InitialContext(jndiProperties);
final String appName = "";
final String moduleName = "hello";
final String distinctName = ""; Object obj = context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/HelloWorld!com.example.HelloWorldRemote");
System.out.println(obj);
HelloWorldRemote hwr = (HelloWorldRemote) obj;
String say = hwr.hello( );
System.out.println(say);
} catch (NamingException e) {
e.printStackTrace();
}
}
}
2,src下的jboss-ejb-client.properties
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=211.100.75.242
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=testUser
remote.connection.default.password=12345678
3,用jboss\bin\add-user.sh 加个 applicationRealm
[userone@localhost bin]$ ./add-user.sh
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): b
Enter the details of the new user to add.
Realm (ApplicationRealm) : ApplicationRealm ---->> Careful Here . You need to type this or leave it blank . I filled an incorrect value here and things went wrong from there .
Username : testuser
Password : testpassword
Re-enter Password : testpassword
What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank for none) : testrole
About to add user 'testuser' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-users.properties'
Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-users.properties'
Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-roles.properties'
Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-roles.properties'
.
大功告成了
参考:
.http://stackoverflow.com/questions/19129836/javax-security-sasl-saslexception-authentic-failed-while-connecting-to-jboss-7
http://middlewaremagic.com/jboss/?p=1466
https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
ejb 远程调用的更多相关文章
- weblogic的ejb远程调用
这是一篇对EJB远程调用的简单范例. 1.环境:win7 + weblogic 12c + myeclipse8.5 2.目的:实现在myeclispe中对weblogic中EJ ...
- Ejb远程调用-jboss服务器调用服务器-Bean调用Bean
英文参考地址 https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+o ...
- 远程调用jboss as 7上部署的ejb出现No EJB receiver available for handling 异常
昨天倒腾了一天终于配置好了jboss as 7的域,今天又倒腾了一整天在上面部署了个EJB,然后试了一个利用JNDI来进行远程调用.下面记录一下过程中那些乱七八糟的问题: 首先是这个jboss-cli ...
- JavaEE(8) - 本地和远程调用的有状态以及无状态Session EJB
1. 使用NetBeans开发Session Bean #1. 创建项目:File-->New Project-->Java EE-->EJB Module #2. 在项目中创建Se ...
- Spring远程调用技术<1>-RMI
在java中,我们有多种可以使用的远程调用技术 1.远程方法调用(remote method invocation, RMI) 适用场景:不考虑网络限制时(例如防火墙),访问/发布基于java的服务 ...
- EJB的调用
EJB调用.html :first-child{margin-top:0!important}img.plugin{box-shadow:0 1px 3px rgba(0,0,0,.1);border ...
- tomee 第一个 远程调用 Session Bean
参考文档 http://tomee.apache.org/ http://download.oracle.com/otndocs/jcp/ejb-3.1-pfd-oth-JSpec/ http://d ...
- JSON-RPC轻量级远程调用协议介绍及使用
这个项目能够帮助开发人员利用Java编程语言轻松实现JSON-RPC远程调用.jsonrpc4j使用Jackson类库实现Java对象与JSON对象之间的相互转换.jsonrpc4j包含一个JSON- ...
- Java[2] 分布式服务架构之java远程调用技术浅析(转http://www.uml.org.cn/zjjs/201208011.asp)
转自:http://www.uml.org.cn/zjjs/201208011.asp 在分布式服务框架中,一个最基础的问题就是远程服务是怎么通讯的,在Java领域中有很多可实现远程通讯的技术,例如: ...
随机推荐
- Xamarin Android -创建Splash Screen (一)
......(空话少说) Xamarin 开发的技术资料很少,通过学习,把自己的学习过程及其中碰到的问题与大家分享. Splash Screen 就是在应用程序启动时,出现的一张图片,一般App的Sp ...
- MVC———用自定义扩展类实现验证
废话少说,直接上图 →_→ NO.1 NO.2 NO.3 NO.4 NO.5 NO.6 NO.7 NO.8 NO.9 NO.10 NO.11 NO.12 NO.13 NO.14 NO.15 NO.16 ...
- 如果在敲代码的时候eclipse不弹出提示,怎么办?
非常弱智的操作,我们曾经在输入System.out.println("content");的时候,当我们输入了"."之后,在输入错误,此时我们再回退至" ...
- PLSQL Developer不支持Oracle 64位客户端解决方法
问题描述: 在虚拟机同网段,搭建Oracle 11.2.04数据库64位的,本机操作系统Win10 x64和PLSQL 9.03,目前想利用PLSQL远程登录ORACLE数据库操作.当初用 insta ...
- python环境搭建-Linux系统下python2.6.6升级python3.5.2步骤
[root@template ~]# python -v # /usr/lib64/python2.6/encodings/utf_8.pyc matches /usr/lib64/python2.6 ...
- Tomcat遇到的问题
1. java.lang.OutOfMemoryError: PermGen space 启动tomcat服务时,报这个错,查了下是,内存泄露 PermGen space的全称是Permanent G ...
- 最棒的10款MySQL GUI工具
绝大多数的关系数据库都明显不同于MS Access,它们都有两个截然不同的部分:后端作为数据仓库,前端作为用于数据组件通信的用户界面.这种设计非常巧妙,它并行处理两层编程模型,将数据 层从用户界面中分 ...
- js 打开窗口window.open
js改变原有的地址 window.open(webPath+'/index?code='+code,'_self');
- Js-加密
1.base64加密 在页面中引入base64.js文件,调用方法为: <!DOCTYPE HTML> <html> <head> <meta charset ...
- 10 函数的复写-override
1.函数的复写:override 2.使用super调用父类的成员函数 class Person { String name; int age; void introduce() { System.o ...