Unable to connect a EJB Client using Wildfly. Same code worked fine in EAP 6.1
ismsteve Sep 9, 2013 2:08 PMHere is my client code:
- ========================================================================================================
- Code
- ========================================================================================================
- public PWSession(String username, String password, String serverIp, String serverPort) throwsCommunicationException, EJBAccessException, NameNotFoundException, NamingException, Exception {
- /**
- * Create connection to jboss Server passing in the user credentials
- */
- this.username = username;
- this.password = password;
- this.serverIp = serverIp;
- this.serverPort = serverPort;
- final EJBClientConfiguration clientConfiguration = new PropertiesBasedEJBClientConfiguration(
- createClientConfigurationProperties(username, password, serverIp, serverPort));
- // create a context selectorintln("#2");
- ContextSelector<EJBClientContext> contextSelector = null;
- try {
- contextSelector = new ConfigBasedEJBClientContextSelector(clientConfiguration);
- } catch (Exception e) {
- e.printStackTrace();
- }
- EJBClientContext.setSelector(contextSelector);
- try {
- System.out.println("serverIp:"+serverIp);
- System.out.println("serverPort:"+serverPort);
- java.util.Hashtable ht = new java.util.Hashtable();
- ht.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
- ht.put("jboss.naming.client.ejb.context", true);
- ht.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
- ht.put(InitialContext.PROVIDER_URL, "http-remoting://" + serverIp + ":" + serverPort);
- ht.put(InitialContext.SECURITY_PRINCIPAL, username);
- ht.put(InitialContext.SECURITY_CREDENTIALS, password);
- ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
- ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "true");
- ht.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
- context = new InitialContext(ht);
- facade = (PWFacade)context.lookup("ejb:propworks/business/PWFacadeBean!com.airit.propworks.session.interfaces.PWFacade?stateful");
- user = facade.getAdminDataMgmt().loginAppUser(username, password);
- } catch (Exception e) {
- System.out.println("Error Occurred");
- e.printStackTrace();
- }
- }
- private static Properties createClientConfigurationProperties(String userName, String password, StringserverIp, String serverPort) {
- final Properties properties = new Properties();
- properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
- properties.put("remote.connections", "default");
- properties.put("endpoint.name", "client-endpoint");
- properties.put("remote.connection.default.host", serverIp);
- properties.put("remote.connection.default.port", serverPort);
- properties.put("remote.connection.default.username", userName);
- properties.put("remote.connection.default.password", password);
- return properties;
- }
- Here is the Error I get.
- =================================================================================================================
- Error Message
- =================================================================================================================
- serverIp:10.10.10.151
- serverPort:8080
- Error Occurred
- 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]
- at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:195)
- at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:176)
- at javax.naming.InitialContext.lookup(Unknown Source)
- at com.airit.propworks.gui.session.PWSession.<init>(Unknown Source)
- at com.airit.propworks.gui.Login$GetSessionWorker.doInBackground(Unknown Source)
- at com.airit.propworks.gui.Login$GetSessionWorker.doInBackground(Unknown Source)
- at javax.swing.SwingWorker$1.call(Unknown Source)
- at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
- at java.util.concurrent.FutureTask.run(Unknown Source)
- at javax.swing.SwingWorker.run(Unknown Source)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
- at java.lang.Thread.run(Unknown Source)
- Caused by: java.lang.IllegalStateException: EJBCLIENT000024: No EJB receiver available for handling[appName:propworks, moduleName:business, distinctName:] combination
- at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:807)
- at org.jboss.ejb.client.EJBClient.createSessionWithPossibleRetries(EJBClient.java:222)
- at org.jboss.ejb.client.EJBClient.createSession(EJBClient.java:202)
- at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:216)
- at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:193)
- ... 12 more
- 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.