EJB CabinBean-client Monson-Haefel Book

Hi,

I am working with the Monson-Haefel Enterprise JavaBeans book (OReilly) and I have the following problem in chapter 4: I successfully deployed the Cabin EJB with J2EE deploytool (after changing the source code for the CabinHomeRemote.class [ejbCreate-method has to throw a CreateException]) but I have problems with the Client_1.class: I get the following error message java.lang.NoClassDefFoundError: javax/ejb/FinderException Exception in thread "main"

This is my source code:

public class Client_1 {

public static void main(String [] args){

try{

Context initial=new InitialContext();

Context myEnv= (Context) initial.lookup("java:comp/env");

Object objref = myEnv.lookup("MyCabinBean");

CabinHomeRemote home= (CabinHomeRemote) PortableRemoteObject.narrow(objref, CabinHomeRemote.class);

CabinRemote cabin_1=home.create(new Integer(1) );

cabin_1.setName("Master Suite");

cabin_1.setDeckLevel(1);

cabin_1.setShipId(1);

cabin_1.setBedCount(3);

Integer pk=new Integer(1);

CabinRemote cabin_2=home.findByPrimaryKey(pk);

System.out.println(cabin_2.getName());

System.out.println(cabin_2.getDeckLevel());

System.out.println(cabin_2.getShipId());

System.out.println(cabin_2.getBedCount());

}catch (java.rmi.RemoteException re) {re.printStackTrace();}

catch (javax.naming.NamingException ne) {ne.printStackTrace();}

catch (javax.ejb.CreateException ce) {ce.printStackTrace();}

catch (javax.ejb.FinderException fe) {fe.printStackTrace();}

};

}

In deploytool I set the JNDI name for the CabinBean to "MyCabinBean". Can anybody who has successfully ran the chapter 4 examples on J2EE server help me with this?

best regards,

Thomas

[1814 byte] By [ThoBer] at [2007-9-19]
# 1

Hi,

You have to include the J2EE.jar files in your classpath when you start your client. For example if you are using weblogic,

for a NT environment do "set CLASSPATH=%WL_HOME%/lib/weblogic.jar;%CLASSPATH%"

on unix do "export CLASSPATH=$WL_HOME/lib/weblogic.jar:$CLASSPATH"

Hope this solves your problem.

John.

john_arun at 2007-7-4 > top of java,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Hi,

I changed some settings: the coded reference to the EJB is now "ejb/cabin". I set the Client app as a J2EE application client and deployed it together with the EJB. The app (.ear-file) has a security role that has access to all methods and I mapped this security role to a group and user I created on the J2EE RI server.

Then I start the client (after setting the APPCPATH variable to the returned JAR-file) with runclient -client <App>.ear -name Client_1

I then login as the mapped user and then I get the following error message:

Binding name:`java:comp/env/ejb/Cabin`

java.rmi.AccessException: CORBA NO_PERMISSION 9998 Maybe; nested exception is:

org.omg.CORBA.NO_PERMISSION:minor code: 9998 completed: Maybe

org.omg.CORBA.NO_PERMISSION:minor code: 9998 completed: Maybe

at java.lang.Class.newInstance0(Native Method)

at java.lang.Class.newInstance(Class.java:237)

at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemException(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(ObjectImpl.java:459)

at com.titan.cabin._CabinHomeRemote_Stub.create(Unknown Source)

at com.titan.cabin.Client_1.main(Client_1.java:37)

at java.lang.reflect.Method.invoke(Native Method)

at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:22

9)

at com.sun.enterprise.appclient.Main.main(Main.java:155)

Has anybody had this error message?

Thanks,

Thomas

ThoBer at 2007-7-4 > top of java,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Thomas,I too am trying to follow the examples in Chapter 4 of the Monson-Haefel book and have the same problems you have. Have you found an answer since you posted this message?Jace.
jace_fly at 2007-7-4 > top of java,Enterprise & Remote Computing,Enterprise Technologies...