Armen Arzumanyan
Armen Arzumanyan

Reputation: 2053

wildfly 8.2.0: ejb remote client fails when pass object to the server

Strange behavior with remote client. when I call ejb facade method count, it is work and return user count. but when I passed object, it was fails! with error

EJBCLIENT000025: No EJB receiver available for handling [appName:writer-ear, moduleName:writer-ejb-1.0, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@331e965f

I am configured all possible ways, but still remote client fails.

for example

/////////////////////////////
        // The "standard" JNDI lookup
        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        //jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); // needed for a login module that requires the password in plaintext
        jndiProperties.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
        //  jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
        jndiProperties.put(Context.SECURITY_PRINCIPAL, "user");
        jndiProperties.put(Context.SECURITY_CREDENTIALS, "pass");
        jndiProperties.put("jboss.naming.client.ejb.context", true);
        final Context context = new InitialContext(jndiProperties);

        traverseJndiNode("/", context);
        final UserFacadeRemote helloWorld = (UserFacadeRemote) context.lookup("writer-ear/writer-ejb-1.0/userFacade!" + UserFacadeRemote.class.getName());
        System.out.println("count " + helloWorld.count());
        UserDTO user = new UserDTO();
        user.setEmail("[email protected]");
        user.setFirstname("Nina");
        user.setLastname("Ben");
        user.setPassword("Password");
        user.setRegisteredDate(new Date(System.currentTimeMillis()));
        helloWorld.save(user);
        context.close();

Actually save method is fake method

 @Override
    public void save(UserDTO user) {
        System.out.println("Received object " + user.getFirstname());
        try {

            System.out.println("Saving object ");

        } catch (Exception e) {
            e.printStackTrace();
        }    
    }

the same in second lookup

// Using the proprietary JBoss EJB Client API
        final Properties ejbProperties = new Properties();
        ejbProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
        ejbProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        ejbProperties.put("remote.connections", "1");
        ejbProperties.put("remote.connection.1.host", "localhost");
        ejbProperties.put("remote.connection.1.port", 8080);
        //ejbProperties.put("remote.connection.1.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER"); // needed for forcing authentication over remoting (i.e. if you have a custom login module)
        //ejbProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false"); // needed for a login module that requires the password in plaintext
        ejbProperties.put("remote.connection.1.username", "user");
        ejbProperties.put("remote.connection.1.password", "pass");
        ejbProperties.put("org.jboss.ejb.client.scoped.context", "true"); // Not needed when EJBClientContext.setSelector is called programatically. ATTENTION: Client-Interceptor registration below does not work with this property! BUG?

        final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(ejbProperties);
        final ConfigBasedEJBClientContextSelector selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
        EJBClientContext.setSelector(selector);
        EJBClientContext.getCurrent().registerInterceptor(0, new ClientInterceptor());

        final Context ejbContext = new InitialContext(ejbProperties);
        final UserFacadeRemote ejbHelloWorld = (UserFacadeRemote) ejbContext.lookup("ejb:writer-ear/writer-ejb-1.0/userFacade!" + UserFacadeRemote.class.getName());
//        UserDTO user = new UserDTO();
//        user.setEmail("[email protected]");
//        user.setFirstname("Nina");
//        user.setLastname("Ben");
//        user.setPassword("Password");
//        user.setRegisteredDate(new Date(System.currentTimeMillis()));
//        ejbHelloWorld.save(user);
        System.out.println("second count " + ejbHelloWorld.count());

My client application run under tomcat, so whats wrong? Why I can get count even from database, but when pass DTO, client fails. I explored a lot, with old versions of JBoss I did the same not one time.

Upvotes: 0

Views: 775

Answers (1)

Armen Arzumanyan
Armen Arzumanyan

Reputation: 2053

Oh, I forgot set my DTO implements Serializable interface :(

public class UserDTO implements Serializable{

    private static final long serialVersionUID = 1L;

    private Long id;

Upvotes: 1

Related Questions