users@glassfish.java.net

lookup question

From: Juan Alzugaray <jea_at_gsoft.com.uy>
Date: Fri, 11 Mar 2011 10:51:14 -0300

hello,

For several day I'm trying to solve this problem

I have an application with ejb and web modules deployed on glassfish v2, and desk application using ejb
all work without problem

now I want to migrate to glassfish v3.1

// ebj
first steep deploy the ejb's on glassfish v3, no have problem

//web application
after when deploy web modules if ejb package checked to include on library the server say this error

GRAVE: Exception while loading the app : EJB Container initialization error
java.lang.RuntimeException: Error while binding JNDI name TestSessionBean for EJB : TestSessionBean
if ejb package not checked the web module is deployed but when run de application lookup not find the ejb

Caused by: javax.naming.NameAlreadyBoundException: Use rebind to override
        at com.sun.enterprise.naming.impl.TransientContext.doBindOrRebind(TransientContext.java:333)

when deploy web application without ejb package the deploy works ok, but when run the application say this error
org.apache.jasper.JasperException: java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'TestSessionBean' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=localhost, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacetest.TestSessionBeanRemote [Root exception is java.lang.ClassNotFoundException: test.TestSessionBeanRemote]]root cause

java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'TestSessionBean' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=localhost, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacetest.TestSessionBeanRemote [Root exception is java.lang.ClassNotFoundException: test.TestSessionBeanRemote]]
//desk application
when run this the lookup say

javax.naming.CommunicationException: Can't find SerialContextProvider [Root exception is java.lang.ClassCastException]


ejb source
//
@Remote
public interface TestSessionBeanRemote {

    int add(int a, int b);
    
}

@Stateless(mappedName="TestSessionBean")
public class TestSessionBean implements TestSessionBeanRemote
{

    @Override
    public int add(int a, int b) {
        return a + b;
    }
}
//

web source on lookup
//
 private TestSessionBeanRemote lookupTestSessionBeanRemote() {
        try {
            Context c = new InitialContext();
            return (TestSessionBeanRemote) c.lookup("TestSessionBean");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
//

desk application lookup
//
           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");

            props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");

            props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

            InitialContext ic = new InitialContext(props);

            TestSessionBeanRemote bean = (TestSessionBeanRemote) ic.lookup("TestSessionBean");
//


you have any suggestion on the subject, or which may be my error

from already very grateful

Juan Alzugaray