Hoping someone can help out with this. I'm getting some really strange behaviour on the intro application.
My environment:
Win XP
J2SDKSE 1.3.1_10
J2SDKEE 1.3.1
For people without the book, Stateless Session bean.
remote interface - headfirst.Advice
ejb class - headfirst.AdviceBean
remote home interface - headfirst.AdviceHome
I have deployed the sample application (JNDI name - "Advisor") into the J2EE RI server, having verified it using the deployment tool. Deployment went through OK, j2ee is happy - no errors.
I have an
test class (some println's removed, so ignore the line numbers on the exception that follows...):
-----
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class AdviceClient {
public static void main (
String[] args) {
AdviceClient client = new AdviceClient();
client.go();
}
public void go() {
try {
// 1. get a reference to the JDNI InitialContext
Context context = new InitialContext();
// 2. use the context to do a lookup on the home interface of the bean
Object object = context.lookup("Advisor");
// 3. narrow and cast
AdviceHome home = (AdviceHome)
PortableRemoteObject.narrow(object, AdviceHome.class);
// 4. call create() on the home interface to get a reference to the
// component interface
Advice advisor = home.create();
// 5. use the component
System.out.println(advisor.getAdvice());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
-----
At step 5, I get the following exception:
-----
java.rmi.RemoteException: CORBA BAD_OPERATION 0 No; nested exception is:
org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemExc
eption(ReplyMessage_1_2.java:93)
at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(
ClientResponseImpl.java:108)
at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOACli
entSC.java:132)
at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
at headfirst._Advice_Stub.getAdvice(Unknown Source)
at AdviceClient.go(AdviceClient.java:39)
at AdviceClient.main(AdviceClient.java:10)
-----
I checked some of the newsgroups, and the closest thing I could find was that the CORBA exception is caused by calling a method on the interface that is not implemented on the stub (I think, can't recall exactly).
I double-checked the bean class against the remote interface, and it's all good. Even got them both to extend/implement the same interface just to be certain (although the verifier probably catches this...).
If anybody has any ideas, it would be greatly appreciated. Cheers,
Jake