Java wildfly swarm:查找ejb远程接口

Java wildfly swarm:查找ejb远程接口,java,ejb-3.0,microservices,wildfly-swarm,Java,Ejb 3.0,Microservices,Wildfly Swarm,我已经生成了两个简单的wildfly swarm项目。第一个是带有远程接口的EJB facade,第二个应该查找它并发送消息。所以第二个应该是作为客户 我习惯了 Wildfly swarm版本2017.9.4 我的EJB外观查找路径: java:global/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote java:app/ejb-one/PingFacade!io.project.co

我已经生成了两个简单的wildfly swarm项目。第一个是带有远程接口的EJB facade,第二个应该查找它并发送消息。所以第二个应该是作为客户

我习惯了 Wildfly swarm版本2017.9.4

我的EJB外观查找路径:

        java:global/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote
        java:app/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote
        java:module/PingFacade!io.project.core.interfaces.PingFacadeRemote
        java:jboss/exported/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote
        java:global/ejb-one/PingFacade
        java:app/ejb-one/PingFacade
        java:module/PingFacade
我的客户:

 public static void main(String[] args) {
        BackendConnectionManager manager = new BackendConnectionManager();
        try {
            manager.getPingFacadeRemote().savePingMessage("halloooooo");
        } catch (NamingException ex) {
            Logger.getLogger(BackendConnectionManager.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    public  PingFacadeRemote getPingFacadeRemote() throws NamingException {
        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,  "org.wildfly.naming.client.WildFlyInitialContextFactory");
              jndiProperties.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");
                 //jndiProperties.put(Context.PROVIDER_URL,"http://localhost:8080");
        final Context context = new InitialContext(jndiProperties);

        return (PingFacadeRemote) context
                .lookup("java:global/ejb-one/PingFacade!io.project.core.interfaces.PingFacadeRemote");
    }
将客户端依赖项添加到pom.xml

 <dependency>
            <groupId>org.wildfly.swarm</groupId>
            <artifactId>ejb-remote</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-naming</artifactId>
        </dependency> 
        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-ejb-client</artifactId>
            <scope>runtime</scope>
        </dependency>  
        <dependency>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-api</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-nio</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.remoting3</groupId>
            <artifactId>jboss-remoting</artifactId>
            <version>3.3.3.Final</version>
            <scope>runtime</scope>
        </dependency>        
        <dependency>
            <groupId>org.jboss.sasl</groupId>
            <artifactId>jboss-sasl</artifactId>
            <scope>runtime</scope>
            <version>1.0.5.Final</version>
        </dependency>     
        <dependency>
            <groupId>org.jboss.marshalling</groupId>
            <artifactId>jboss-marshalling-river</artifactId>
            <scope>runtime</scope>
        </dependency>     
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.jms</groupId>
            <artifactId>jboss-jms-api_2.0_spec</artifactId>
        </dependency>     
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>runtime</scope>
        </dependency>
另外,如何解决在客户端查找中传递安全凭据的问题

这里的项目本身

在BackendConnectionManager.java的第57行中,您试图查找服务java:global/ejbone/PingFacade!io.project.core.interfaces.PingFacadeMote,但它似乎不存在。PingFacadeMote接口是ejb核心模块的一部分。是的,您确实在EJBOne模块中实现了它,但是您在PingFacade.java中将该接口注册为remote@RemotePingFacadeRemote.class


您可以尝试用java:global/ejbcore/PingFacade替换它!io.project.core.interfaces.pingfacadremote.

能否提供您使用的WildFly服务器版本以及重现错误的步骤?
javax.naming.CommunicationException: WFNAM00018: Failed to connect to remote host [Root exception is org.jboss.remoting3.ServiceOpenException: Unknown service name]
    at org.wildfly.naming.client.remote.RemoteContext.getRemoteTransport(RemoteContext.java:80)
    at org.wildfly.naming.client.remote.RemoteContext.lambda$lookupNative$0(RemoteContext.java:106)
    at org.wildfly.naming.client.NamingProvider.performExceptionAction(NamingProvider.java:150)
    at org.wildfly.naming.client.remote.RemoteContext.lookupNative(RemoteContext.java:104)
    at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:74)
    at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:60)
    at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:150)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at io.project.ejbtwo.rest.BackendConnectionManager.getPingFacadeRemote(BackendConnectionManager.java:57)
    at io.project.ejbtwo.rest.BackendConnectionManager.main(BackendConnectionManager.java:43)
Caused by: org.jboss.remoting3.ServiceOpenException: Unknown service name