Nor any of its super class is known to this context ...problem

hi all
i have simple complex object in jave that looks like this :
@XmlAccessorType(XmlAccessType.FIELD)
public class MyID{
    @XmlAttribute
    public short dbnum = (short)0;
    @XmlAttribute
    public short usernum= (short)0;
    @XmlAttribute
    public long userid = (long)0;
    public MyId(){
}i converted it with jaxb and it generete me corespanding java object with the propreate geters and seters
now when i try to in the server side to insert this object into List<Object> im geting error saing :
Caused by: javax.xml.bind.JAXBException: com.WebServices.datastructures.MyID nor any of its super class is known to this context
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:474)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:557)
... 47 more
i must say that if i send back only this object (MyID) the unmarsheling passed successfully
thanks for your help

Ok I found it out
jboss was using the jre default axis impelmentation while the server where my client was deployed was using the axis 2 implementation
I changed the server to use jre default axis and things worked now
Thanks
Sapan

Similar Messages

  • JAXBContextImpl nor any of its super class is known to this context

    Hi,
    I have a XSD, generated classes from it. At runtime, i have included DAS/lib/classes.jar. getting below exception. Can somebody help?
    javax.xml.bind.JAXBException: class com.sun.xml.bind.v2.runtime.JAXBContextImpl nor any of its super class is known to this context.
         at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:596)
         at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:482)
         at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
         at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96)
         at vodafone.commerce.fulfillment.processor.ProcSubmitOrder.getMessageStr(ProcSubmitOrder.java:249)
         at vodafone.commerce.fulfillment.processor.ProcSubmitOrder.sendSubmitOrderMessage(ProcSubmitOrder.java:177)
         at vodafone.commerce.fulfillment.processor.ProcCheckOrderToGoForManualReview.runProcess(ProcCheckOrderToGoForManualReview.java:114)
    Thanks
    Gopi

    Ok I found it out
    jboss was using the jre default axis impelmentation while the server where my client was deployed was using the axis 2 implementation
    I changed the server to use jre default axis and things worked now
    Thanks
    Sapan

  • Why isn't there a simpler way to initialize a subclass with its super class

    Let me explain my doubt with an example...
    public class Parent {
    �    public String parent;
    public class Child extends Parent{
    �    public String child;
    I've an instance of Parent p. I want to construct Child c, with the data in p.
    The only way that is provided by Java language seems to be, having a constructor in Child like
    public class Child extends Parent{
    �    public String child;
    �    public Child(Parent p){
    �    �    parent = p.parent;
    �    }
    The problem with this is there is lot of redundant assignment code.
    What I don't understand is why there is not a simpler way of doing this when a subclass is after all super class data + some other data(excuse me for not looking at the bahavior part of it)
    I'm looking for something as simple as Child c = p, which I know is wrong and know the reasons too.
    Yes, we can wrap Child over Parent to do this, but it necessitates repeating all the methods in Parent.
    Why is the language writers didn't provide a simple way of doing this? I should be missing something here...I'm just searching for an explanation. May be I'm asking a dumb question, but this bugs me a lot...
    Regards,
    Kothapalli.

    To answer DrClap, I'm demanding it now :-). Let me
    not suggest something that Mr.Gosling didn't think of;
    he should be having some reasons in not providing it.Because it's essentially impossible in the general case. One of the reasons you may be extending a class is to add new invariants to the superclass.
    eg- extend java.awt.Rectangle by BoundedRectangle - extra invariant that none of its corner points may be less than 0 or more than 100 in any dimension. (The rectangle must be entirely contained in the area (0,0)-(100,100))
    What would happen if you try to create a BoundedRectangle from a rectangle representing (50,50)-(150,150)? Complete invariant breakdown, with no generic way to handle it, or even recognise it.
    Actually, BIJ and sgabie are asking for it. Provide an
    automatic copy constructor. Every object should have
    an implicit copy constructor defined. From any
    subclass, I should be able to invoke
    super(parentClass). From the subclass, we can invoke
    super(parentClass) first and then go on to initialize the
    subclass data.
    I really don't know the implementation issues of this,
    but what I'm looking for is something like this. I'm just
    curious to know the implementation issues.Implementation issue #1: Classes that should not, under any circumstane, be copied.
    * eg 1- Singleton objects. If there's an automatic copy constructor, then multiple singletons can be created, making them essentially useless. This by extension kills the Typesafe Enum pattern also.
    * eg 2- Objects with extra information, such as java.sql.Connection - if you copied this, would the copy be using the same socket connection, or would another connection be required? What happens if opening another connection, and the JDBC driver requires the password to be entered for every new connection? If the wrong password is entered, what happens to the newly creating connection?
    Implementation issue #2: Copying implementation?
    * Already mentioned by RPWithey. The only guaranteed way to perform the copy would be with a shallow copy, which may end up breaking things.
    Why can't you write the copy constructor yourself? If it's a special case, it only has to be done once. If it's a recurring case, you could write a code generation tool to write them for you, along with most of the rest of the class.

  • I can't take a card that has no money on I want it off my ipad mini because I can't update my games and I can't find on the computer and can't find it on the divice under visa master nor any one of them none and I think this would have to be an update

    Gift card will not get off my ipad mini and can't do updates

    maryfromedina wrote:
    I would like to buy some music and transfer to my Ipod.  There is no easy way to do it.
    Yes, it is very easy.
    Purchase the song then sync the iPod.
    A couple of weeks ago I talked to a tech for 15 min and he got me on.I used to be able to bring up my music, purchase new songs, transfer to Ipod and share with my laptop.  Can't do it anymore without calling support.
    Why cant you? Do it the same way as when you are on the phone with support.
    Do you get any messages? What are they?
    When do you see these messages?
    when downloading?
    when syncing?

  • Super class methods

    How to get the methods of current class and its super class using reflection. The retrieved methods should be only the methods of user-defined classes but not methods of Java APIs such as Object or any other class provided in JDK.
    For ex, If Class B is inheriting Class A, i need the methods which are declared only in A & B but not from the Object Class. Similarly, If class C is extending any JDK API such as Thread, I need only the methods declared in class C.

    thanku very much for the answer.
    I am trying to execute the methods of another class using reflection. So I have to consider the inherited methods also. For that, I have to differentiate between standard classes & user-defined classes.Assume that u have one GUI screen where in once u select a class all its methods including inherited methods have to be displayed.
    I can get the the superclass using the method getSuperClass(). But inorder to get the protected methods of superclass what is the method to be used ? If I use getMethods(), it returns only public methods, where as getDeclaredMethods() returns all the methods. Since I have to execute only public & protected methods, what is the best way to solve this ?

  • Binding of super class property

    can we bind super class property, for example:
    class A
    private String message;
    pubic String getMessage()
    return "My Message";
    public void setMessage( String message )
    this.message = message;
    class B extends A
    }now my managed bean returns me a collection of class B objects, and i want to bind in JSF page poperty of its super class like that:
    <h:outputText value="#{b.message}" />
    It gives me a error "PropertyNotFoundException: b.message.
    Is it possible in JSF ??
    regards,
    Y_NOT_

    I threw a quick test up on my JSF app and it works fine for me. It is not because of polymorphism. It must be in the way you are accessing the method. A typo or something small. Or perhaps it's because you are using a collection (and not accessing the Collection properly)?
    CowKing

  • Regarding Super classes

    Hi,
    I have created one class in SE24. This class will be used as a super class for other classes.
    When subclasses are derived from this superclass, i want to make sure that some of the methods of superclasses are redefined by the subclasse compulsarily.
    So i want to force the subclasses to redefine complusarily some of the methods of its super class.
    Is this feasible. If so please let me know the corresponding approach.
    Thanks in advance !
    Pramod

    Hi,
    Check this out this will help you.
    Inheritance is the concept of passing the behavior of a class to another class.
    1.You can use an existing class to derive a new class.
    2.Derived class inherits the data and methods of a super class.
    3.However they can overwrite the methods existing methods and also add new once.
    4.Inheritance is to inherit the attributes and methods from a parent class.
    Inheritance:
    Inheritance is the process by which object of one class acquire the properties of another class.
    Advantage of this property is reusability.
    This means we can add additional features to an existing class with out modifying it.
    Go to SE38.
    Provide the program name.
    Provide the properties.
    Save it.
    Provide the logic for inheritance.
    *& Report  ZLOCALCLASS_VARIABLES                      *
    *&----------------------------------------------------*REPORT  ZLOCALCLASS_VARIABLES.
    *OOPS INHERITANCE
    *SUPER CLASS FUNCTIONALITY
    *DEFINE THE CLASS.
    CLASS CL_LC DEFINITION.
    PUBLIC SECTION.
    DATA: A TYPE I,
          B TYPE I,
          C TYPE I.
    METHODS: DISPLAY,
             MM1.
    CLASS-METHODS: MM2.
    ENDCLASS.
    *CLASS IMPLEMENTATION
    CLASS CL_LC IMPLEMENTATION.
    METHOD DISPLAY.
    WRITE:/ 'THIS IS SUPER CLASS' COLOR 7.
    ENDMETHOD.
    METHOD MM1.
    WRITE:/ 'THIS IS MM1 METHOD IN SUPER CLASS'.
    ENDMETHOD.
    METHOD MM2.
    WRITE:/ 'THIS IS THE STATIC METHOD' COLOR 2.
    WRITE:/ 'THIS IS MM2 METHOD IN SUPER CLASS' COLOR 2.
    ENDMETHOD.
    ENDCLASS.
    *SUB CLASS FUNCTIONALITY
    *CREATE THE CLASS.
    *INHERITING THE SUPER CLASS.
    CLASS CL_SUB DEFINITION INHERITING FROM CL_LC. "HOW WE CAN INHERIT
    PUBLIC SECTION.
    DATA: A1 TYPE I,
          B1 TYPE I,
          C1 TYPE I.
    METHODS: DISPLAY REDEFINITION,     "REDEFINE THE SUPER CLASS METHOD
             SUB.
    ENDCLASS.
    *CLASS IMPLEMENTATION.
    CLASS CL_SUB IMPLEMENTATION.
    METHOD DISPLAY.
    WRITE:/ 'THIS IS THE SUB CLASS OVERWRITE METHOD' COLOR 3.
    ENDMETHOD.
    METHOD SUB.
    WRITE:/ 'THIS IS THE SUB CLASS METHOD' COLOR 3.
    ENDMETHOD.
    ENDCLASS.
    *CREATE THE OBJECT FOR SUB CLASS.
    DATA: OBJ TYPE REF TO CL_SUB.
    START-OF-SELECTION.
    CREATE OBJECT OBJ.
    CALL METHOD OBJ->DISPLAY. "THIS IS SUB CLASS METHOD
    CALL METHOD OBJ->SUB.
    WRITE:/'THIS IS THE SUPER CLASS METHODS CALLED BY THE SUB CLASS OBJECT'COLOR 5.
    SKIP 1.
    CALL METHOD OBJ->MM1.     "THIS IS SUPER CLASS METHOD
    CALL METHOD OBJ->MM2.
    *CREATE THE OBJECT FOR SUPER CLASS.
    DATA: OBJ1 TYPE REF TO CL_LC.
    START-OF-SELECTION.
    CREATE OBJECT OBJ1.
    SKIP 3.
    WRITE:/ 'WE CAN CALL ONLY SUPER CLASS METHODS BY USING SUPER CLASS OBJECT' COLOR 5.
    CALL METHOD OBJ1->DISPLAY. "THIS IS SUPER CLASS METHOD
    CALL METHOD OBJ1->MM1.
    CALL METHOD OBJ1->MM2.
    This example will help you to solve your problem.
    For more detailed information GOTO -> SAPTECHNICAL ->Tutorials -> Object Oriented Programming.
    Regards Madhu.
    Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:13 PM

  • Is there any way to access an overridden method of super class?

    class Animals
         void makeNoice(){System.out.println("General noice");}
    class Dog extends Animals
              void makeNoice(){System.out.println("bark");}
    };Is there any way to access the makeNoice() of Animals class from a Dog object
    Dog dog = new Dog();
    Animal animaldog = dog;
    animaldog.makeNoice(); // will always calls Dog's makeNoice() ie the overriden method.
    Is there a way to access the Animals makeNoice() method ? by using cast or super etc?
    Or it is not possible at all?

    Rajeebs wrote:
    Now another question coming in my mind.
    Whether any way to access a method which belong to super class's super class without using any method of class B,
    like super.super.fn() ??Isn't this just the same question again? And won't you again just "solve" it by writing some invokeSuperSuperMethod or other? This flawed design is quickly getting out of hand, isn't it? The question isn't "How can I invoke an arbitrarily deep superclass' method?" but more "Why do I need to invoke a method belonging to a concrete type at all?". If you need to do that, chances are you've misused inheritance.
    To use your initial sample code, in what circumstance would you require that a Dog make anything other than a Dog noise? It makes no sense. Point is, you have an Animal abstraction, and can call makeNoise on any instance of any subclass, and it will make the appropriate noise. By trying to use trickery to force other noises, you're doing something unnatural, and you're also depending on actual specific concrete subclasses. If you're going to go to specific classes and ask them to make their noise, what use is the inheritance? What use it the polymorphism?
    Are we heading into another "I've got a brilliant idea for a [useless language feature|http://forums.sun.com/thread.jspa?threadID=5423706&messageID=10905772#10905772], guys!" thread?

  • Super Class of Java

    can any one tell what is the super class of JAVA?

    How can u assume a to be = b and then prove that a = b based on the assumption that a=b... --:)
    also 0 = 1 ....> which leaves Aryabhatta thinking why the Hell did I invented zero , when it will turn out to be 1 in future .:). no NOR gates required .. cool ... No boolean datatype required ....... rather no computer bo byte funda when 1 = 0 ..... Hurray so no Java ...... No Exceptions ..... So we would be only left with our old Crashproof Word Processor ( Commonly known as TypeWriter)

  • Error while calling a super class public method in the subclass constructor

    Hi ,
    I have code like this:
    CLASS gacl_applog DEFINITION ABSTRACT.
      PUBLIC SECTION.
        METHODS:
                create_new_a
                   IMPORTING  pf_obj       TYPE balobj_d
                              pf_subobj    TYPE balsubobj
                              pf_extnumber TYPE string
                   EXPORTING  pfx_log_hndl TYPE balloghndl
                   EXCEPTIONS error
    ENDCLASS.
    CLASS gacl_applog IMPLEMENTATION.
      METHOD create_new_a.
        DATA: ls_log TYPE bal_s_log.
      Header aufsetzen
        MOVE pf_extnumber TO ls_log-extnumber.
        ls_log-object     = pf_obj.
        ls_log-subobject  = pf_subobj.
        ls_log-aluser     = sy-uname.
        ls_log-alprog     = sy-repid.
        ls_log-aldate     = sy-datum.
        ls_log-altime     = sy-uzeit.
        ls_log-aldate_del = ls_log-aldate + 1.
        CALL FUNCTION 'BAL_LOG_CREATE'
             EXPORTING
                  i_s_log      = ls_log
             IMPORTING
                  e_log_handle = pfx_log_hndl
             EXCEPTIONS
                  OTHERS       = 1.
        IF ( sy-subrc NE 0 ).
          MESSAGE ID      sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH    sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                  RAISING error.
        ENDIF.
      ENDMETHOD.
    CLASS gcl_applog_temp DEFINITION INHERITING FROM gacl_applog.
      PUBLIC SECTION.
        DATA: log_hndl   TYPE balloghndl READ-ONLY
            , t_log_hndl TYPE bal_t_logh READ-ONLY
        METHODS: constructor
                   IMPORTING  pf_obj       TYPE balobj_d
                              pf_subobj    TYPE balsubobj
                              pf_extnumber TYPE string
                   EXCEPTIONS error
               , msg_add      REDEFINITION
               , display      REDEFINITION
    ENDCLASS.
    CLASS gcl_applog_temp IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD create_new_a
               EXPORTING  pf_obj       = pf_obj
                          pf_subobj    = pf_subobj
                          pf_extnumber = pf_extnumber
               IMPORTING  pfx_log_hndl = log_hndl.
        IF ( sy-subrc NE 0 ).
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                  RAISING error.
        ENDIF.
      ENDMETHOD.
    A public method of Super class has been called from the constructor of the sub class. we are getting the syntax error :
    ' In the constructor method, you can only access instance attributes, instance methods, or "ME" after calling the constructor of the superclass…'
    Can you please suggest how to change the code with out affecting the functioanlity.
    Thank you ,
    Lakshmi.

    Hi,
    Call that method by instance of Subclass.   OR
    SUPER-->method.
    Read very useful document
    Constructors
    Constructors are special methods that cannot be called using CALL METHOD. Instead, they are called automatically by the system to set the starting state of a new object or class. There are two types of constructors - instance constructors and static constructors. Constructors are methods with a predefined name. To use them, you must declare them explicitly in the class.
    The instance constructor of a class is the predefined instance method CONSTRUCTOR. You declare it in the public section as follows:
    METHODS CONSTRUCTOR
            IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL]..
            EXCEPTIONS.. <ei>.
    and implement it in the implementation section like any other method. The system calls the instance constructor once for each instance of the class, directly after the object has been created in the CREATE OBJECT statement. You can pass the input parameters of the instance constructor and handle its exceptions using the EXPORTING and EXCEPTIONS additions in the CREATE OBJECT statement.
    The static constructor of a class is the predefined static method CLASS_CONSTRUCTOR. You declare it in the public section as follows:
    CLASS-METHODS CLASS_CONSTRUCTOR.
    and implement it in the implementation section like any other method. The static constructor has no parameters. The system calls the static constructor once for each class, before the class is accessed for the first time. The static constructor cannot therefore access the components of its own class.
    Pls. reward if useful....

  • Overwriting a method of a super class in the subclass ???

    Hi,
    can somebody tell me whether it's possible to add a new implementation of a method in the sub class which is inherited from a super class?
    I want to model my program in that way:
    1. I define a super class with some implemented methods.
    2. This class should be inherited in a sub class. One method should be used as it was implemented in the super class but another method should be overwritten in the subclass.
    I know this concept from Java but I couldn't find a way how to do it in ABAP
    Many thanks for any help!
    Best regards,
    Birgit

    hi,
    yeas you can do it,
    Subclass can re-implement  the inherited public and protected methods from superclass.Class C1 contains method METH1(public) and METH2(protected), both of which are modified and re-implemented in  its subclass C2.also you can have ur own methods in subclass.Objects are created out of both classes and the method METH1 for both objects are called.
    Output of the program demonstrates different behaviour for method METH1 of class C1 and C2.
    This demonstrates the theme.
    REPORT YSUBDEL.
    CLASS C1 DEFINITION.
      PUBLIC SECTION.
       METHODS : METH1.
      PROTECTED SECTION.
       METHODS METH2.
      ENDCLASS.
    CLASS C1 IMPLEMENTATION .
      METHOD : METH1.
       WRITE:/5 'I am meth1 in class C1'.
       CALL METHOD METH2.
      ENDMETHOD.
      METHOD : METH2.
       WRITE:/5 ' I am meth2 in class C1 '.
      ENDMETHOD.
    ENDCLASS.
    CLASS C2 DEFINITION INHERITING FROM C1.
    PUBLIC SECTION.
      METHODS : METH1 redefinition,
      meth3.
    PROTECTED SECTION.
      METHODS : METH2 redefinition.
    ENDCLASS.
    CLASS C2 IMPLEMENTATION.
    METHOD METH1.
       WRITE:/5 'I am meth1 in class C2'.
       call method meth2.
    endmethod.
      METHOD : METH2.
      WRITE:/5 ' I am meth2 in class C2 '.
    ENDMETHOD.
    METHOD : METH3.
      WRITE:/5 ' I am own method of class C2'.
    ENDMETHOD.
    endclass.
    START-OF-SELECTION.
      DATA : OREF1 TYPE REF TO C1 ,
             OREF2 TYPE REF TO C2.
      CREATE OBJECT :  OREF1 , OREF2.
      CALL METHOD : OREF1->METH1 ,
                    OREF2->METH1.
    hope it helps,
    regards

  • Weird one..  i can't return a variable from the extended to the super class

    Hey everyone, i hope i'm not annoying you guys :)
    So today's problem is to return a variable (int) from a method of the extended class and print it ont the super class.
    I'm just testing the super class , if it works fine.
    So the extended class ( FileIO) just read the file txt and return the integer or string ( from the txt file)
    I already did a main method to that class and tested it, it works fine.
    So now the problem is to print the integer ( that the extended class gets from the txt. ) inside the Super class. I mean , is the same thing but now im testing the Super class , just have to do the same thing, a super class method calls the extended class method and receive the integer from the txt file.
    i think the problem is when i create the instance of the FileIO object , maybe its constructor ...i don't know.
    The name of the txt file is passed from the super class to the extended class, but i think the error is not from there.
    this.aero_le = new BufferedReader(new FileReader(super.ficheiroleitura_aero()));  //  super calls ficheiroleitura_aero()  and receive the name of the txt file ( e.g "temp.txt")  so i think that is correct.
    here's the code of the Super class public class Aeroporto {
         private String filereader_voo = "temporary.txt";
         private String filereader_aero = "temp.txt";
         private String siglaAero = "";
         public FileIO file;
         public Aeroporto(){};
         public Aeroporto(String filereader_voo, String filereader_aero) throws IOException{
              this.filereader_voo = filereader_voo;
              this.filereader_aero =filereader_aero;     
              file = new FileIO();
         public String siglaAero() {
              return siglaAero; }
         public String filereader_aero(){
              return filereader_aero;
    public int nrLines() throws IOException{   // it was supose to retunr the number of lines ( integer) from the txt file .
              return Integer.parseInt(file.lerLinhaN(1,1));
    // main() {
    Aeroporto a = new Aeroporto();
              int v = a.nrLines();
              System.out.print(v);
    // ***********************************************************+
    // Extended Class
    public class FileIO extends Aeroporto{
         private String ficheiroescrita;
         private PrintWriter vooescreve, aeroescreve ;
         private BufferedReader voo_le, aero_read;
         public FileIO(){}
         public FileIO(String filereader_voo, String filereader_aero, String ficheiroescrita) throws IOException {
              super(filereader_voo, filereader_aero);
              this.ficheiroescrita = ficheiroescrita;
              //If file does not exists , create one.
              try{
                   this.aero_read = new BufferedReader(new FileReader(super.filereader_aero()));
                   aero_read.close();
              catch(IOException ex){
                   this.aeroescreve = new PrintWriter(new FileWriter(ficheiroescrita));
                   aeroescreve.close();
    public String lerLinhaN(int line, int column) throws IOException{  // this method works fine , i already tested this class.
              this.aero_read = new BufferedReader(new FileReader(super.filereader_aero()));
              for(int i = 0; i != line-1; ++i) aero_read.readLine();
              String linha = aero_read.readLine();
              String [] words = linha.split(" ");
              return words[column-1];
    Maybe the error is that i use to test the Super class a default contructor on both classes... i don't know where the error is, i also did two small classes ( super and another that extends ) and get the string "Hello" from the super and print it inside the extended..and it works, that's why i think the error is when i call the extended class .. need help.
    thanks.

    Ok,
    This one might actually work... atleast it compiles.import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.File;
    import java.io.PrintWriter;
    import java.io.FileWriter;
    import java.io.IOException;
    public abstract class FileIO {
         public static boolean CreateOutputFileIfNotExists(
              String outputFilename //the name of the file to ensure exists.
         ) throws IOException
              final String functionName = "FileIO.CreateOutputFileIfNotExists";
              boolean retVal = false;
              //If the output file does does not exist then create it.
              //post condition: output file exists or an IOException has been thrown.
              BufferedReader infile = null;
              try{
                   infile = new BufferedReader(new FileReader(outputFilename));
                   retVal = true;
              } catch(IOException ex) {
                   PrintWriter outfile = null;
                   try {
                        outfile = new PrintWriter(new FileWriter(outputFilename));
                        retVal = true;
                   } catch(IOException ex2){
                        throw new IOException(functionName + ": cannot create output file " + outputFilename, ex2);
                   } finally {
                        outfile.close();
                        if (outfile.checkError()) {
                             throw new IOException(functionName + ": error on output stream " + outputFilename);
              } finally {
                   try {
                        infile.close();
                   } catch(IOException ex){
                        throw new IOException(functionName + ": cannot close output file " + outputFilename, ex);
              return(retVal);
         public static String readLine(
                   String  inputFilename //the name of the file to read.
              , int     lineNumber    //1 based number of the line to read from.
         ) throws IOException
              final String functionName = "FileIO.readLine";
              String outputLine = null;
              // reads the numbered "lineNumber" from "inputFilename".
              BufferedReader infile = null;
              try {
                   infile = new BufferedReader(new FileReader(new File(inputFilename)));
                   for(int i=1; i<lineNumber; ++i) infile.readLine();
                   outputLine = infile.readLine();
              } catch(IOException ex){
                   throw new IOException(functionName + ": cannot read input file " + inputFilename, ex);
              } finally {
                   try {
                        infile.close();
                   } catch(IOException ex){
                        throw new IOException(functionName + ": cannot close input file " + inputFilename, ex);
              return(outputLine);
         public static String readWord(
                   String inputFilename  //the name of the file to read.
              , int lineNumber        //1 based number of the line to read from.
              , int wordNumber        //0 based number of the word to read.
         ) throws IOException
              final String functionName = "FileIO.readWord";
              String outputWord = null;
              // reads the numbered space-seperated "wordNumber" from the numbered "lineNumber" of "inputFilename"
              try {
                   String[] words = FileIO.readLine(inputFilename, lineNumber).split(" ");
                   if (wordNumber>0 && wordNumber<words.length) outputWord = words[wordNumber-1];
              } catch(IOException ex){
                   throw new IOException(functionName + ": cannot read input file " + inputFilename, ex);
              return(outputWord);
    }Design notes... FileIO is a generic helper class... there is nothing specific to Airports, flights, or any other "domain" specific stuff in it... so it's re-usable... you can keep it and reuse it on other projects, or even share it with your friends.
    So... The airport class will just call the static methods on FileIO like this    ....
        int lineNumber=1;
        int wordNumber=1;
        String airportCode = FileIO.readWord(airportsFilename, lineNumber, wordNumber);
        ....How's that?
    corlettk: my now mandatory edit.

  • How is super class's method called?

    I'm having some doubt about Item 15 in Effective Java, "Design and document for inheritance or else prohibit it".
    The author says if a class is intended to be inherited, then its constructor must not invoke any overridable methods. He gives the following example code. The result of running proves the author's word: The first line is null, and then the second line is a date.
    My question is why Super's constructor calls Sub's version of m, but not its own? Can anyone give me some explanation?
    import java.util.*;
    class Super {
    // Broken - constructor invokes overridable method
        public Super() {
            m();
        public void m() {
    public final class Sub extends Super {
        private final Date date; // Blank final, set by constructor
        Sub() {
            date = new Date();
    // Overrides Super.m, invoked by the constructor Super()
        public void m() {
            System.out.println(date);
        public static void main(String[] args) {
            Sub s = new Sub();
            s.m();
    }

    First up, it's handy (good practice?) to include
    calls to super() in your constructors as an explicit
    reminder as to the order that they'll be executed,
    e.g.
    Sub() {
    super();
    date = new Date();
    }This makes it clear that the superclass's
    constructor will be executed before date is
    initialised.
    Now to your question: a subclass and a superclass
    form a single whole object; the subclass doesn't 'sit
    on top' of the superclass, as it were. Because the
    subclass, Sub, overrides the superclass's
    implementation of method m, its implementation will
    always be invoked. Only Sub.m can call its
    super implementation (i.e. super.m()); So, for
    example, even this would call Sub's implementation of
    method m:Super a = new Sub();
    a.m(); // will invoke Sub.m(), not Super.m()!
    Thank everybody for all the replies.
    Super a = new Sub();
    a.m(); // will invoke Sub.m(), not Super.m()!This is easy to understand. although a is of type Spuer, it's an instance of Sub, so the runtime will decide to invoke Sub's implemention. This is right where Polymorphism comes.
    So it can go a step further, when an instance is being constructed, an instance of Super never exists, and there is only one instance, it's a Sub instance. So, although the m method is invoked by the Super constructor, which version is invoked is chosen by the instance.

  • Calling constructor of super class

    Hello everyone! I'm a student. I hope I can find guidance. Here's the issue:
    Super class: Property
    Sub class: House
    constructor of parent class:
    protected Property(String id, char status, String address,
            String tenet, String landlord, long rent, char freq,
            long amtDue, String date, boolean repair, char tradesman)
            this.id = id;
            this.status = status;
            this.address = address;
            this.tenet = tenet;
            this.landlord = landlord;
            this.rent = rent;
            this.freq = freq;
            this.amtDue = amtDue;
            this.repair = repair;
            this.tradesman = tradesman;
            SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yy");
            this.dateDue = formatter.parse(date, new ParsePosition(0));
        }the constuctor of the sub class:
    public House(String id, char status, String address,
            String tenet, String landlord, long rent, char freq,
            long amtDue, String dateDue, boolean repair, char tradesman,
            int broom, int proom, int throom, boolean garden,
            boolean garage, boolean heating)
        super(id, status, address, tenet, landlord, rent, freq,
            amtDue, dateDue, repair, tradesman);
        this.broom = broom;
        this.proom = proom;
        this.throom = throom;
        this.garden = garden;
        this.garage = garage;
        this.heating = heating;
        }I'm sure you notice I'm calling the constructor of the Property in House. That;s where the error is when i try to compile either class. This is the error it shows within the House class.
    Object() in java.lang.Object cannot be applied to (java.lang.String,char,java.lang.String,java.lang.String,java.lang.String,long,char,long,java.lang.String,boolean,char)
    Maybe its elementary? Thanks in advance..

    You haven't pasted all the code so I can only guess that the class House does not extend Property class.
    public class House extends Property
      // put the constructor here
    }If the House class does not extend Property (or any other class) it just extends (by default) the Object class, which does not have the constructor of Property class.
    Hope it helps
    Nick

  • Super class for java Language

    which is the super class for java Language...
    this is an interview question .
    I SAY Object is the super class for java Language ...
    then he asked whether object class will extend ??
    i say Yes it will implectly extend ...
    then he whether each and every class will extend object
    i say yes ...
    then he asked multiple inheritance is possible in java ...
    i say no ...
    then how will say object class will extend in each and every class....
    hai friends if there is any solution tell mem
    by
    dhana

    which is the super class for java Language...
    this is an interview question .
    I SAY Object is the super class for java Language
    ge ...If you mean the ultimate parent of all classes, yes.
    (Although it's not the parent of interfaces.)
    then he asked whether object class will extend ??
    i say Yes it will implectly extend ...Not sure what is meant by "will object extend."
    then he whether each and every class will extend
    object
    i say yes ...Correct.
    then he asked multiple inheritance is possible in
    java ...
    i say no ...Correct. At least in the usual sense. When people talk about multiple inheritance, the usually mean multiple inheritance of implementation, such as C++ supports. The ability to implement more than one interface in Java is sometimes referred to as multiple inheritance of interface. I don't know if that term is in common use outside of Java.
    then how will say object class will extend in each
    and every class....
    hai friends if there is any solution tell memMultiple inheritance means that a class' ancestors are not all in a straight line to the ultimate parent. That is, not all ancestors are parents or children of each other.
    You are you father's son, and he is his father's son, and so on. So your grandfather is your ancestor, and so is your father. This is not MI.
    You also have a mother. She's neither an ancestor nor a descendant of your father. That's MI.

Maybe you are looking for