0 Replies Latest reply on Jun 24, 2014 8:04 AM by Igor Malinovskyy

    Lookup from remote host does not work.

    Igor Malinovskyy Newbie

      Its works fine to me to lookup ejb for ejb client on local computer.

      When I tried to do same thing on remote computer its does not work.

       

       

         public void connect(String url) throws RepositoryException {

      //    boolean useJvmIL = System.getProperties().containsKey("jboss.server.name");

          this.url = url;

          if (handler != null) {

            System.out.println("connect login");

            loggedInThreads.login(handler, this, null);

          }

       

       

          try {

        

            initContext();

          

            /*repository =

              (ZRepository)context.lookup("ejb:000-zert/ZRepositoryBean/remote");*/

            repository =

              (ZRepository)context.lookup("ejb:000-zert/zert-ejb3/ZRepositoryBean!"

            + ZRepository.class.getName() + "?stateful");

       

            if (repository == null) {

              throw new RepositoryException(I18N.t("Could not lookup repository bean"));

            }

          

            repository.checkDatabaseVersion();

            repository.getRole();

            repository.setUserName(username);

          

            queryManager = new QueryManagerImpl(this);

            securityManager = new SecurityManagerImpl(this);

          

            notificationManager = new NotificationManagerImpl(this, repository);

            openJMSConnections();

          

         

          

         /* } catch (JMSException e) {

            throw new RepositoryException(I18N.t("Failed to setup event queue."), e);

          }*/

            } catch (NamingException e) {

            e.printStackTrace();

            throw new RepositoryException(I18N.t("Failed to lookup interfaces."), e);

          } catch (JMSException e) {

            e.printStackTrace();

            throw new RepositoryException(I18N.t("Failed to lookup interfaces."), e);

          }

           

        }

       

      protected void initContext() throws RepositoryException, NamingException {

       

        //  String credentials = getCredentials();

          Properties clientProperties = new Properties();

          clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED",

                  "false");

          username =  SecurityActions.securityContextGetPrincipal().getName();

       

        

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

          clientProperties.put("remote.connection.default.host", url == null ? "localhost" : url);

          clientProperties.put("remote.connection.default.port", "8080");

       

          clientProperties.put("remote.connection.default.username", username);

          clientProperties.put("remote.connection.default.pasword", SecurityActions.securityContextGetCredential().toString());

          clientProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

          clientProperties.put("remote.connection.provider.create.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT","false");

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

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

          Hashtable<String, String> env = new Hashtable<String, String>();

          if (url != null) {

           EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(clientProperties);

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

           EJBClientContext.setSelector(selector);

           org.jboss.ejb.client.EJBClientContext.getCurrent().registerInterceptor(0, new ClientSecurityInterceptor());

           env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

          }

         // }

        

      //   env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");

      //   env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

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

          env.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

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

          env.put("remote.connection.default.host", url == null ? "localhost" : url);

          env.put("remote.connection.default.port", "8080");

       

          env.put("remote.connection.default.username", username);

          env.put("remote.connection.default.pasword", SecurityActions.securityContextGetCredential().toString());

       

          //clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS","JBOSS-LOCAL-USER");

         // clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT","false");

          env.put("remote.connection.provider.create.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT","false");

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

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

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

          if (url != null) {

            env.put(Context.PROVIDER_URL,"http-remoting://" + url + ":8080");

          }

          env.put("remote.connectionprovider.create.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT","false");

          final EJBClientTransactionContext localUserTxContext = EJBClientTransactionContext.createLocal();

          EJBClientTransactionContext.setGlobalContext(localUserTxContext);

           

          context = new InitialContext(env);

        

        }