javax.ejb.NoSuchEJBException: EJBCLIENT000079 with JBoss 7.1 and Eclipse

为君一笑 提交于 2020-06-26 14:11:07

问题


I am quite new to JavaEE and tried to get a little Hello World example running (https://ibytecode.com/blog/how-to-create-a-simple-ejb3-project-in-eclipse-jboss-7-1/), but I am stuck with an

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

It is probably only some beginner's error, but I am lost here.

Here is my source code:

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 !!!";
    }

}

I created a JBoss 7.1 Server in Eclipse, started and deployed the HelloWorldSessionBean. That seemed to work well:

...
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
...

Here's the client code:

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());
    }
}

And I put jboss-ejb-client.properties in the class path:

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

When I run the client as plain Java application, I get this output:

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)

I put the jboss-client.jar from $JBOSS-HOME/bin/client in the classpath.

Any suggestions what I did wrong? Thanks a lot!

Edit: Probably, it's worth noting that the NoSuchEJBException occurs because of bean.sayHello(). So, maybe it's not a problem with the lookup, but with the connection?


回答1:


It seems that your lookupName (JNDI) of HelloWorldBean is wrong. Try this:

java:jboss/HelloWorldBean

ALso you can watch this article and find proper JNDI name of your bean on JBOSS admin page. How to find JNDI name in JBoss-7?



来源:https://stackoverflow.com/questions/55022384/javax-ejb-nosuchejbexception-ejbclient000079-with-jboss-7-1-and-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!