ejb@glassfish.java.net

Holder Class Error

From: Ning Zhu <zhu_at_astreetpress.com>
Date: Wed, 21 Jun 2006 17:17:16 -0400

Hi,

We are running into a new problem, which is about "Holder" class. When we
trying to do output and in/out parameters for ejb, we just start from a very
simple test and here is the code:

// asp.dorp.Content

package asp.dorp;
import javax.ejb.Remote;
@Remote
public interface Content {
    void getContentbyID(org.omg.CORBA.BooleanHolder rights);
}

//asp.dorp.ContentBean

package asp.dorp;
import javax.ejb.Stateless;
@Stateless
public class ContentBean implements asp.dorp.Content {
    public ContentBean() {
    }

    public void getContentbyID(org.omg.CORBA.BooleanHolder rights) {
        rights.value = true;
    }
}

// Test client, standalone client from same app server, not enterprise
client

package test;

public class Main {
    public Main() {
    }

    public statis void main(String[] args) {
      org.omg.CORBA.BooleanHolder rights = new
org.omg.CORBA.BooleanHolder(false);
    try {
        javax.naming.InitialContent ic = new javax.naming.InitialContent();
        asp.dorp.Content local = (asp.dorp.Content)
ic.lookup("asp.dorp.Content");
        local.getContentbyID(rights);
        // this is where we always getting an error of
java.lang.ClassCastException: org.omg.CORBA.BooleanHolder
    }
    catch(Exception e){}
    }
}

We have no clue how to use this holder class now. Could you help us?

Ning