4 Replies Latest reply on Jul 21, 2014 7:56 AM by Wolf-Dieter Fink

    EJB in Jboss AS 7.1

    Allwyn Lawrence Newbie

      Hi Guys,

                   I'm a beginner with Java/EJB. I'm trying to setup a basic session bean program. I went through many online materials and finally made a simple program.  I'm getting the following error when i run my client. i'm using jboss 7 and eclipse (kepler)




      Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

        at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)

        at javax.naming.InitialContext.lookup(Unknown Source)

        at test.psp.gdc.client.AllyClient.doLookup(AllyClient.java:66)

        at test.psp.gdc.client.AllyClient.invokeAlly(AllyClient.java:33)

        at test.psp.gdc.client.AllyClient.main(AllyClient.java:24)






      My Bean Class is like this


      package test.psp.gdc.SEB;

      import javax.ejb.Remote;

      import javax.ejb.Stateless;


      * Session Bean implementation class Ally




      public class Ally implements AllyRemote {

          public Ally() {

              // TODO Auto-generated constructor stub


          public String callAlly(){

             return "Alucard";







      Remote Interface:


      package test.psp.gdc.SEB;

      import javax.ejb.Remote;


      public interface AllyRemote {

      public String callAlly();








      package test.psp.gdc.client;

      import java.util.Hashtable;

      import javax.naming.Context;

      import javax.naming.InitialContext;

      import javax.naming.NamingException;

      import test.psp.gdc.SEB.Ally;

      import test.psp.gdc.SEB.AllyRemote;





      public class AllyClient {

        public static void main(String[] args) throws Exception {











        private static void invokeAlly() throws NamingException {

        // TODO Auto-generated method stub

            final AllyRemote nats = doLookup();

              System.out.println("Calling the Session Bean");

         System.out.println("Bean Output:" +nats.callAlly());


      private static AllyRemote doLookup() throws NamingException{

        // TODO Auto-generated method stub


        final Hashtable jp = new Hashtable();

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

        Context context = new InitialContext(jp);

        //App Name

        final String appName="";

      //Module Name

        final String modName="Lightning";

      //Distinct Name

        final String disName="";

        //EJB Name

        final String ejbName=Ally.class.getSimpleName();

      //view Class Name

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

        return (AllyRemote) context.lookup("ejb:" + appName + "/" + modName + "/" + disName + "/" + ejbName + "/" + viewClassName);












      remote.connection.default.port = 4447