3 Replies Latest reply on Sep 10, 2013 1:17 PM by ismsteve

    Unable to connect a EJB Client using Wildfly. Same code worked fine in EAP 6.1

    ismsteve

      Here  is my client code:

      1. ========================================================================================================
      2. Code
      3. ========================================================================================================
      4.     public PWSession(String username, String password, String serverIp, String serverPort) throwsCommunicationException, EJBAccessException, NameNotFoundException, NamingException, Exception {
      5.         /**
      6.          * Create connection to jboss Server passing in the user credentials
      7.          */
      8.         this.username = username;
      9.         this.password = password;
      10.         this.serverIp = serverIp;
      11.         this.serverPort = serverPort;
      12.         final EJBClientConfiguration clientConfiguration = new PropertiesBasedEJBClientConfiguration(
      13.                 createClientConfigurationProperties(username, password, serverIp, serverPort));
      14.         // create a context selectorintln("#2");
      15.         ContextSelector<EJBClientContext> contextSelector = null;
      16.         try {
      17.             contextSelector = new ConfigBasedEJBClientContextSelector(clientConfiguration);
      18.         } catch (Exception e) {
      19.             e.printStackTrace();
      20.         }
      21.         EJBClientContext.setSelector(contextSelector);
      22.         try {
      23.             System.out.println("serverIp:"+serverIp);
      24.             System.out.println("serverPort:"+serverPort);
      25.             java.util.Hashtable ht = new java.util.Hashtable();
      26.             ht.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
      27.             ht.put("jboss.naming.client.ejb.context", true);
      28.             ht.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
      29.             ht.put(InitialContext.PROVIDER_URL, "http-remoting://" + serverIp + ":" + serverPort);
      30.             ht.put(InitialContext.SECURITY_PRINCIPAL, username);
      31.             ht.put(InitialContext.SECURITY_CREDENTIALS, password);
      32.             ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
      33.             ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "true");
      34.             ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
      35.             context = new InitialContext(ht);
      36.             facade = (PWFacade)context.lookup("ejb:propworks/business/PWFacadeBean!com.airit.propworks.session.interfaces.PWFacade?stateful");
      37.             user = facade.getAdminDataMgmt().loginAppUser(username, password);
      38.         } catch (Exception e) {
      39.             System.out.println("Error Occurred");
      40.             e.printStackTrace();
      41.         }
      42.     }
      43.     private static Properties createClientConfigurationProperties(String userName, String password, StringserverIp, String serverPort) {
      44.         final Properties properties = new Properties();
      45.         properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
      46.         properties.put("remote.connections", "default");
      47.         properties.put("endpoint.name", "client-endpoint");
      48.         properties.put("remote.connection.default.host", serverIp);
      49.         properties.put("remote.connection.default.port", serverPort);
      50.         properties.put("remote.connection.default.username", userName);
      51.         properties.put("remote.connection.default.password", password);
      52.         return properties;
      53.     }

      54. Here is the Error I get.
      55. =================================================================================================================
      56. Error Message
      57. =================================================================================================================
      58. serverIp:10.10.10.151
      59. serverPort:8080
      60. Error Occurred
      61. javax.naming.NamingException: Failed to create proxy [Root exception is java.lang.IllegalStateException:EJBCLIENT000024: No EJB receiver available for handling [appName:propworks, moduleName:business, distinctName:]combination]
      62.         at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:195)
      63.         at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:176)
      64.         at javax.naming.InitialContext.lookup(Unknown Source)
      65.         at com.airit.propworks.gui.session.PWSession.<init>(Unknown Source)
      66.         at com.airit.propworks.gui.Login$GetSessionWorker.doInBackground(Unknown Source)
      67.         at com.airit.propworks.gui.Login$GetSessionWorker.doInBackground(Unknown Source)
      68.         at javax.swing.SwingWorker$1.call(Unknown Source)
      69.         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      70.         at java.util.concurrent.FutureTask.run(Unknown Source)
      71.         at javax.swing.SwingWorker.run(Unknown Source)
      72.         at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      73.         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      74.         at java.lang.Thread.run(Unknown Source)
      75. Caused by: java.lang.IllegalStateException: EJBCLIENT000024: No EJB receiver available for handling[appName:propworks, moduleName:business, distinctName:] combination
      76.         at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:807)
      77.         at org.jboss.ejb.client.EJBClient.createSessionWithPossibleRetries(EJBClient.java:222)
      78.         at org.jboss.ejb.client.EJBClient.createSession(EJBClient.java:202)
      79.         at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:216)
      80.         at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:193)
      81.         ... 12 more

      82. I am using the vanilla  ejb3 sub system configuration that ships with wildfly. I only changed I made to my client code was the PROVIDER_URL. I changed from remote: to http-remoting.