File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Couldn't launch the Advice example in HF EJB book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Couldn Watch "Couldn New topic
Author

Couldn't launch the Advice example in HF EJB book

Patrick Badri
Greenhorn

Joined: Jan 26, 2005
Posts: 8
Hi!

I'm compiling and trying to run AdviceClient. But it does nothing...

Server is loaded, Advice Application is deployed...

My command lines:
javac -classpath .;\j2sdkee1.3.1\lib\j2ee.jar;\projects\advice\AdviceAppClient.jar AdviceClient.java

java -cp .;\j2sdkee1.3.1\lib\j2ee.jar;\projects\advice\AdviceAppClient.jar AdviceClient.java

AdviceClient is exactly from book page 57.

Any Solution?
Patrick Viswanathan
Greenhorn

Joined: Jan 27, 2005
Posts: 3
It seems you are using windows environmen
If so please include the drive/partition
eg

change - \j2sdkee1.3.1\lib\j2ee.jar
to - c:\j2sdkee1.3.1\lib\j2ee.jar

remember the above path is not literal and should be the exact path as is in your system.


Patrick
Patrick Badri
Greenhorn

Joined: Jan 26, 2005
Posts: 8
This is my AdviceClient file, it's compiled and executed without errors, all debug message are printed, but there is no connection to bean...

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

// Debug
System.out.println( "End of main()!" );
}

public void go( )
{
System.out.println( "start of go()" );
try
{
Context initContext = new InitialContext();
Object obj = initContext.lookup("Advisor");
// Debug
System.out.println( "after lookup()" );

AdviceHome home = (AdviceHome) PortableRemoteObject.narrow( obj, AdviceHome.class );
Advice advisor = home.create();

String strAdvice = advisor.getAdvice();

// Debug
System.out.println( "This advise from bean: " + strAdvice );
}
catch( Exception ex ) { }
}
}
Patrick Viswanathan
Greenhorn

Joined: Jan 27, 2005
Posts: 3
change
-> catch( Exception ex ) { }
to
-> catch( Exception ex ) {ex.printStackTrace()}


Check if your server/appserver is up and running.
Patrick Badri
Greenhorn

Joined: Jan 26, 2005
Posts: 8
I launched my server:
----------------------------
D:\projects\advice>runj2ee

D:\projects\advice>d:\j2sdkee1.3.1\bin\j2ee
J2EE server listen port: 1050
Redirecting the output and error streams to the following files:
D:\j2sdkee1.3.1\logs\comp\j2ee\j2ee\system.out
D:\j2sdkee1.3.1\logs\comp\j2ee\j2ee\system.err
J2EE server startup complete.

inserted catch( Exception ex ) {ex.printStackTrace()} in my Client
------------------------------------------------------------------
Compile with success
----------------
D:\projects\advice\src>compileclient

D:\projects\advice\src>set J2EE_HOME=D:\j2sdkee1.3.1

D:\projects\advice\src>set CPATH=.;D:\j2sdkee1.3.1\lib\j2ee.jar

D:\projects\advice\src>javac -classpath .;d:\j2sdkee1.3.1\lib\j2ee.jar;d:\projec
ts\advice\AdviceAppClient.jar AdviceClient.java

Run and get this:
-----------------------------------------------
D:\projects\advice\src>runclient

D:\projects\advice\src>set J2EE_HOME=D:\j2sdkee1.3.1

D:\projects\advice\src>set CPATH=.;D:\j2sdkee1.3.1\lib\j2ee.jar

D:\projects\advice\src>java -cp .;d:\j2sdkee1.3.1\lib\j2ee.jar;d:\projects\advic
e\AdviceAppClient.jar AdviceClient
start of go()
after lookup()
java.rmi.RemoteException: CORBA BAD_OPERATION 0 No; nested exception is:
org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemExc
eption(ReplyMessage_1_2.java:93)
at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(
ClientResponseImpl.java:108)
at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOACli
entSC.java:132)
at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
at headfirst._Advice_Stub.getAdvice(Unknown Source)
at AdviceClient.go(AdviceClient.java:31)
at AdviceClient.main(AdviceClient.java:11)
End of main()!
Patrick Viswanathan
Greenhorn

Joined: Jan 27, 2005
Posts: 3
This problem is reported in many forums and ours too..
Check the link below.
http://www.coderanch.com/t/312836/EJB-JEE/java/Head-First-EJB-st-tut
Patrick Badri
Greenhorn

Joined: Jan 26, 2005
Posts: 8
Thank you! Situation has changed, but I still have exception:
My client you could see in previous message

D:\projects\advice\src>runClient

D:\projects\advice\src>set J2EE_HOME=D:\j2sdkee1.3.1

D:\projects\advice\src>set CPATH=.;D:\j2sdkee1.3.1\lib\j2ee.jar

D:\projects\advice\src>java -cp .;d:\j2sdkee1.3.1\lib\j2ee.jar;d:\projects\advice\AdviceAppClient.jar AdviceClient
start of go()
after lookup()
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at AdviceClient.go(AdviceClient.java:28)
at AdviceClient.main(AdviceClient.java:11)
End of main()!
Patrick Badri
Greenhorn

Joined: Jan 26, 2005
Posts: 8
Thank you!!!
It worked finally!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Couldn't launch the Advice example in HF EJB book
 
Similar Threads
pg:57 head first ejb client running problem..HELP
AdviceClient and JNDI
AdviceClient
Error compiling the AdviceClient.java
Trouble running Advice EJB