• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Couldn't launch the Advice example in HF EJB book

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 Badri
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
change
-> catch( Exception ex ) { }
to
-> catch( Exception ex ) {ex.printStackTrace()}


Check if your server/appserver is up and running.
 
Patrick Badri
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem is reported in many forums and ours too..
Check the link below.
https://coderanch.com/t/312836/EJB-JEE/java/Head-First-EJB-st-tut
 
Patrick Badri
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!!!
It worked finally!!!
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic