Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

running EJB gives exception in 'main' of Client

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pls help resolving this.

My Codes are ....
1)Home interface
package headfirst;

import javax.ejb.*;
import java.rmi.RemoteException;

public interface Advice extends EJBObject{
public String getAdvice() throws RemoteException;
}

2)Component interface
package headfirst;

import javax.ejb.*;
import java.rmi.RemoteException;

public interface AdviceHome extends EJBHome{
public Advice create() throws CreateException, RemoteException;
}

3)Bean Class
package headfirst;
import javax.ejb.*;

public class AdviceBean implements SessionBean{

private String [] adviceStrings = {"One word:inappropriate.","You might want to rethink that haircut.","Your boss will respect yhou if you tell him waht you REALLY of him.","Visualize yourself with better clothes.","Of course you don't have to go to work today.","Do you really think you should be leaving the house like that?", "Read a book, once a year whether you need to or not."};

public void ejbActivate(){
System.out.println("ejb activate");
}

public void ejbPassivate(){
System.out.println("ejb passivate");
}

public void ejbRemove(){
System.out.println("ejb remove");
}

public void setSessionContext(SessionContext ctx){
System.out.println("Session context");
}

public String getAdvice(){
System.out.println("in get advice");
int random = (int) (Math.random() * adviceStrings.length);
return adviceStrings[random];
}

public void ejbCreate(){
System.out.println("in ejb create");
}
}


and the Client...

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


Thse codes could compile and make the .jar . The client also got compiled. But when running with the local srver following erro display.

first compilation.......
D:\J2eeProject\Advice>java -cp d:\j2eeproject\advice\AdviceAppClient.jar AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient


2nd compilation
D:\J2eeProject\Advice>java -cp d:\j2eeproject\advice\AdviceAppClient.jar;d:\j2sdkee1.3.1\lib\j2ee.jar Ad
viceClient
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient


Let me know where the erro is..I used J2EE 1.3 RI .

Thanks in advance.
Niran
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Niran,
It seems like you have some class path issue. Look at the next post in the forum by Cliff DeRose. Will get some idea. Also make sure that you have the JDK run time in the path.( Hint from the post by Cliff DeRose).


Thanks
Shibu
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic