Subclassing RemoteException

Dear All,
I want to differentiate between various errors that may happen on server side and then take appropriate actions on client side. I thought to do it by subclassing RemoteException and catching the appropriate subclasses. However, it is always RemoteException what is actually thrown, with subclass nested in it.
The only thing that works is:
catch (RemoteException re) {
   if (re.detail instanceof ASubclass)
     do what you want;
}But is not too pretty.
Can someone tell me why is RemoteException supposed to work this way?
Thanks

Know your dilemma.
The getMessage()::RemoteException doesn't always return a message. Even when you get something it may not reflect the true error.
Remote Exception is the superclass. Meaning everything under the sun is pushed into it.
You have to trap the error on the Server side. This is not so easy. What we ended up doing was editing the _Stub Class by putting in printStackTrace(), (and other code), in the catch statements. It ain't pretty, but it worked.
You can get the _Stub source by running rmic with the -keepgenerated option.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

Similar Messages

  • Remote Interface question

    I have a remote Interface as follows.
    public interface AccessDataBaseI {
    List retrieveItems(Object id) throws ApplicationException;
    The ApplicationException extends RemoteException.
    public class ApplicationException extends RemoteException {
    public AppException () {}
    public AppException (String msg) {
    super(msg);
    I build compile the application and I dont have a problem .When I deploy it to the server I get the following error message .
    method retrieveItems(Object id) defined in the remote interface must include java.rmi.RemoteException in its throws clause.
    It includes the ApplicationException in its signature which extends RemoteException .
    Any ideas what could be wrong and how to over come this .
    I am using weblogic 8.1.4 .
    Thanks for your help.

    It's not a good idea to subclass RemoteException for your ApplicationException. RemoteException
    should be preserved for system level failures. I would recommend instead subclassing
    java.lang.Exception. If you're using the EJB 3.0 Remote business interface there is no longer
    a requirement to declare RemoteException on each method signature.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • RE: exception handling

    Wayne,
    When an exception occurs, Forte aborts the inner
    most compound statement, after executing the code
    of an exception handler if there is one. If the excep-
    tion is not handled, it still exists after the compound
    statement was aborted, so Forte now aborts the
    remaining inner most compound statement. This
    continues until Forte reaches the root compound
    statement of the tread (or "task" if you will). This
    one will also be aborted and that is the end of the
    thread (task). If you look at the debugger, you will
    see "RIP" in front of this thread. Sure, this thread
    was spawned by another thread. It was started
    by a "start task" call from within some compound
    statement in the parent thread, but this compound
    statement was probably long since closed. Forte
    can't pass the exception on to a higher level com-
    pound statement, because there is none. If the
    thread started with a method that had a return event
    and an exception event, and you started the task
    with "Completion = event" then Forte will post one
    of these events after the root compound statement
    was finished (in other words, the thread was stopped).
    From this event you can see, if the thread wasfinished succesfully or not.
    Of course, an event is not the same kind of thing
    as an exception. You can't raise events, or post
    exceptions.
    So, when an exception is not handled, only the thread
    where this exception occured is cancelled (including
    all it's child threads). The rest of the treads stay alive.
    -----Original Message-----
    From: Wayne Walker [SMTP:[email protected]]
    Sent: Wednesday 22 July 1998 13:49
    To: '[email protected]'
    Subject: exception handling
    I have a problem in handling exceptions detected in a task. I start a
    task
    which performs some function. I also have an event handler which
    recognizes the method_exception returned should an exception be
    detected.
    Once detected by the event handler I force the exception up to
    another
    process which displays the exception to the user. However, it appears
    that
    forte is intercepting the exception before my event handler can detect
    it
    and posts an exception message. Can anyone explain how this mechanism
    works and the best approach for handling exceptions myself vice Forte?
    Thanks,
    Wayne
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    My understanding is that if your client doesn't care (or cannot handle) the exception,
    you throw your exception WRARPPED with EJBException. This way, the container can
    roll back the transaction properly.
    If your client cares (or have the ability to recover) the exception, you should
    define your own exception. They should not be derived from RuntimeException or
    RemoteException or EJBException. If you want to make sure that the transactions
    are rolled back, you call setRollbackOnly() before you throw the exception.
    Charles
    soraya abbasi <[email protected]> wrote:
    I have tried to make my custom exception subclass RemoteException but
    that doesn't work.
    Does that mean to say you can't have custom exceptions thrown to a client?

  • Can't use RemoteException.getCause() instanceof MyException !!

    Hi there, please help me out on this one, I just can't figure out the problem!
    I have a swing client and a Session EJB that will throw a DataNotFoundException (subclass of EJBException) if the supplied id was not found in the database:
    And as the EJBException is a RuntimeException, it will be autowrapped in RemoteException by the EJB container. Now, on the client we use RemoteException.getCause() to get this DataNotFoundException. getCause returns a Throwable (highest in hierarchy). Now, shouldn't I be able to use instanceof DataNotFoundException?? I mean, it is indeed an exception of this type! But the comparison gives FALSE! However, using (...instanceof Throwable) gives TRUE, as does comparing with Exception!
    Anyone knows why I don't get true on (re.getCause() instanceof DataNotFoundException) ??
    I'd be very pleased if someone knows the answer!!
    Best regards,
    AC
    (I posted this question on SUN/java language forum too, but got no answers yet!)
    try{
    filmEJB.insertOrder(orderVO,number);
    }catch(RemoteException re){
    if (re.getCause() instanceof DataNotFoundException)//returns false!!!
    System.out.println("CAUGHT DataNotFoundException");
    re.printStackTrace();
    //etc, etc

    Hi,
    Is DataNotFoundException is your own exception class defined!
    If so try using the initCause() in your constructor to propagate the exception's cause!
    Cheers,
    Dwaraka.

  • RemoteException stacktrace

    Hello, ugly question:
    If I do:
    e.printStackTrace()
    where 'e' is a subclass of java.rmi.RemoteException, and then throw it to the client, when I catch it in the client side and do:
    e.printStackTrace()
    I get different output. It seems that some information of the stacktrace do not travel to the client. I need full loging of the exceptions.
    In the app server:
    com.sofrecom.frameworkExceptions.negocio.BusquedaExcepcion: Error en la busqueda.; nested exception is:
         com.sofrecom.frameworkExceptions.logica.EJBBuscarExcepcion: No se encontro la entidada con Clave=1; nested exception is: javax.ejb.ObjectNotFoundException: No such entity: 1
    com.sofrecom.frameworkExceptions.logica.EJBBuscarExcepcion: No se encontro la entidada con Clave=1; nested exception is: javax.ejb.ObjectNotFoundException: No such entity: 1
    javax.ejb.ObjectNotFoundException: No such entity: 1
         com.sofrecom.frameworkExceptions.aplicacion.OperacionLocal OperacionLocalHome_EntityHomeWrapper6.findByPrimaryKey(java.lang.Long)
              OperacionLocalHome_EntityHomeWrapper6.java:394
         java.lang.Long com.sofrecom.frameworkExceptions.logica.ejb.AccesoOperacionBean.obtenerOperacion(java.lang.Long)
              AccesoOperacionBean.java:44
         java.lang.Long AccesoOperacionLocal_StatelessSessionBeanWrapper2.obtenerOperacion(java.lang.Long)
              AccesoOperacionLocal_StatelessSessionBeanWrapper2.java:100
         java.lang.Long com.sofrecom.frameworkExceptions.negocio.ejb.MiFacadeBean.obtenerOperacion(java.lang.Long)
              MiFacadeBean.java:43
         java.lang.Long MiFacade_StatelessSessionBeanWrapper0.obtenerOperacion(java.lang.Long)
              MiFacade_StatelessSessionBeanWrapper0.java:101
         java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])
              native code
         void com.evermind.server.rmi.RMICallHandler.run(java.lang.Thread)
              RMICallHandler.java:119
         void com.evermind.server.rmi.RMICallHandler.run()
              RMICallHandler.java:48
         void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
              PooledExecutor.java:797
         void java.lang.Thread.run()
              Thread.java:484
    com.sofrecom.frameworkExceptions.logica.EJBBuscarExcepcion: No se encontro la entidada con Clave=1; nested exception is: javax.ejb.ObjectNotFoundException: No such entity: 1
         java.lang.Long com.sofrecom.frameworkExceptions.logica.ejb.AccesoOperacionBean.obtenerOperacion(java.lang.Long)
              AccesoOperacionBean.java:58
         java.lang.Long AccesoOperacionLocal_StatelessSessionBeanWrapper2.obtenerOperacion(java.lang.Long)
              AccesoOperacionLocal_StatelessSessionBeanWrapper2.java:100
         java.lang.Long com.sofrecom.frameworkExceptions.negocio.ejb.MiFacadeBean.obtenerOperacion(java.lang.Long)
              MiFacadeBean.java:43
         java.lang.Long MiFacade_StatelessSessionBeanWrapper0.obtenerOperacion(java.lang.Long)
              MiFacade_StatelessSessionBeanWrapper0.java:101
         java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])
              native code
         void com.evermind.server.rmi.RMICallHandler.run(java.lang.Thread)
              RMICallHandler.java:119
         void com.evermind.server.rmi.RMICallHandler.run()
              RMICallHandler.java:48
         void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
              PooledExecutor.java:797
         void java.lang.Thread.run()
              Thread.java:484
    In the client side:
    com.sofrecom.frameworkExceptions.negocio.BusquedaExcepcion: Error en la busqueda.; nested exception is:
         com.sofrecom.frameworkExceptions.logica.EJBBuscarExcepcion: No se encontro la entidada con Clave=1; nested exception is: javax.ejb.ObjectNotFoundException: No such entity: 1
    com.sofrecom.frameworkExceptions.logica.EJBBuscarExcepcion: No se encontro la entidada con Clave=1; nested exception is: javax.ejb.ObjectNotFoundException: No such entity: 1
    javax.ejb.ObjectNotFoundException: No such entity: 1
    com.sofrecom.frameworkExceptions.logica.EJBBuscarExcepcion: No se encontro la entidada con Clave=1; nested exception is: javax.ejb.ObjectNotFoundException: No such entity: 1No se busco el cliente:
    Thanks.

    Assuming the stack trace info is not serialized, then you will obviously have to send it separately some how. One way is to get it into a string as follows:
    StringWriter sWriter = new StringWriter();
    PrintWriter sPrintWriter = new PrintWriter( sWriter );
    e.printStackTrace( sPrintWriter );
    sPrintWriter.flush();
    String theStackTrace = sWriter .toString() ;And of course you already know that code like this will losse a stack trace
    catch( Exception e )
    throw new Exception();
    }Now may I go back to my politic thread please ;->

  • Design question: RemoteException -- checked or unchecked

    I'm working an non-RMI RPC library and a question that has come up is how to deal with RPC-induced failures (networking outages, interface clashes). I'm curious what the RMI experience was with making RemoteException a checked exception. In retrospect, was this the right choice? Or should have it been unchcked? If you prefer the checked exception, is subclassing IOException still considered the correct approach?

    I think Sun got it right in both cases myself. The rationale is given at some length in http://research.sun.com/techrep/1994/abstract-29.html.

  • 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....

  • How to get the subclass from a super class( or interface)

    hi,
    I want to get subclass from a super class (or a interface), how to do that? the subclass of a interface means the class implementing the interface.
    for example;
    List ls;
    I want to get the subclass of ls, i.e., LinkedList, Stack, Vector......
    AbstractList al;
    the subclass of al, i.e., ArrayList, Vector.......
    thanks
    Aiwu

    List ls = new ArrayList();Since ls has been declared as a List we can only use List methods
    with it. This is a good thing because we might later want to change
    it to some other sort of List.
    I want to get subclass from a super class (or a interface), how to do
    that?The instance of the subclass declared above did not really come
    from the super class. A class "knows nothing" about its
    subclasses: many sub classes would not even exist at the time
    the class was written.

  • NSView subclass and mouse clicks

    I wrote a relatively simple program. It's got a single visual component on the window, an NSView subclass with drawing delegated out to another class called Arrow. Anyway, it uses a timer to trigger calls to drawRect which in turn "animates" a layer. I have a 100x100 layer and a velocity & position which get updated each time through depending on how much "real" time has passed. As the layer bounces around the screen, the animation seems smooth and everything looks good. If I start clicking in the window, however, things get wonky. The animation stutters (probably expected) and the position sometimes gets set back to the origin (0,0, bottom left corner of screen). I wonder if there's something I can do to stop mouse clicks from affecting the view, I have no set up anything to use the mouse clicks AT ALL so I don't really know how they can affect anything in the code I wrote. If this isn't enough info to answer the question, I'll post the xcode project.

    The end result is going to be a very simple 2d game with maybe 8-10 things on the screen moving around at any one time. My next step is to try out openGL but using these CALayers seemed a lot simpler. However, since you say any event will block, I expect that will happen to opengl as well. I'll dig some more in the examples. It seems I followed the pattern from the crash landing demo (although I'm doing it on the mac itself, not iphone/simulator) to set up the rendering.
    When you suggest using core animation, are you talking about just telling it the start/end position and the speed, and letting it handle everything in between? I don't think that will work for my case because eventually I will have to handle mouse/keyboard events to alter the movement in real-time. Am I missing something?
    Thanks again for your help.

  • How can I invoke a method on a subclass based on the runtime type?

    Hi all,
    I have defined a base class OrderDetail, and 2 subclasses which extend it: OrderDetailSingleReservation and OrderDetailMonthReservation. Furthermore, I have a method:
        public Order order_generate(OrderDetail orderDetail) {
            if (orderDetail instanceof OrderDetailSingleReservation) {
                return order_generate((OrderDetailSingleReservation) orderDetail);
            }  else if (orderDetail instanceof OrderDetailMonthReservation) {
                return order_generate((OrderDetailMonthReservation) orderDetail);
            } else {
                Misc.alert("orderAndInvoice_Generate(GENERIC): unsupported type.");
                return null;
        }The type of this method's parameter is OrderDetail, as you can see. (This particular method only serves as a kind of dispatcher and is therefore not very interesting in itself, but the same pattern using 'instanceof' occurs in a codebase I am working on several times, and I would like to factor it out if possible.)
    My question: it seems that the invocation of order_generate() from within this method requires an explicit downcast to one of the two subclasses. If not, java invokes the method on the superclass. But at runtime, the JVM knows what type of object it is dealing with, right? So is there no way to do this without the explicit downcast?
    A similar problem occurs when trying to invoke a method on an object whose type is one of the subclasses; the method on superclass is called, instead of the one in the appropriate subclass that overrides it.
    Any help would be greatly appreciated!
    Thanks,
    Erik

    Thanks for your replies! I was editing my post last night to clarify it, but my connection went down and the edit was lost :(
    Anyway, yes, it should be done with polymorphism. I was constructing an example using the famous Animal, Cat and Dog classes to demonstrate my question more clearly, and to my surprise the problem does not occur in my example code.
    LRMK: Invoking a method such as in your example, where the method is inside the class itself, works fine. However for MVC's sake, I have a separate class called Invoicing with methods as below:
    class invoicing
      // the method for the superclass
      public Invoice invoice_create(OrderDetail orderDetail) {
         System.out.println("type: " + orderDetail.getClass());
         return null;
      // the method for one of the subclasses (this method is being not invoked)
      public Invoice invoice_create(OrderDetailSingleReservation orderDetail) {
         return null;
      // ...nor is this one.
      public Invoice invoice_create(OrderDetailMonthReservation od) {
         return null;
    }Now I attempt to invoke these methods:
    // create example objects
    OrderDetailSingleReservation odSingle = new OrderDetailSingleReservation();
    OrderDetailMonthReservation odMonth = new OrderDetailMonthReservation();
    // this call displays "odSingle type: OrderDetailSingleReservation"
    System.out.println("odSingle type: " + odSingle.getClass());
    // this call displays "odMonth type: OrderDetailMonthReservation"
    System.out.println("odMonth type: " + odMonth.getClass());
    // this call invokes Invoicing.invoice_create(OrderDetail)
    // instead of Invoicing.invoice_create(OrderDetailSingleReservation)
    Invoicing.invoice_create(odSingle);
    // this call invokes Invoicing.invoice_create(OrderDetail)
    // instead of Invoicing.invoice_create(OrderDetailMonthReservation)
    Invoicing.invoice_create(odMonth);So these calls will invoke the method for the superclass, i.e. Invoicing.invoice_create(OrderDetail od). That method then then executes the System.out.println() call which displays the class type of its parameter as one of { OrderDetailSingleReservation | OrderDetailMonthReservation }, that is, the expected subclass types!
    So the dynamic dispatch isn't working the way I would expect it to. If I do the explicit if-else checking using instanceof, as described in my first post, the correct methods are called.
    I hope the problem is somewhat clearer now. I am a bit lost as to what might be causing this, or how to monitor what's going on inside the jvm. Any ideas? BTW, the OrderDetail class and its subclasses are JPA entities (though I don't think it should matter).
    Thanks!
    Erik

  • Unique methods in subclass: can't access if superclass was the cast

    Hey up,
    I have an abstract class - Boid - and two subclasses - PredatorBoid and PreyBoid.
    If I add a method to PreyBoid (not one that's over-riding a method from Boid: its unique to this class) something that confuses me occurs.
    I can access this method if I instantiate PreyBoid thus:
    PreyBoid p = new Preyboid();
    But how I want to instantiate it is as part of an array, thus:
    private Boid[] boids = new Boids[x];
    for (int i=0; i<numberOfBoids*2;i+=2) {
                boids[i] = new PreyBoid();
                boids[i+1] = new PredatorBoid();
            }But if make em this way, I can no longer access the method unique to PreyBoid.
    Am I missing something? Do I have to make two separate arrays for the different kind of boid (which somewhat defeats the point?)
    The alternative is to add abstract methods for every different subclass method - but given that some of them are unique to the subclasses, this seems like overkill and clutter.
    It also makes no difference if the superclass is abstract or not: if I start by casting the array as a Boid array, but fill it with sub-classes, I can only access the methods that have been over-ridden from the superclass.
    Any thoughts gratefully received! I have read plenty about this, but can't find an answer anywhere...

    You can cast them of course(see below). My advice is to use an ArrayList for each type. ArrayLists also resize dynamically and also support Generics which avoid casting. (Not in all Java versions though, 1.5 and upwards)
    ((PreyBoid)boids).getSomeValue();
    Message was edited by:
    helloWorld

  • How to create a UITableView subclass in Xcode 4?

    In Xcode 3 you can create a UITableView option while creating a new class. Now this option is gone and was replaced by an "iPad compatible" option. How can I get to the UITableView option? Or is there any other way to create an UITableViewController?

    Hey Elefantosque,
    I have been creating UITableView classes by doing the following:
    Select NewFile
    Select UIViewControllerSubclass and click Next
    Where it says 'subclass of', use the drop-down menu to select UITableViewController and click Next
    Enter your new file name and click Save.
    I hope this is what you are asking?
    james

  • How to call a subclass method.

    Hi:
    I am trying to call a method from the subclass. I get many errors. Please correct the following code.
    public abstract class A{
    private int id;
    public static void main(){
    A obj = new B(200);
    obj.subclassMethod;
    class B extends A{
    public void subclassMethod(){
    System.out.println("ID is : " +id);
    public B(int i){
    id = i;

    The first problem:
    A obj = new B(200);  // This is perfect
    obj.subclassMethod; // <--obj is an object of type "A" and "A" doesnt know "subclassMethod()"
    so in order to call "subclassMethod" you have to make a explicit casting to "B".
    ((B)obj).subclassMethod(); //remeber that calling a method needs "()"
    The second problem:
    System.out.println("ID is : " +id);You cannot acces a private variable or function from anywhere else but the class.
    If you want to acces you need to declare it:
    protected: for access from anywhere in the package and/or subclass(for your case i recomend this).
    public: for acces from anywhere.
    (nothing)package:(dont declare anything) acces for anywhere from the class.
    In resume:
    Change to the following lines to fix:
    private int id; // --> protected int id;
    obj.subclassMethod;  // --> ((B)obj).subclassMethod();I hope this help.
    N�stor Mata.

  • Why assigning a subclass instance to a variable of type of superclass ?

    Hi all,
    What is the significance of assigning an instance of a subclass to a variable whose type is a superclass's type.
    For eg. List list=new ArrayList();
    If I do so is it possible to execute the methods of the subclass ?
    regards
    Anto Paul.

    In addition, this is what polymorphism is all about:
    abstract class Animal {
      String name;
      Animal(String name) {
        this.name = name;
      public abstract void voice();
    class Dog extends Animal {
      Dog(String name) { super(name); }
      public void voice() {
        System.out.println(name+" barks");
    class Cat extends Animal {
      Cat(String name) { super(name); }
      public void voice() {
        System.out.println(name+" miaows");
    public class Polymorphism {
      public static void main(String args[]) {
        Animal[] animals = {
          new Dog("Fido"),
          new Cat("Felix")
        for (int i = 0; i < animals.length; i++) {
          animals.voice();
    Here, we are looping through an array of Animals. In fact, these are concrete subclasses of the abstract Animal class. In this simple example, you can see from the code that the animals array contains a dog and a cat. But we could even extend this to read in an arbitrary Animal object that had been serialized into a file. At compile time, the exact class of the serialized animal would not be known. But polymorphism occurs at runtime to ensure the correct voice() method is called.
    For the List, or Map example, conisder this:
    public SomeClass {
      public HashMap map1 = new HashMap();  // this ties you to hashmap
      public Map map2 = new HashMap();      // this allows you to change Map implementation
      public void process(HashMap map) {}   // this ties you to hashmap
      public void process(Map map) {}       // this allows you to change Map implementation
    }Suppose you use a HashMap for map2 to start with. But at some point in the future you would like to ensure your map is sorted. By specifying map2 to be a Map, you can change the implementation without having to modify each method call by simplying changing the initiliastion to be:
    Map map2 = new TreeMap();Hope some of this helps :) Cheers, Neil

  • Java.rmi.RemoteException: EJB Exception: while calling an EJB method,

    Hi
    I am getting below error while calling a stateless EJB method. There is some validation checks while performing ejb's modify() method and a RuntimeException is thrown in case of validation failure.The modify() method internally calls other stateless ejb as well.
    The problem I'm facing is, instead of getting the expected RuntimeException in the Servlet, i am getting RemoteException. I am using WLS 9 MP1, all participating ejbs are stateless and i am using default transaction attributes(Supports) for these ejbs.
    The interesting part is, at the ejb layer RuntimeException is thrown as expected, but this exception changed to RemoteException at the servlet's end where i am catching the ejb call exceptions.
    I am new to WLS, please suggest/help me out of this exception.
    Any help is truly appreciated.
    java.rmi.RemoteException: EJB Exception: ; nested exception is: java.lang.RuntimeException:
         at weblogic.ejb.container.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:95)
         at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:713)
         at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:681)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvoke1(BaseEJBObject.java:447)
         at weblogic.ejb.container.internal.StatelessEJBObject.postInvoke1(StatelessEJBObject.java:72)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvokeTxRetry(BaseEJBObject.java:374)
         at com.mycomp.base.BaseController_8x2e52_EOImpl.modify(BaseController_8x2e52_EOImpl.java:149)
         at com.mycomp.webgui.servlet.FrontComponent.service(FrontComponent.java:207)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:223)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3245)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2003)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1909)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Thanks!
    Edited by: user10721298 on Feb 23, 2009 4:16 AM

    Hi,
    If i don't misunderstand, you are using the RuntimeException as an application exception, right?
    Have you annotated it or denoted it in deployment descriptor?
    Thanks,
    Amy

Maybe you are looking for

  • Select "most recent" records in abap

    Hi how can I select the most recent records in a table by using the abap select statement. Example: The 100 rows with the "highest" (most recent) sequence-numbers in a table with documents. somehow like this:     SELECT "most recent" * FROM draw    

  • Pdf files as applications and preview crash

    hi everyone some system glitches im trying to figure out: I was following an apple guide on how to make FCP manuals (pdf) searchable by spotlight. It involved saving the manuals with Preview on the desktop ( those files are usually inside the FCP app

  • Pricing not copied from qoutation to Sales Order.

    Hi All, Issue: Discount pricing is not copied from Qoutation to Sales order. Please suggest the correct copy control/Routine programs which i can check to proceed furthur. Points will be rewarded. Regards, neslin.

  • Rosettanet - Testing

    Hi Experts, Here is our question related to PIP4A3 in Rosettanet. Please help We have configured 2 Scenario's. One with Sender as HTTP Adapter and Receiver as RNIF2.0 Adapter. Another Scenario RNIF2.0 as Sender and RFC adapter as receiver. Both these

  • Send metrics of PL/SQL to SONAR with Job Jenkins

    Hi, We are implemented Continuous Integration for PL/SQL using Jenkins and Sonar. We following one tutorial that we discovered on Web (Continuous Integration with Oracle PL/SQL, utPLSQL and Hudson – The Server Labs Blog). After following all steps, o