Glassfish v3 / JNDI-Eintrag kann nicht gefunden werden Probleme!

Ich habe Probleme versuchen, Aufruf einer EJB-Methode aus einer Java-Anwendung Client.
Hier ist der code.

EJB-Remote-Interface

package com.test;

import javax.ejb.Remote;

@Remote
public interface HelloBeanRemote {

    public String sayHello();

}

EJB

package com.test;

import javax.ejb.Stateless;

@Stateless (name="HelloBeanExample" , mappedName="ejb/HelloBean")
public class HelloBean implements HelloBeanRemote {

    @Override
    public String sayHello(){

        return "hola";

    }

}

Hauptklasse (ein anderes Projekt)

import com.test.HelloBeanRemote;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Main {


    public void runTest()throws Exception{

        Context ctx = new InitialContext();
        HelloBeanRemote  bean = (HelloBeanRemote)ctx.lookup("java:global/Test/HelloBeanExample!com.test.HelloBeanRemote");
        System.out.println(bean.sayHello());

    }


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

        Main main = new Main();
        main.runTest();

    }

}

Na, was ist mein problem? JNDI-Eintrag für diese EJB können nicht gefunden werden!

java.lang.NullPointerException
        at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:297)
        at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:271)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at testdesktop.Main.runTest(Main.java:22)
        at testdesktop.Main.main(Main.java:31) Exception in thread "main" javax.naming.NamingException: Lookup failed for 'java:global/Test/HelloBeanExample!com.test.HelloBeanRemote' in SerialContext  [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext  [Root exception is java.lang.NullPointerException]]
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at testdesktop.Main.runTest(Main.java:22)
        at testdesktop.Main.main(Main.java:31) Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext  [Root exception is java.lang.NullPointerException]
        at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:276)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
        ... 3 more Caused by: java.lang.NullPointerException
        at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:297)
        at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:271)
        ... 4 more Java Result: 1

Habe ich versucht mit verschiedenen JNDI-Einträge, aber nichts funktioniert (ich habe diese Einträge von NetBeans Konsole):

INFO: Portable JNDI-Namen EJB-HelloBeanExample : [java:global/Test/HelloBeanExample, java:global/Test/HelloBeanExample!com.test.HelloBeanRemote]

INFO: Glassfish-spezifische (Nicht-portable) - JNDI-Namen EJB-HelloBeanExample : [ejb/HelloBean, ejb/HelloBean#com.test.HelloBeanRemote]

Also versuchte ich mit den folgenden Einträgen, aber ich habe die gleiche Ausnahme :

  1. java:global/Test/HelloBeanExample
  2. java:global/Test/HelloBeanExample!com.test.HelloBeanRemote
  3. ejb/HelloBean
  4. ejb/HelloBean#com.test.HelloBeanRemote

Ich bin mit Netbeans 6.8 und Glassfish v3!

InformationsquelleAutor rudymatos | 2010-01-18
Schreibe einen Kommentar