Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

headfirst AdviceClient throws NoClassDefFound exception  RSS feed

 
jay akhawri
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi all,

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

bye
 
bis ani
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!