• 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
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Compiler error

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Would any one of you mind in helping me getting out of this?
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic