javax.ejb.NoSuchEJBException: EJBCLIENT000079 с JBoss 7.1 и Eclipse - PullRequest
1 голос
/ 06 марта 2019

Я довольно новичок в JavaEE и попытался запустить небольшой пример Hello World (https://ibytecode.com/blog/how-to-create-a-simple-ejb3-project-in-eclipse-jboss-7-1/),, но я застрял с

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

Возможно, это ошибка только начинающего, ноЯ потерян здесь.

Вот мой исходный код:

HelloWorld.java

package com.ibytecode.business;
import javax.ejb.Remote;

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

HelloWorldBean.java

package com.ibytecode.businesslogic;
import com.ibytecode.business.HelloWorld;
import javax.ejb.Stateless;

/**
 * Session Bean implementation class HelloWorldBean
 */
@Stateless
public class HelloWorldBean implements HelloWorld {

    public HelloWorldBean() {
    }

    @Override
    public String sayHello() {
        return "Hello World !!!";
    }

}

Я создалСервер JBoss 7.1 в Eclipse, запустил и развернул HelloWorldSessionBean. Это, кажется, хорошо работает:

...
10:23:17,999 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-8) WFLYEJB0473: JNDI bindings for session bean named 'HelloWorldBean' in deployment unit 'deployment "HelloWorldSessionBean.jar"' are as follows:

    java:global/HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld
    java:app/HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld
    java:module/HelloWorldBean!com.ibytecode.business.HelloWorld
    java:jboss/exported/HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld
    java:global/HelloWorldSessionBean/HelloWorldBean
    java:app/HelloWorldSessionBean/HelloWorldBean
    java:module/HelloWorldBean
...

Вот код клиента:

package com.ibytecode.client;

import java.util.Properties;

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

import com.ibytecode.business.HelloWorld;

public class EJBApplicationClient {

    public static void main(String[] args) {
        InitialContext context = null;
        HelloWorld bean = null;
        try {
            Properties properties = new Properties();
            properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
            //properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
            properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
            context = new InitialContext(properties);

            String lookupName = "ejb:/HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld";
            bean = (HelloWorld) context.lookup(lookupName);

        } catch (NamingException e) {
            e.printStackTrace();
        }
        System.out.println(bean.sayHello());
    }
}

И я вставил jboss-ejb-client.properties впуть к классу:

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 = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

remote.connection.default.username=admin
remote.connection.default.password=admin

Когда я запускаю клиент как простое Java-приложение, я получаю следующий вывод:

