JBoss Community

JBoss 7 and Ejb remote call with security

new comment by xiang yingbing View all comments on this document

The correct solution is: https://community.jboss.org/thread/196169?tstart=0

 

At last, my client works after I fixed above bugs and added some properties:

 

package mate.test;

 

import java.util.Properties;

 

import javax.naming.Context;

import javax.naming.InitialContext;

 

import org.jboss.ejb.client.ContextSelector;

import org.jboss.ejb.client.EJBClientConfiguration;

import org.jboss.ejb.client.EJBClientContext;

import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;

import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;

 

public class Client1 {

    public static void main(String[]args) throws Exception{

        String jndiName = "ejb:TestEar/TestEjb//TestBean!" + TestBeanRemote.class.getName();//ear:good

       

        Properties p = new Properties();

        {

            p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");

            p.put("remote.connections", "default");

            p.put("remote.connection.default.host", "192.168.1.100");

            p.put("remote.connection.default.port", "4447");

            p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "true");

            p.put("remote.connection.default.username", "testX");

            p.put("remote.connection.default.password", "test1234");           

           

            p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");

            p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");  

        }

       

        EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);

        ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);

        EJBClientContext.setSelector(selector);

 

        Properties props = new Properties();

        props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

        InitialContext context = new InitialContext(props);

       

        TestBeanRemote vLookup = (TestBeanRemote) context.lookup(jndiName);

        

        System.out.println("x" + vLookup.getNameFree());

        System.out.println("x" + vLookup.getName());

    }

}

 

 

The log:

 

INFO: JBoss EJB Client version 1.0.5.Final

xname testX true

xname testX true

 

 

 

Anyway, thank you Mates. I can NOT find any better example that has an EJB client. ;\