【问题标题】:How can I solve EJBCLIENT000079 Exception in thread "main" javax.ejb.NoSuchEJBException?如何解决线程“main”javax.ejb.NoSuchEJBException 中的 EJBCLIENT000079 异常?
【发布时间】:2017-12-03 12:01:11
【问题描述】:

我想用 Intellij IDEA 做一个 EJB 项目。但是有一个错误。我的项目在一个项目中有两个模型,一个是服务器,另一个是客户端。我想启动服务器并运行客户端来执行 sayHello 函数,但失败了。

我的 SessionBean 接口和客户端接口

package com.ejb;

import javax.ejb.Remote;

@Remote
public interface HelloWorld {
    public String sayHello(String world);
}

我的 SessionBean 类

import com.ejb.HelloWorld;

import javax.ejb.Stateless;

@Stateless(name = "HelloWorldEJB")
public class HelloWorldBean implements HelloWorld {
    public HelloWorldBean() {
    }

    @Override
    public String sayHello(String world) {
        return "hello"+world;
    }
}

我的客户类

package com.ejb;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;

public class HelloWorldClient {
    private static HelloWorld lookupRemoteStatelessEjbBean() throws NamingException {
        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        jndiProperties.put("jboss.naming.client.ejb.context", true);
        final Context context = new InitialContext(jndiProperties);
        String namespace="ejb:/EJBServer_war_exploded/HelloWorldEJB!com.ejb.HelloWorld";
        return (HelloWorld) context.lookup(namespace);
    }
    public static void main(String[] args) throws NamingException {
        HelloWorld helloWorld = lookupRemoteStatelessEjbBean();
        System.out.println(helloWorld);
        String s = helloWorld.sayHello("world");
        System.out.println(s);
    }
}

我的属性(这个属性已经完全放在src文件夹中了)

endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=admin
remote.connection.default.password=123456

首先我启动服务器和intellij IDEA自动将war文件夹放入JBOSS(WildFly) 11.我访问了EJB amdin网站,war文件夹完全在服务器中。 错误代码是

Exception in thread "main" javax.ejb.NoSuchEJBException: EJBCLIENT000079: Unable to discover destination for request for EJB StatelessEJBLocator for "/EJBServer_war_exploded/HelloWorldEJB", view is interface com.ejb.HelloWorld, affinity is None

我不知道如何解决,我在bing和google上搜索过。没有人有同样的问题,我该如何解决?

【问题讨论】:

    标签: jakarta-ee intellij-idea jboss ejb wildfly


    【解决方案1】:

    对于 WildFly11,使用以下配置:

    jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory"); jndiProperties.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");

    代替:

    jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); jndiProperties.put("jboss.naming.client.ejb.context", true);

    【讨论】:

    • 这不是解决方案
    【解决方案2】:

    就我而言,替换字符串

    namespace="ejb:/EJBServer_war_exploded/HelloWorldEJB!com.ejb.HelloWorld";
    

    与 字符串

    namespace="ejb:/EJBServer_war_exploded/HelloWorldBean!com.ejb.HelloWorld";
    

    【讨论】:

    • 非常感谢。为我工作。
    猜你喜欢
    • 2015-09-19
    • 2015-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-14
    • 2015-06-13
    • 2011-10-26
    • 1970-01-01
    相关资源
    最近更新 更多