Search code examples
javaejbwildflyjndiremote-access

Remote Connection to EJB working on localhost but fails on 127.0.0.1 and another server


I just learning ejb remote on wildfly 12 server. I have successfully connected to ejb in my the same computer with jboss-ejb-client.properties when accessing the same JVM with localhost (Working example) :

remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=8080

when I try to access the same ejb using 127.0.0.1 than localhost , it waits so long and nothing happens without displaying any erroe. Here is the jboss-ejb-client.properties when accessing server on the same JVM with 127.0.0.1 (Failure example) :

 remote.connections=default
 remote.connection.default.host=127.0.0.1
 remote.connection.default.port=8080

I also deploy the same ejb service to another computer with ip 192.168.1.101 and changed host and set password credientials accordingly and try to access but the same endless wait happen again. Here is the jboss-ejb-client.properties when accessing to another server at 192.168.1.101 (Failure example):

remote.connections=default
remote.connection.default.host=192.168.1.101
remote.connection.default.port=8080
remote.connection.default.username=username
remote.connection.default.password=**password
remote.connection.default.connect.timeout=3000

build.gradle is :

// https://mvnrepository.com/artifact/org.jboss.spec.javax.transaction/jboss-transaction-api_1.2_spec
api  group: 'org.jboss.spec.javax.transaction', name: 'jboss-transaction-api_1.2_spec', version: '1.1.1.Final'
       // https://mvnrepository.com/artifact/org.jboss.spec.javax.ejb/jboss-ejb-api_3.2_spec
    api group: 'org.jboss.spec.javax.ejb', name: 'jboss-ejb-api_3.2_spec', version: '1.0.1.Final'
        // https://mvnrepository.com/artifact/org.jboss/jboss-ejb-client
    api group: 'org.jboss', name: 'jboss-ejb-client', version: '4.0.10.Final'
        // https://mvnrepository.com/artifact/org.jboss.xnio/xnio-api
    api group: 'org.jboss.xnio', name: 'xnio-api', version: '3.6.3.Final'
        // https://mvnrepository.com/artifact/org.jboss.xnio/xnio-nio
    api group: 'org.jboss.xnio', name: 'xnio-nio', version: '3.6.3.Final'
        // https://mvnrepository.com/artifact/org.jboss.remoting/jboss-remoting
    api group: 'org.jboss.remoting', name: 'jboss-remoting', version: '5.0.7.Final'
        // https://mvnrepository.com/artifact/org.jboss.sasl/jboss-sasl
    api group: 'org.jboss.sasl', name: 'jboss-sasl', version: '1.0.5.Final'
        // https://mvnrepository.com/artifact/org.jboss.marshalling/jboss-marshalling-river
    api group: 'org.jboss.marshalling', name: 'jboss-marshalling-river', version: '2.0.5.Final'

And context lookup procedure :

 Properties props = new Properties();
    props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

InitialContext ic = new InitialContext(props);
Calculator calc = (Calculator) ic.lookup("ejb:/ejbtest-service-1.0/CalculatorService!com.testejb.model.Calculator");

Is there some thing missing ?


Solution

  • I would recommend following this example project

    https://github.com/wildfly/quickstart/tree/12.x/ejb-remote

    The default mode us using local auth (which works on file permissions) where as the HTTP example uses true auth

    This example shows how to use auth as well

    https://github.com/wildfly/quickstart/blob/12.x/ejb-security/src/main/resources/wildfly-config.xml

    Where as the first example (https://github.com/wildfly/quickstart/blob/12.x/ejb-remote/client/src/main/resources/META-INF/wildfly-config.xml) used

     <property key="wildfly.sasl.local-user.quiet-auth" value="true" />