• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

headfirst AdviceClient throws NoClassDefFound exception

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying to run the first example in the headfirst EJB series.Good news is i have deployed the bean successfully but the bad news is i am being blocked from seeing the famous advice from advice guy.

i have got the AdviceAppClient.ear from the container.... and have compiled this file

===================================================================
/** 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();
}
}
}
======================================================================


Note: i have chaged the way book has compiled the AdviceClient.java.

F:\projects\advice>javac -classpath "AdviceAppClient.jar;F:\j2sdkee1.3\lib\j2ee.jar" AdviceClient.java

>> this gives me back the class file.

but..

F:\projects\advice>java -classpath "AdviceAppClient.jar" AdviceClient

throws NoClassDefFound exception in main method.

Note: My server is up and running perfectly!!


At this point i am completly helpless and desparately looking for help.

Bye

Jay
 
jay akhawri
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

found the solution!!...the ultimate RI bug!

bye
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you please let me know how you have solved the problem? I am also stuck with the same problem!!

regards,
Bis
 
jay akhawri
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh i am sorry i didnt provide the solution. see if you are using j2sdk1.3 and j2eesdk1.3.

and i am assuming you have deployed the bean successfully..then try thiese steps

1. include these three lines in the AdviceClient.java
----------------------------------------------------------------------------
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.enterprise.naming.SerialInitContextFactory");

ht.put(Context.PROVIDER_URL,"iiop//localhost:1050");

Context ic = new InitialContext(ht);
---------------------------------------------------------------------------


2.compile it as usual(try keeping both j2ee.jar and AdviceAppClient.jar in classpath)

(just for a reference)
------------------------------------------------------------------
f:\projects\advice>javac -classpath "AdviceAppClient.jar;%j2ee_home%\lib\j2ee.jar" AdviceClient.java
------------------------------------------------------------------



3. run client
-----------------------------------------------------------------------
~\project\advice>java -cp "%CLASSPATH%;AdviceClient.jar" AdviceClient
------------------------------------------------------------------------

i hope this will solve your problem.Have a nice day.


Jay
 
Grow your own food... or this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic