无法访问以7身份部署在jboss中的EJB [英] Unable to access an EJB deployed in jboss as 7

查看:91
本文介绍了无法访问以7身份部署在jboss中的EJB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Jboss As 7.0中部署了EJB.

I have deployed an EJB in Jboss As 7.0.

以下是部署日志中有关EJB的JNDI绑定的内容.

Following is what the deployment logs says about the JNDI binding of EJB.

19:21:43,269信息[org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor](MSC服务线程1-1)名为的会话Bean的JNDI绑定部署单元部署"EJBTest1.jar"中的ManageEmployeeBean如下如下:

19:21:43,269 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named ManageEmployeeBean in deployment unit deployment "EJBTest1.jar" are as follows:

java:global/EJBTest1/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemotejava:app/EJBTest1/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemotejava:module/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemotejava:jboss/exported/EJBTest1/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemotejava:global/EJBTest1/ManageEmployeeBeanjava:app/EJBTest1/ManageEmployeeBean java:module/ManageEmployeeBean

java:global/EJBTest1/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemote java:app/EJBTest1/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemote java:module/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemote java:jboss/exported/EJBTest1/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemote java:global/EJBTest1/ManageEmployeeBean java:app/EJBTest1/ManageEmployeeBean java:module/ManageEmployeeBean

这是我的客户类的样子.

This is how my client class looks like.

package com.test.ejb.test;

import java.util.Hashtable;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.test.ejb.bean.Employee;
import com.test.ejb.businessimpl.ManageEmployeeBean;
import com.test.ejb.businessimpl.ManageEmployeeBeanRemote;

public class Client {

    private static InitialContext initialContext;

    public static void main(String[] args){
        try {
            getInitialContext();
            System.out.println("CTX:"+initialContext);
        } catch (NamingException e) {
            e.printStackTrace();
        }

        try {
            System.out.println("Looking up EJB !!");
            ManageEmployeeBeanRemote remote = 
                    (ManageEmployeeBeanRemote)initialContext.lookup("/EJBTest1/ManageEmployeeBean!com.test.ejb.businessimpl.ManageEmployeeBeanRemote");
            System.out.println("setting employee..............");
            Employee employee = new Employee();
            employee.setFirstName("Renjith");
            employee.setLastName("Ravi");

            System.out.println("Adding employee");
            remote.addEmployee(employee);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    public static InitialContext getInitialContext() throws NamingException {
        if (initialContext == null) {
            Properties prop = new Properties();
            prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            prop.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
            prop.put(Context.PROVIDER_URL, "remote://localhost:4447");
            prop.put(Context.SECURITY_PRINCIPAL, "renjith");
            prop.put(Context.SECURITY_CREDENTIALS, "user");
            initialContext = new InitialContext(prop);
        }
        return initialContext;
    }


}

运行我的客户端时找不到该服务.

Client is not able to find the service when I run it.

CTX:javax.naming.InitialContext@40964823
Looking up EJB !!
javax.naming.CommunicationException: Could not obtain connection to any of these urls: remote://localhost:4447 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server remote:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server remote:1099 [Root exception is java.net.UnknownHostException: remote: Name or service not known]]]
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1416)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:596)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at com.test.ejb.test.Client.main(Client.java:29)
Caused by: javax.naming.CommunicationException: Failed to connect to server remote:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server remote:1099 [Root exception is java.net.UnknownHostException: remote: Name or service not known]]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1387)
    ... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server remote:1099 [Root exception is java.net.UnknownHostException: remote: Name or service not known]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
    ... 5 more
Caused by: java.net.UnknownHostException: remote: Name or service not known
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
    at java.net.InetAddress.getAllByName(InetAddress.java:1162)
    at java.net.InetAddress.getAllByName(InetAddress.java:1098)
    at java.net.InetAddress.getByName(InetAddress.java:1048)
    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:76)
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
    ... 5 more

有人可以告诉我我在这里想念什么吗?我在stackoverflow中看到了很多关于类似主题的线程,但是它们都没有帮助我!

Can anyone tell me what am i missing here? I saw lots of threads on similar topic in stackoverflow, but none of them helped me!!

推荐答案

您正尝试使用JBoss AS 5(或更早版本)的EJB Remote客户端.

You are attempting to use the EJB Remote client from JBoss AS 5 (or earlier).

您需要使用JBoss AS 7 EJB Remote客户端并根据 Remote JNDI 标题下的ASf J7DI参考.

You need to use the JBoss AS 7 EJB Remote client and configure it as per the documentation at AS7 JNDI Reference under the Remote JNDI heading.

这篇关于无法访问以7身份部署在jboss中的EJB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