0 Replies Latest reply on May 3, 2013 10:32 AM by alucardeck1

    Dynamic EJB Destination Server - EJB client context selector may not be changed

    alucardeck1 Newbie

      Hi all,


      can someone help me with a problem?

      i already tried search on google and forum, but i cant make it work.


      I want to: have Dynamic EJB Destination Server.


      1- One main server exists alone. (with methods ready to consume EJBs from another server)

      2- Another server is created somewhere.


      3- Without any XML configuration or restart in server, i create my host/port configuration into Database of both servers.

      4- A @Schedule routine will load this host/port configuration from Database, and start to consume those remote EJB  (bidirectional, Serv1 -> Serv2  and Serv2 -> Serv1)


      I cant make the item 4 work, when i try to set the Selector manually, i get a "EJB client context selector may not be changed" exception.

      is it even possible to change Selector "on fly" ?




      Header 1

      11:23:31,816 INFO  [org.jboss.ejb.client.remoting] (Remoting "config-based-ejb-client-endpoint" task-1) EJBCLIENT000017: Received server version 1 and marshalling strategies [river]

      11:23:31,825 INFO  [org.jboss.ejb.client.remoting] (EJB default - 1) EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@128c871, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection@e486d7,channel=jboss.ejb,nodename=***]} on channel Channel ID 8becc41b (outbound) of Remoting connection 011299e2 to localhost/******


      11:23:31,894 ERROR [org.jboss.as.ejb3] (EJB default - 1) javax.ejb.EJBTransactionRolledbackException: EJBCLIENT000021: EJB client context selector may not be changed

      11:23:31,894 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 1) JBAS014134: A Invocação EJB falhou no SynchronizerBusinessImpl do componente para o *****  throws java.lang.Exception do método: javax.ejb.EJBTransactionRolledbackException: EJBCLIENT000021: EJB client context selector may not be changed



      It works perfectly if i set it all on XML/Config files and let it be hardcoded.

      but when i try the snippet below i get error.


      I though it would be an AS 7.1 error, then i changed to AS 7.2 (EAP 6.1), and i have the same problem.


      My structure (every server is exactly the same project):


      |-- ProjectEJB

      \-- ProjectJSF





      Header 1

      Properties clientProp = new Properties();

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

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

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

              clientProp.put("remote.connection.default.host", "localhost");   //coming from Database, just hardcoded for example

              clientProp.put("remote.connection.default.username", "ejbuser");

              clientProp.put("remote.connection.default.password", "*****");

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


              EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp);

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


              EJBClientContext.setSelector(selector); //<-- EXCEPTION HERE!


              Properties props = new Properties();

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

              Context ctx = new InitialContext(props);


              //i also tried with those

      //        Properties props = new Properties();

      //        props.put("jboss.naming.client.ejb.context", "true");

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

      //        props.put(javax.naming.Context.PROVIDER_URL, "remote://localhost:4447"); //coming from Database, just hardcoded for example

      //        props.put(javax.naming.Context.SECURITY_PRINCIPAL, "ejbuser");

      //        props.put(javax.naming.Context.SECURITY_CREDENTIALS, "*****");

      //        Context ctx = new InitialContext(props);


              String jndi = "ejb:********" // from Database

              IRemote sync = (IRemote)ctx.lookup(jndi);

              AbstractSynchronizedEntity<T> c = sync.send(e);




      I tried with and without the following XMLs/configs, but i am avoiding it cause i dont want it to be "hardcoded" inside XML server, i want it on database to be dynamic:
















      Header 1

      <jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0">



                  <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection"/>








      Header 1

      <?xml version="1.0" encoding="UTF-8"?>




                  <module name="org.jboss.xnio" export="true"/>






      Server standalone.xml:





                <security-realm name="ejb-security-realm">


                          <secret value="*****"/>






      <subsystem xmlns="urn:jboss:domain:remoting:1.1">

                <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>


                      <remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb" username="ejbuser" security-realm="ApplicationRealm">


                              <property name="SASL_POLICY_NOANONYMOUS" value="false"/>

                              <property name="SSL_ENABLED" value="false"/>






      <socket-binding-group ...>


              <outbound-socket-binding name="remote-ejb">

                  <remote-destination host="localhost" port="4447"/>






      if it is possible to change programmatically the destination, I am not sure what config files I should keep too.


      Can someone give me a help plzz?

      I spent 3 days to make it work remotely, and now i cant make it dynamic (i thought it would be easier =/)


      Thanks in advance.