No EJB receiver to process

I am learning how to deploy EJB on JBoss by following these two tutorials:

So basically I created an EJB project called "EjbComponent" in Netbeans with these two classes:

LibrarySessionBeanRemote.java

package com.test.stateless;

import java.util.List;

public interface LibrarySessionBeanRemote {

void addBook(String bookName);

List getBooks();

}

      

LibrarySessionBean.java

package com.test.stateless;

import java.util.List;
import java.util.ArrayList;
import javax.ejb.Stateless;
import javax.ejb.Remote;

@Stateless
@Remote(LibrarySessionBeanRemote.class)
public class LibrarySessionBean implements LibrarySessionBeanRemote {

List<String> bookShelf;

public LibrarySessionBean(){
    bookShelf = new ArrayList<String>();
}

@Override
public void addBook(String bookName){
    bookShelf.add(bookName);
}

@Override
public List<String> getBooks(){
    return bookShelf;
}
}

      

Then I deploy them to JBoss Server successfully

21:16:13,566 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "EjbComponent.jar" (runtime-name: "EjbComponent.jar")
21:16:13,582 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016002: Processing weld deployment EjbComponent.jar
21:16:13,583 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-5) JNDI bindings for session bean named LibrarySessionBean in deployment unit deployment "EjbComponent.jar" are as follows:

java:global/EjbComponent/LibrarySessionBean!com.test.stateless.LibrarySessionBeanRemote
java:app/EjbComponent/LibrarySessionBean!com.test.stateless.LibrarySessionBeanRemote
java:module/LibrarySessionBean!com.test.stateless.LibrarySessionBeanRemote
java:jboss/exported/EjbComponent/LibrarySessionBean!com.test.stateless.LibrarySessionBeanRemote
java:global/EjbComponent/LibrarySessionBean
java:app/EjbComponent/LibrarySessionBean
java:module/LibrarySessionBean

21:16:13,589 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016005: Starting Services for CDI deployment: EjbComponent.jar
21:16:13,593 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016008: Starting weld service for deployment EjbComponent.jar
21:16:13,735 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS015865: Replaced deployment "EjbComponent.jar" with deployment "EjbComponent.jar"

      

Now, to use this EJB, I am creating a separate java client by creating another project in Netbeans called "Test" with one class:

EJBTester.java

package com.test.client;

import com.test.stateless.LibrarySessionBeanRemote;
import com.test.stateless.LibrarySessionBean;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Hashtable;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.security.Security;
import org.jboss.sasl.JBossSaslProvider;

public class EJBTester {

BufferedReader brConsoleReader = null;

{
    brConsoleReader = new BufferedReader(new InputStreamReader(System.in));
}

public static void main(String[] args) {
    EJBTester ejbTester = new EJBTester();
    ejbTester.testStatelessEjb();
}

private void showGUI(){
    System.out.println("*************************");
    System.out.println("Welcome to the Book Store");
    System.out.println("*************************");
    System.out.print("Options \n1. Add Book\n2. Exit \nEnter Choice:");
}

private void testStatelessEjb(){
    try{
        Hashtable jndiProperties = new Hashtable();
        jndiProperties.put("jboss.naming.client.ejb.context", true);
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        final Context context = new InitialContext(jndiProperties);
        final String appName = "";
        final String moduleName = "EjbComponent";
        final String distinctName = "";
        final String beanName = LibrarySessionBean.class.getSimpleName();
        final String viewClassName = LibrarySessionBeanRemote.class.getName();
        final String lookupPath = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName;
        LibrarySessionBeanRemote libraryBean = (LibrarySessionBeanRemote)context.lookup(lookupPath);
        System.out.println(lookupPath);
        int choice = 0;
        while (choice != 2) {
            String bookName;
            showGUI();
            String strChoice = brConsoleReader.readLine();
            choice = Integer.parseInt(strChoice);
            if (choice == 1) {
               System.out.print("Enter book name: ");
               bookName = brConsoleReader.readLine();
               libraryBean.addBook(bookName);          
            } else if (choice == 2){
               break;
            }
        }
        List<String> booksList = libraryBean.getBooks();
        System.out.println("Book(s) entered so far: " + booksList.size());
        for(String book: booksList){
            System.out.println(book);
        }
        System.out.println("**********Using second lookup to get library statless object");
        LibrarySessionBeanRemote libraryBean1 = (LibrarySessionBeanRemote)context.lookup(lookupPath);
        booksList = libraryBean1.getBooks();
        System.out.println("Book(s) entered so far: " + booksList.size());
        for(String book: booksList){
            System.out.println(book);
        }
        context.close();
    }catch(Exception e){
        e.printStackTrace();
    }finally{
        try{
            if(brConsoleReader != null)
                brConsoleReader.close();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}    
}

      

jboss-ejb-client.properties

endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

remote.connections=default

remote.connection.default.host=127.0.0.1
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

remote.connection.default.username=app1
remote.connection.default.password=pass123

      

When I try to run this application, I get the following error:

run:
Jul 03, 2015 9:28:42 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 1.0.30.Final-redhat-1
ejb:/EjbComponent//LibrarySessionBean!com.test.stateless.LibrarySessionBeanRemote
*************************
Welcome to the Book Store
*************************
Options 
1. Add Book
2. Exit 
Enter Choice:1
Enter book name: abcd

java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:EjbComponent, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@7aec35a
     at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:747)
     at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
     at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
     at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)
     at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)
     at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)
     at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
     at com.sun.proxy.$Proxy0.addBook(Unknown Source)
     at com.test.client.EJBTester.testStatelessEjb(EJBTester.java:58)
     at com.test.client.EJBTester.main(EJBTester.java:25)
 BUILD SUCCESSFUL (total time: 7 seconds)

      

Can anyone tell me where I am making the mistake? I read other threads on stackoverflow pointing out the same problem and tried all their solutions such as including in my code

jndiProperties.put("jboss.naming.client.ejb.context", true);
context.close();

      

but still get the error.

My config info:

  • Netbeans IDE 8.0.2
  • JBoss EAP 6.4
  • Java 1.8.0_45
  • Ubuntu 14.04 64 bit
+3


source to share


1 answer


I was able to reproduce the error with the missing jboss-ejb-client.properties file. Make sure it is placed correctly in your project.

To resolve in my case, I put it in:



Java / CSI

Hope it helps

+3


source







All Articles