users@glassfish.java.net

Problem with Stateless bean in Web Application

From: Piero Filippin <filippinp_at_yahoo.co.uk>
Date: Thu, 16 Aug 2007 16:46:12 +0100

Hi,

I created my first stateless bean :

@Stateless(mappedName="MyBean")
public class MyBean implements MyBeanRemote{
    public String sayHello() {
        return "Hello";
    }
}

and a remote interface:

@Remote
public interface MyBeanRemote{
    public String sayHello();
}

This compiles and deploys (from Eclipse) fine in GlassFish v2 (last build)

I then created a client,

public class Client {
    public Client() {
        try {
            InitialContext ctx = new InitialContext();
            MyBeanRemote myrb = (MyBeanRemote) ctx.lookup("MyBean");
            System.out.println(myrb.sayHello());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args){
        new Client();
    }
}

This is working as well... great, it could not be simpler!

Now, I am trying to use it inside a Web App:

<%
    try {
        InitialContext ctx = new InitialContext();
        MyBeanRemote myrb = (MyBeanRemote) ctx.lookup("MyBean");
        out.write(myrb.sayHello());
    } catch (Exception e) {
        out.write(e.getMessage());
    }
%>

This does not work; I get:

*org.apache.jasper.JasperException: PWC6033: Unable to compile class for
JSP *
PWC6197: An error occurred at line: 3 in the jsp file: /index.jsp
PWC6199: Generated servlet error: string:///index_jsp.java:53: cannot
find symbol
symbol : class MyBeanRemote
location: package com.my.myejbs

Now my diagnosis is: while my bean is deployed on the server, the web
app has no clues about the interface MyBeanRemote. Initially I started
fiddling with the classpath, but then I realised that the bean and the
web application could be on different servers, and this should work no
matter the classpath!

My next try has been to put a copy of the MyBeanRemote interface inside
the web application - but no luck, what I get this time is a weird
exception:

#|2007-08-16T16:05:57.688+0100|WARNING|sun-appserver9.1|javax.enterprise.resource.corba.ee.S1AS-ORB.rpc.encoding|_ThreadID=21;_ThreadName=httpSSLWorkerThread-8080-1;javax.rmi.CORBA.EnumDesc;_RequestID=c34b367b-5ba5-4d71-bb2b-0478e1f0eaec;|"IOP00810257:
(MARSHAL) Could not load class javax.rmi.CORBA.EnumDesc"
org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe

javax.rmi.CORBA.EnumDesc is in appserv-rt.jar, which is in the GlassFish
classpath, so now I am stuck!

What do I need to do? Am I doing something wrong?