This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

headfirst AdviceClient throws NoClassDefFound exception  RSS feed

 
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
 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!