F
Flip
I'm going through the HeadFirt EJB book, and I stuck on one example. :< The
code is here (simple example used to illustrate simple ejb creation/usage,
but my example has that commented out).
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class AdviceClient{
public static void main( String[] args ){
System.err.println( "BEG" );
//new AdviceClient().go();
System.err.println( "END" );
}
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.err.println( advisor.getAdvice() );
} catch( Exception ex ){
ex.printStackTrace();
}
}
}
I can compile it with the right -classpath and all is good. But when I goto
run it, I get the error message java.lang.NoClassDefFoundError:
AdviceClient. Why?
As far as I can see the classname matches the public classname, there is a
public static void main( String[] ) method, and it compiles, but it can't
seem to find the main, why? I can create another simple test.java code with
just the mainline and all runs correctly. Is there something with classpath
setup that screwing things up?
code is here (simple example used to illustrate simple ejb creation/usage,
but my example has that commented out).
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;
public class AdviceClient{
public static void main( String[] args ){
System.err.println( "BEG" );
//new AdviceClient().go();
System.err.println( "END" );
}
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.err.println( advisor.getAdvice() );
} catch( Exception ex ){
ex.printStackTrace();
}
}
}
I can compile it with the right -classpath and all is good. But when I goto
run it, I get the error message java.lang.NoClassDefFoundError:
AdviceClient. Why?
As far as I can see the classname matches the public classname, there is a
public static void main( String[] ) method, and it compiles, but it can't
seem to find the main, why? I can create another simple test.java code with
just the mainline and all runs correctly. Is there something with classpath
setup that screwing things up?