zoukankan      html  css  js  c++  java
  • 远程调用jboss as 7上部署的ejb出现No EJB receiver available for handling 异常

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

    首先是这个jboss-client.properties文件,各个属性值的含义可以从jboss的官方文档上得到解释https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

    1 endpoint.name=client-endpoint
    2 remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
    3 remote.connections=default
    4 remote.connection.default.host=192.168.1.33
    5 remote.connection.default.port=4447
    6 remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
    7 remote.connection.default.username=mosmith
    8 remote.connection.default.password=MTIzNDU2

    endpoint.name是个可选的参数,用于EJB Receiver创建连接所用的名称,如果不设置将使用默认值:config-based-ejb-client-endpoint

    remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false官方上说是用在创建connection provider 上处理 remote://协议的参数,但具体是什么没有说,照这名字看来好像与安全有关的(纯属猜测)

    remote.connections=default,这是指定连接配置名的,我们可以创建多个配置,具体做法请看官方文档

    上面需要注意的是:

    username是Jboss中application user 中的用户

    password这个属性是用用户密码的base64编码。

    下面是我的程序远程调用代码,基本和官方给出的一样:

     1 package com.bes.training.ejb.EJBRemoteInvocation;
     2 
     3 import com.bes.training.ejb.Helloworld.*;
     4 
     5 import javax.naming.*;
     6 import java.util.*;
     7 
     8 public class RemoteInvocationDemo {
     9     public static void main(String[] args){
    10 
    11         Hashtable<String,String> jndiProperties=new Hashtable<String,String>();
    12         jndiProperties.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming");
    13         //jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory");
    14         jndiProperties.put("jboss.naming.client.ejb.context","true");
    15         
    16         try{
    17             Context context=new InitialContext(jndiProperties);
    18             Object obj=context.lookup("ejb:/temp//SayHelloImpl!com.bes.training.ejb.Helloworld.SayHelloImplRemote" );
    19             
    20             SayHelloImplRemote intf=(SayHelloImplRemote) obj;
    21             String result=intf.sayHello("Mosmith");
    22             System.out.println(result);
    23             
    24         }catch(NamingException e){
    25             System.out.println(e.getMessage());
    26             e.printStackTrace();
    27         }
    28     }
    29 }

    但是在eclipse中运行的时候出现了No EJB receiver available for handling的异常:倒腾了好长时间,于是怀疑-Djboss.ejb.client.properties.file.path=jndi.properties参数没有起作用,于是在命令行下运行了一下,正常!回eclipse仔细检查,发现是参数的设置错了:

    应该设置在VM arguments而不是Program arguments里。初学者一定要注意这里的区别啊。

  • 相关阅读:
    ActiveMQ 即时通讯服务 浅析
    Asp.net Mvc (Filter及其执行顺序)
    ActiveMQ基本介绍
    ActiveMQ持久化消息的三种方式
    Windows Azure Virtual Machine (27) 使用psping工具,测试Azure VM网络连通性
    Azure China (10) 使用Azure China SAS Token
    Windows Azure Affinity Groups (3) 修改虚拟网络地缘组(Affinity Group)的配置
    Windows Azure Storage (22) Azure Storage如何支持多级目录
    Windows Azure Virtual Machine (26) 使用高级存储(SSD)和DS系列VM
    Azure Redis Cache (2) 创建和使用Azure Redis Cache
  • 原文地址:https://www.cnblogs.com/mosmith/p/4248591.html
Copyright © 2011-2022 走看看