Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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
 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic