• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Class not found error when running the trial example from Headfirst book

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having problem with the trial example given in the first chapter of the HeadFirst EJB book. I followed all the steps for creation/deployment. Now when I am trying to execute the client I am getting a noclassdeffound error. I have not set the CLASSPATH enviro variable instead I am using the
-classpath option. Details are as shown below:
C:\sudhir\ejb_scripts\advice>java -cp AdviceAppClient.jar AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient
C:\sudhir\ejb_scripts\advice>dir
Volume in drive C is HP_PAVILION
Volume Serial Number is 3431-502D
Directory of C:\sudhir\ejb_scripts\advice
11/29/2003 01:48a <DIR> .
11/29/2003 01:48a <DIR> ..
11/29/2003 01:01a 3,411 AdviceApp.ear
11/29/2003 01:01a 21,725 AdviceAppClient.jar
11/29/2003 01:51a 1,435 AdviceClient.class
11/29/2003 01:28a 585 AdviceClient.java
11/28/2003 08:58p <DIR> classes
11/29/2003 02:17a 453 cloudscape.LOG
11/28/2003 08:58p <DIR> src
Thanks
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same problem and resolved it by adding the path to the client to the classpath like this:
java -cp AdviceAppClient.jar;C:\sudhir\ejb_scripts\advice AdviceClient
Hope it helps
/Magnus
 
Sudhir V
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I executed it but then I am getting a new error.
C:\sudhir\ejb_scripts\advice>java -cp C:\j2sdkee1.3.1\ lib\j2ee.jar;AdviceAppClient.jar;C:\sudhir\ejb_scripts\advice AdviceClient
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(Class.java:232)
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(ObjectImpl.java:454)
at headfirst._Advice_Stub.getAdvice(Unknown Source)
at AdviceClient.go(AdviceClient.java:21)
at AdviceClient.main(AdviceClient.java:10)
 
Sudhir V
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the code for the AdviceClient.java
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class AdviceClient {

public static void main(String[] args) {
new AdviceClient().go();
}

public void go() {
try {
Context ic = new InitialContext();
Object o = ic.lookup("Advisor");

AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);

Advice advisor = home.create();
System.out.println (advisor.getAdvice());
} catch (Exception ex) {
ex.printStackTrace ();
}
}
}
 
Sudhir V
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Followed kathy's steps and renamed the method getAdvice and its working now
Thanks
 
Something about .... going for a swim. With this tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic