• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

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?
 
Have you no shame? Have you no decency? Have you no tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic