• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiler error

 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am encountering compiler errors in the AdviceClient.java found in chapter 1 of K AND B book.

Here is the source code.

import javax.naming.*;
import javax.rmi.*;
import hf.*;
import java.rmi.*;
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("TEST");




AdviceHome ac = (AdviceHome)PortableRemoteObject.narrow(o,AdviceHome.class);



Advice adcomp = ac.create();
System.out.println(adcomp.getAdvice());
}
catch(Exception e)
{
e.printStackTrace();
}


}//end of method

}

This is the list of errors I get
======================================
AdviceClient.java:25: inconvertible types
found : java.lang.Object
required: AdviceHome
AdviceHome ac = (AdviceHome)PortableRemoteObject.narrow(o,AdviceHome.class);
^
AdviceClient.java:29: cannot resolve symbol
symbol : method create ()
location: class AdviceHome
Advice adcomp = ac.create();
^
AdviceClient.java:30: cannot resolve symbol
symbol : method getAdvice ()
location: class Advice
System.out.println(adcomp.getAdvice());
^
3 errors======================================================

Any idea of what is causing the error?
 
arunij katiliyar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Try to do this way

AdviceHome ac = (AdviceHome)PortableRemoteObject.narrow(ic.lookup("TEST"),AdviceHome.class);

Lemme know if this worked fine .


Regards
Arun
 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arun,

I tried but am getting the same results.
 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Would any one of you mind in helping me getting out of this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic