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 远程调用的更多相关文章

  1. weblogic的ejb远程调用

    这是一篇对EJB远程调用的简单范例.      1.环境:win7  + weblogic 12c + myeclipse8.5      2.目的:实现在myeclispe中对weblogic中EJ ...

  2. Ejb远程调用-jboss服务器调用服务器-Bean调用Bean

    英文参考地址 https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+o ...

  3. 远程调用jboss as 7上部署的ejb出现No EJB receiver available for handling 异常

    昨天倒腾了一天终于配置好了jboss as 7的域,今天又倒腾了一整天在上面部署了个EJB,然后试了一个利用JNDI来进行远程调用.下面记录一下过程中那些乱七八糟的问题: 首先是这个jboss-cli ...

  4. JavaEE(8) - 本地和远程调用的有状态以及无状态Session EJB

    1. 使用NetBeans开发Session Bean #1. 创建项目:File-->New Project-->Java EE-->EJB Module #2. 在项目中创建Se ...

  5. Spring远程调用技术<1>-RMI

    在java中,我们有多种可以使用的远程调用技术 1.远程方法调用(remote method invocation, RMI)  适用场景:不考虑网络限制时(例如防火墙),访问/发布基于java的服务 ...

  6. EJB的调用

    EJB调用.html :first-child{margin-top:0!important}img.plugin{box-shadow:0 1px 3px rgba(0,0,0,.1);border ...

  7. tomee 第一个 远程调用 Session Bean

    参考文档 http://tomee.apache.org/ http://download.oracle.com/otndocs/jcp/ejb-3.1-pfd-oth-JSpec/ http://d ...

  8. JSON-RPC轻量级远程调用协议介绍及使用

    这个项目能够帮助开发人员利用Java编程语言轻松实现JSON-RPC远程调用.jsonrpc4j使用Jackson类库实现Java对象与JSON对象之间的相互转换.jsonrpc4j包含一个JSON- ...

  9. Java[2] 分布式服务架构之java远程调用技术浅析(转http://www.uml.org.cn/zjjs/201208011.asp)

    转自:http://www.uml.org.cn/zjjs/201208011.asp 在分布式服务框架中,一个最基础的问题就是远程服务是怎么通讯的,在Java领域中有很多可实现远程通讯的技术,例如: ...

随机推荐

  1. Lucene.Net的服务器封装+APi组件 (开源)

    为什么要封装 真不知道用什么标题合适,我这几天在研究Lucene.Net,觉得把Lucene.Net封装为一个独立的服务器,再提供一个给客户端调用的Api组件应该是一件很意思的事,主要优势有以下: 1 ...

  2. [BZOJ 2819]NIM(dfs序维护树上xor值)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2819 分析: 树上的nim游戏,关键就是要判断树上的一条链的异或值是否为0 这个题目有 ...

  3. The median of multi ascending array

    Given 17 arrays,every array is ascending.The task is to get the median of all these numbers. 0 1 2 3 ...

  4. Hibernate 的dialect 大全

    RDBMS 方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB2 OS3 ...

  5. 访问HTML元素(节点)

    访问HTML元素等同于访问节点,能够以不同的 方式来访问HTML元素: 通过使用 getElementById() 方法 通过使用 getElementsByTagName() 方法 通过使用 get ...

  6. 1025基础REDIS

    -- 登录AUTHPING -- 通用命令EXISTS KEY EXPIRE KEY seconds 为给定 KEY 设置过期时间 -- 字符SET runoobkey redisDEL runoob ...

  7. android中通话录音

    file = new File(Environment.getExternalStorageDirectory(), this.incomeNumber + System.currentTimeMil ...

  8. ps打造逼真印章效果

    新建500*500px--->路径工具 最后通过 通道扣取选取,填充白色,即可

  9. zabbix 监控MySQL

    现在我来说一下我的监控环境 zabbix-3.0.3 MySQL-5.6.23 1.首先我们要登录MySQL,创建一个监控MySQL的用户 GRANT USAGE,PROCESS,SUPER,REPL ...

  10. 【BZOJ 3242】【UOJ #126】【CodeVS 3047】【NOI 2013】快餐店

    http://www.lydsy.com/JudgeOnline/problem.php?id=3242 http://uoj.ac/problem/126 http://codevs.cn/prob ...