ejb@glassfish.java.net

Re: lookup glassFish ejb3 netbeans NoInitialContextException

From: <jhandal7_at_aol.com>
Date: Sun, 27 May 2007 13:36:52 -0400

Hi
Please I need help with  NetBeans ,running GlassFish & EJB3.

package ejb;

import javax.ejb.Remote;


/**
 * This is the business interface for AdiosNY enterprise bean.
 */
@Remote
public interface AdiosNYRemote {
    public String Mensaje();
   
   
}




AdiosNYBean.java
 *
 * Created on May 26, 2007, 4:20 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ejb;

import javax.ejb.Stateless;

/**
 *
 * @author HANDAL
 */
@Stateless(mappedName="Alpha")
public class AdiosNYBean implements ejb.AdiosNYRemote {
    public String Mensaje(){
        System.out.println("Viva el Peru");
        return "Peru tierra de Heroes";
       
    }
   
    /** Creates a new instance of AdiosNYBean */
    public AdiosNYBean() {
    }
   
}


/*
 * TestAdios.java
 *
 * Created on May 26, 2007, 4:27 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ejb;

import java.util.Properties;
import javax.naming.InitialContext;

/**
 *
 * @author HANDAL
 */
public class TestAdios {
   
   
    /** Creates a new instance of TestAdios */
    public TestAdios() {
    }
    public static void main(String [] args)throws Exception{
        Properties props=new Properties();
       
        props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
        props.setProperty("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
        props.setProperty("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        InitialContext ic=new InitialContext(props);
        AdiosNYRemote ad=(AdiosNYRemote)ic.lookup("Alpha");
       
       
    }
   
    }
   






init:
deps-jar:
compile-single:
run-main:
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.(InitialContext.java:197)
        at ejb.TestAdios.main(TestAdios.java:31)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
        ... 4 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

How can I get the JNDI Properties file in the GlassFish Server?
Thanks



AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.



________________________________________________________________________
AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.