Hi all,

i am trying to run the client:
package de.ejbkomplett.reisebuero.client;

import de.ejbkomplett.reisebuero.usecase.*;

import javax.ejb.EJBMetaData;
import javax.ejb.HomeHandle;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.sql.Date;
import java.util.*;

public class Client {

  public static void main(String[] args) {
        System.out.println("*****************************");
        System.out.println("** Test-Client Kapitel 04  **");
        System.out.println("** HomeHandle-Beispiel     **");
        System.out.println("** gestartet...            **");
        System.out.println("*****************************\n");

    try {
      // 1. JNDI-Context ermitteln
      Hashtable env = new Hashtable();
      env.put("java.naming.factory.initial",
              "org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.provider.url", "localhost:1099");
      Context context = new InitialContext(env);
      System.out.println("*** Mit JNDI-Namensdienst verbunden...");
     
      // 2. Home-Objekt über JNDI holen
      Object o = context.lookup("FlugSuche");
      FlugSucheHome home = (FlugSucheHome)
              PortableRemoteObject.narrow(o, FlugSucheHome.class);

      
      
          System.out.println("*** Referenz auf Home-Objekt FlugSuche 
erhalten...");
          System.out.println("*** FlugSuche Bean - HashCode: " + 
((Object)home).hashCode());
          System.out.println("*** FlugSuche Bean - Klasse  : " + 
((Object)home).toString());

      // 3. EJBObject erzeugen
      FlugSuche suche = home.create();
          System.out.println("*** FlugSuche Bean ist erzeugt...");

      // 4. HomeHandle der EJB-Komponente beim Home Interface anfordern
      javax.ejb.HomeHandle hh = home.getHomeHandle();
      
         
      // 5. HomeHandle serialisieren
      System.out.println("*** HomeHandle wird serialisiert...\n");
      java.io.FileOutputStream fileOut = new 
java.io.FileOutputStream("homehandle.ser");
      java.io.ObjectOutputStream objectOut = new 
java.io.ObjectOutputStream(fileOut);
      objectOut.writeObject(hh);
      objectOut.flush();
      fileOut.close();
          hh = null; //HomeHandle löschen

      suche.remove(); //EJBObject wieder löschen

      // 6. HomeHandle deserialisieren
          System.out.println("*** HomeHandle wird deserialisiert...");
          java.io.FileInputStream fileIn = new 
java.io.FileInputStream("homehandle.ser");
          java.io.ObjectInputStream objectIn = new 
java.io.ObjectInputStream(fileIn);
      javax.ejb.HomeHandle handleNeu = 
(javax.ejb.HomeHandle)objectIn.readObject();
      fileIn.close();
      
          //Home-Objekt vom HomeHandle erfragen.
          //Bei Aufruf der Methode getEJBHome() sorgt die Implemen-
          //tierung des HomeHandles dafür, eine funktionsfähige
          //Referenz auf das Home Interface zur Verfügung zu stellen.
      
      
      javax.ejb.EJBHome homeNew = (FlugSucheHome)handleNeu.getEJBHome();

          //Nach dem Cast auf das FlugSucheHome Interface steht das
          //Remote Home Interface wieder zur Verfügung und kann für
          //die Steuerung des Lebenszyklus einer FlugSuche-Komponente
          //genutzt werden.
          FlugSucheHome sucheNeuHome = 
(FlugSucheHome)PortableRemoteObject.narrow(homeNew, FlugSucheHome.class);
          System.out.println("*** FlugSuche Bean - HashCode: " + 
((Object)sucheNeuHome).hashCode());
          System.out.println("*** FlugSuche Bean - Klasse  : " + 
((Object)sucheNeuHome).toString());

      FlugSuche sucheNeu = sucheNeuHome.create();

          //EJBObject wieder löschen
          sucheNeu.remove();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}




then I get the following message:

     [java] *****************************
     [java] ** Test-Client Kapitel 04  **
     [java] ** HomeHandle-Beispiel     **
     [java] ** gestartet...            **
     [java] *****************************
     [java] *** Mit JNDI-Namensdienst verbunden...
     [java] *** Referenz auf Home-Objekt FlugSuche erhalten...
     [java] *** FlugSuche Bean - HashCode: 15232416
     [java] *** FlugSuche Bean - Klasse  : FlugSucheHome
     [java] log4j:WARN No appenders could be found for logger 
(org.jboss.security.SecurityAssociation).
     [java] log4j:WARN Please initialize the log4j system properly.
     [java] *** FlugSuche Bean ist erzeugt...
     [java] *** HomeHandle wird serialisiert...
     [java] *** HomeHandle wird deserialisiert...
     [java] java.rmi.ServerException: Could not get EJBHome; nested exception 
is:
     [java] 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
     [java] at 
org.jboss.proxy.ejb.handle.HomeHandleImpl.getEJBHome(HomeHandleImpl.java:107)
     [java] at de.ejbkomplett.reisebuero.client.Client.main(Client.java:73)
     [java] Caused by: 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
     [java] at 
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
     [java] at 
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
     [java] at 
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
     [java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
     [java] at 
org.jboss.proxy.ejb.handle.HomeHandleImpl.getEJBHome(HomeHandleImpl.java:102)
     [java] ... 1 more


please help me!

Thanks!

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079281#4079281

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079281

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to