Mär 07, 2019 2:35:57 PM org.wildfly.naming.client.Version <clinit>
INFO: WildFly Naming version 1.0.7.Final-redhat-1
Mär 07, 2019 2:35:57 PM org.wildfly.security.Version <clinit>
INFO: ELY00001: WildFly Elytron version 1.1.7.Final-redhat-1
Mär 07, 2019 2:35:57 PM org.jboss.ejb.client.naming.ejb.ejbURLContextFactory <clinit>
INFO: EJBCLIENT000064: org.jboss.ejb.client.naming.ejb.ejbURLContextFactory is deprecated; new applications should use org.wildfly.naming.client.WildFlyInitialContextFactory instead
Mär 07, 2019 2:35:57 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 4.0.9.Final-redhat-1
Mär 07, 2019 2:35:57 PM org.jboss.naming.remote.client.InitialContextFactory <clinit>
INFO: WFNAM00025: org.jboss.naming.remote.client.InitialContextFactory is deprecated; new applications should use org.wildfly.naming.client.WildFlyInitialContextFactory instead
Mär 07, 2019 2:35:57 PM org.jboss.ejb.client.legacy.LegacyPropertiesConfiguration configure
INFO: EJBCLIENT000072: Using legacy jboss-ejb-client.properties EJB client configuration
Mär 07, 2019 2:35:57 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.5.4.Final-redhat-1
Mär 07, 2019 2:35:57 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.5.4.Final-redhat-1
Mär 07, 2019 2:35:57 PM org.jboss.ejb.client.legacy.RemotingLegacyConfiguration getConfiguredEndpoint
INFO: EJBCLIENT000070: Using legacy jboss-ejb-client.properties Remoting configuration
Mär 07, 2019 2:35:57 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 5.0.5.Final-redhat-1
Mär 07, 2019 2:35:57 PM org.jboss.ejb.client.legacy.ElytronLegacyConfiguration getConfiguredAuthenticationContext
INFO: EJBCLIENT000069: Using legacy jboss-ejb-client.properties security configuration
Exception in thread "main" javax.ejb.NoSuchEJBException: EJBCLIENT000079: Unable to discover destination for request for EJB StatelessEJBLocator for "/HelloWorldSessionBean/HelloWorldBean", view is interface com.ibytecode.business.HelloWorld, affinity is None
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:567)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
    at org.jboss.ejb.protocol.remote.RemotingEJBClientInterceptor.handleInvocationResult(RemotingEJBClientInterceptor.java:56)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
    at org.jboss.ejb.client.TransactionPostDiscoveryInterceptor.handleInvocationResult(TransactionPostDiscoveryInterceptor.java:133)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
    at org.jboss.ejb.client.DiscoveryEJBClientInterceptor.handleInvocationResult(DiscoveryEJBClientInterceptor.java:108)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
    at org.jboss.ejb.client.NamingEJBClientInterceptor.handleInvocationResult(NamingEJBClientInterceptor.java:78)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
    at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:172)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:569)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:503)
    at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:913)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:177)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:112)
    at com.sun.proxy.$Proxy0.sayHello(Unknown Source)
    at com.ibytecode.client.EJBApplicationClient.main(EJBApplicationClient.java:53)
    Suppressed: java.net.ConnectException: Connection refused: no further information
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at org.xnio.nio.WorkerThread$ConnectHandle.handleReady(WorkerThread.java:327)
        at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
        at ...asynchronous invocation...(Unknown Source)
        at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:570)
        at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:536)
        at org.jboss.remoting3.ConnectionInfo$None.getConnection(ConnectionInfo.java:82)
        at org.jboss.remoting3.ConnectionInfo.getConnection(ConnectionInfo.java:55)
        at org.jboss.remoting3.EndpointImpl.doGetConnection(EndpointImpl.java:487)
        at org.jboss.remoting3.EndpointImpl.getConnectedIdentity(EndpointImpl.java:433)
        at org.jboss.remoting3.Endpoint.getConnectedIdentity(Endpoint.java:122)
        at org.jboss.remoting3.Endpoint.getConnectedIdentity(Endpoint.java:135)
        at org.jboss.remoting3.Endpoint.getConnection(Endpoint.java:212)
        at org.jboss.ejb.client.legacy.RemotingLegacyConfiguration.getConfiguredEndpoint(RemotingLegacyConfiguration.java:81)
        at org.jboss.remoting3.ConfigurationEndpointSupplier$Holder.lambda$static$0(ConfigurationEndpointSupplier.java:58)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.jboss.remoting3.ConfigurationEndpointSupplier$Holder.<clinit>(ConfigurationEndpointSupplier.java:45)
        at org.jboss.remoting3.ConfigurationEndpointSupplier.get(ConfigurationEndpointSupplier.java:84)
        at org.jboss.remoting3.ConfigurationEndpointSupplier.get(ConfigurationEndpointSupplier.java:40)
        at org.wildfly.common.context.ContextManager.getPrivileged(ContextManager.java:282)
        at org.jboss.remoting3.Endpoint.getCurrent(Endpoint.java:80)
        at org.jboss.ejb.protocol.remote.RemotingEJBDiscoveryProvider.<init>(RemotingEJBDiscoveryProvider.java:92)
        at org.jboss.ejb.protocol.remote.RemoteTransportProvider.notifyRegistered(RemoteTransportProvider.java:43)
        at org.jboss.ejb.client.EJBClientContext.<init>(EJBClientContext.java:275)
        at org.jboss.ejb.client.EJBClientContext$Builder.build(EJBClientContext.java:788)
        at org.jboss.ejb.client.ConfigurationBasedEJBClientContextSelector.loadConfiguration(ConfigurationBasedEJBClientContextSelector.java:71)
        at org.jboss.ejb.client.ConfigurationBasedEJBClientContextSelector.<clinit>(ConfigurationBasedEJBClientContextSelector.java:52)
        at org.jboss.ejb.client.EJBClientContext.getDefault(EJBClientContext.java:109)
        at org.wildfly.common.context.ContextManager.getPrivileged(ContextManager.java:282)
        at org.jboss.ejb.client.EJBClientContext.getCurrent(EJBClientContext.java:798)
        at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:161)
        ... 3 more
    Suppressed: java.net.ConnectException: Connection refused: no further information
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at org.xnio.nio.WorkerThread$ConnectHandle.handleReady(WorkerThread.java:327)
        at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
        at ...asynchronous invocation...(Unknown Source)
        at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:570)
        at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:536)
        at org.jboss.remoting3.ConnectionInfo$None.getConnection(ConnectionInfo.java:82)
        at org.jboss.remoting3.ConnectionInfo.getConnection(ConnectionInfo.java:55)
        at org.jboss.remoting3.EndpointImpl.doGetConnection(EndpointImpl.java:487)
        at org.jboss.remoting3.EndpointImpl.getConnectedIdentity(EndpointImpl.java:433)
        at org.jboss.remoting3.UncloseableEndpoint.getConnectedIdentity(UncloseableEndpoint.java:51)
        at org.jboss.ejb.protocol.remote.RemotingEJBDiscoveryProvider.getConnectedIdentityUsingClusterEffective(RemotingEJBDiscoveryProvider.java:311)
        at org.jboss.ejb.protocol.remote.RemotingEJBDiscoveryProvider$DiscoveryAttempt.lambda$connectAndDiscover$0(RemotingEJBDiscoveryProvider.java:384)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.jboss.ejb.protocol.remote.RemotingEJBDiscoveryProvider$DiscoveryAttempt.connectAndDiscover(RemotingEJBDiscoveryProvider.java:384)
        at org.jboss.ejb.protocol.remote.RemotingEJBDiscoveryProvider$DiscoveryAttempt.countDown(RemotingEJBDiscoveryProvider.java:468)
        at org.jboss.ejb.protocol.remote.RemotingEJBDiscoveryProvider$DiscoveryAttempt$1.handleFailed(RemotingEJBDiscoveryProvider.java:350)
        at org.jboss.ejb.protocol.remote.RemotingEJBDiscoveryProvider$DiscoveryAttempt$1.handleFailed(RemotingEJBDiscoveryProvider.java:342)
        at org.xnio.IoFuture$HandlingNotifier.notify(IoFuture.java:215)
        at org.xnio.AbstractIoFuture$NotifierRunnable.run(AbstractIoFuture.java:720)
        at org.jboss.remoting3.EndpointImpl$TrackingExecutor.lambda$execute$0(EndpointImpl.java:926)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

Я помещаю jboss-client.jar из $JBOSS-HOME/bin/client в classpath.

Есть предложения, что я сделал не так? Большое спасибо!

Редактировать: Вероятно, стоит отметить, что исключение NoSuchEJBException происходит из-за bean.sayHello(). Так что, возможно, это не проблема споиск, но с подключением?

1 Ответ

0 голосов
/ 06 марта 2019

Кажется, что ваше lookupName (JNDI) в HelloWorldBean неверно. Попробуйте это:

java:jboss/HelloWorldBean

Также вы можете посмотреть эту статью и найти правильное имя JNDI вашего компонента на странице администратора JBOSS. Как найти имя JNDI в JBoss-7?

...