4 Replies Latest reply on Dec 10, 2015 3:35 PM by taichimaster84

    i m new to willdfy and i m getting errors on  configuring jndi for remote ejb application

    taichimaster84

      this is what i see on the console of eclipse;

       

       

      dic 08, 2015 3:42:14 PM org.jboss.ejb.client.EJBClient <clinit>

      INFO: JBoss EJB Client version 2.0.0.Final

      **********************

      Welcome to Book Store

      **********************

      Options

      1. Add Book

      2. Exit

      Enter Choice: 1

      Enter book name: fg

      EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:EjbComponent, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@5cb0d902

      java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:EjbComponent, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@5cb0d902

        at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:749)

        at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)

        at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183)

        at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253)

        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198)

        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)

        at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)

        at com.sun.proxy.$Proxy0.addBook(Unknown Source)

        at com.tutorialspoint.test.EJBTester.testStatelessEjb(EJBTester.java:48)

        at com.tutorialspoint.test.EJBTester.main(EJBTester.java:26)

       

      can someone help me?

        • 1. Re: i m new to willdfy and i m getting errors on  configuring jndi for remote ejb application
          mayerw01

          I think it may help if you post your source code.

          But you could try to add this property:  

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

          • 2. Re: i m new to willdfy and i m getting errors on  configuring jndi for remote ejb application
            taichimaster84

            i tried it but it's not working maybe  im missing some library , this is my client code:

             

            package com.tutorialspoint.test;

             

             

            import java.io.BufferedReader;

            import java.io.IOException;

            import java.io.InputStreamReader;

            import java.util.List;

            import java.util.Properties;

             

             

            import javax.naming.Context;

            import javax.naming.InitialContext;

            import javax.naming.NamingException;

             

             

            import com.tutorialspoints.stateless.LibrarySessionBean;

            import com.tutorialspoints.stateless.LibrarySessionBeanRemote;

             

             

            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 Book Store");

              System.out.println("**********************");

              System.out.print("Options \n1. Add Book\n2. Exit \nEnter Choice: ");

              }

             

             

              private void testStatelessEjb() {

              try {

              int choice = 1;

              LibrarySessionBeanRemote libraryBean = lookupRemoteStatelessLibrarySession();

              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 (int i = 0; i < booksList.size(); ++i) {

              System.out.println((i + 1) + ". " + booksList.get(i));

              }

             

             

              LibrarySessionBeanRemote libraryBean1 = lookupRemoteStatelessLibrarySession();

              List<String> booksList1 = libraryBean1.getBooks();

              System.out

              .println("***Using second lookup to get library stateless object***");

              System.out.println("Book(s) entered so far: " + booksList1.size());

              for (int i = 0; i < booksList1.size(); ++i) {

              System.out.println((i + 1) + ". " + booksList1.get(i));

              }

              } catch (Exception e) {

              System.out.println(e.getMessage());

              e.printStackTrace();

              } finally {

              try {

              if (brConsoleReader != null) {

              brConsoleReader.close();

              }

              } catch (IOException ex) {

              System.out.println(ex.getMessage());

              }

              }

              }

             

             

              private static LibrarySessionBeanRemote lookupRemoteStatelessLibrarySession()

              throws NamingException {

              

              Properties prop = new Properties();

              

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

              prop.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");

              prop.put(Context.SECURITY_PRINCIPAL, "username");

              prop.put(Context.SECURITY_CREDENTIALS, "password");

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

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

              

              Context context = new InitialContext(prop);

             

             

              // The app name is the application name of the deployed EJBs. This is

              // typically the ear name

              // without the .ear suffix. However, the application name could be

              // overridden in the application.xml of the

              // EJB deployment on the server.

              // Since we haven't deployed the application as a .ear, the app name for

              // us will be an empty string

              final String appName = "";

              // This is the module name of the deployed EJBs on the server. This is

              // typically the jar name of the

              // EJB deployment, without the .jar suffix, but can be overridden via

              // the ejb-jar.xml

              // In this example, we have deployed the EJBs in a

              // jboss-as-ejb-remote-app.jar, so the module name is

              // jboss-as-ejb-remote-app

              final String moduleName = "EjbComponent";

              // AS7 allows each deployment to have an (optional) distinct name. We

              // haven't specified a distinct name for

              // our EJB deployment, so this is an empty string

              final String distinctName = "";

              // The EJB name which by default is the simple class name of the bean

              // implementation class

              final String beanName = LibrarySessionBean.class.getSimpleName();

              // the remote view fully qualified class name

              final String viewClassName = LibrarySessionBeanRemote.class.getName();

              // let's do the lookup

              context.lookup(  "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

              return (LibrarySessionBeanRemote) context.lookup(  "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

             

              }

            }

             

             

             

            THIS IS MY EJB CODE:

             

            package com.tutorialspoints.stateless;

             

             

            import java.util.List;

             

             

            import javax.ejb.Remote;

             

             

            public interface LibrarySessionBeanRemote {

              void addBook(String bookName);

             

             

              List<String> getBooks();

            }

             

             

             

             

             

            package com.tutorialspoints.stateless;

             

             

            import java.util.ArrayList;

            import java.util.List;

             

             

            import javax.ejb.Remote;

            import javax.ejb.Stateless;

             

             

            /**

            * Session Bean implementation class NewSessionBean

            */

            @Stateless

            @Remote(LibrarySessionBeanRemote.class)

            public class LibrarySessionBean implements LibrarySessionBeanRemote {

             

             

              List<String> bookShelf;

             

             

              public LibrarySessionBean() {

              bookShelf = new ArrayList<String>();

              }

             

             

              public void addBook(String bookName) {

              bookShelf.add(bookName);

              }

             

             

              public List<String> getBooks() {

              return bookShelf;

              }

            }

            • 3. Re: i m new to willdfy and i m getting errors on  configuring jndi for remote ejb application
              mayerw01

              This indicates a lookup problem.

              You should remove the "ejb:"

              So you should replace

              return (LibrarySessionBeanRemote) context.lookup(  "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

              with

              return (LibrarySessionBeanRemote) context.lookup( appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

              • 4. Re: i m new to willdfy and i m getting errors on  configuring jndi for remote ejb application
                taichimaster84

                thanks very much i tried it and it worked