1

I have an invocation target exception issue. I am having one object(window) which i am calling on a click of a button, now using that common button on two different User Interfaces. The problem is that when i click on it on one UI it shows me the data but when i click it on other UI it returns invocation target exception.

Code is:

@Override
public void buttonClick(ClickEvent event) {

    // This if block will be called when user clicks on list of 
    // document button 
    if(event.getButton() == mlistButton) {
        try {
            listButtonButtonClicked();
        } catch (RequestDetailTableException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    // this if block will be called when user clicks on Tracking button
    if(event.getButton() == mtrackingButton) {
        trackingButtonClicked();
    }

}

/**
 * This function will be called when user clicks on list of
 * document button.
 * @throws Exception 
 */
protected void listButtonButtonClicked() throws RequestDetailTableException {

    DocumentListLayout ldocumentList = null;
    try {
        ldocumentList = new DocumentListLayout(mrequestInfoBean,mdetailRequestLayout.getGeoAISUI());
    } catch (DocumentListLayoutException e) {
        throw new RequestDetailTableException(e);
    }
    mdetailRequestLayout.getGeoAISUI().addWindow(ldocumentList);
} 

Stack Trace:

java.lang.NullPointerException
 at org.ids.geoais.common.RequestDetailTable.listButtonButtonClicked(RequestDetailTable.java:306)
 at org.ids.geoais.common.RequestDetailTable.buttonClick(RequestDetailTable.java:275)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
 at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:995)
 at com.vaadin.ui.Button.fireClick(Button.java:393)
 at com.vaadin.ui.Button$1.click(Button.java:61)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158)
 at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
 at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:313)
 at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:202)
 at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:95)
 at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
 at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
 at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:350)
 at org.ids.geoais.Servlet.service(Servlet.java:160)
 at javax.servlet.http.HttpSer

The compiler moves to this:

    /**
     * Constructs a InvocationTargetException with a target exception.
     *
     * @param target the target exception
     */
    public InvocationTargetException(Throwable target) {
        super((Throwable)null);  // Disallow initCause
        this.target = target;
    }
tushar sharma
  • 105
  • 2
  • 10
  • What's the full stacktrace and what does `getGeoAISUI()` return? – Morfic Jul 27 '16 at 11:48
  • it returns the UI object that common for the application – tushar sharma Jul 27 '16 at 13:09
  • 1
    Yes but you mentioned that you have multiple UIs, and since the UI has a meaning of _application_, does it return the correct one? Also please post the whole stacktrace. – Morfic Jul 27 '16 at 13:27
  • 1
    In most cases InvocationTargetException is caused by an underlying exception. Please post the full stack trace – agassner Jul 27 '16 at 19:12
  • @Morfic Please see the stack trace and UI's i have mentioned for the two vaadin layouts that are used in the project(MMI's) – tushar sharma Jul 28 '16 at 06:16
  • What about `NullPointerException at org.ids.geoais.common.RequestDetailTable.listButtonButtonClicked(RequestDetailTable.java:306)` do you not understand? – OneCricketeer Jul 28 '16 at 06:20
  • @agassner Here it is showing null pointer exception but this null point comes inside invocation target exception – tushar sharma Jul 28 '16 at 06:30
  • @criket_007 see i am getting your point but as i mentioned above the compiler is going somewhere inside the invocation target exception and showing me null – tushar sharma Jul 28 '16 at 06:32
  • What happens at line 306 of `RequestDetailsTable`? – Morfic Jul 28 '16 at 07:01
  • @Morfic It try to add the window of Display Document but when compiler comes to this line rather than adding the window it moves to invocation target exception that throws null – tushar sharma Jul 29 '16 at 06:37
  • @Morfic Actually on listbuttonclicked() it is calling the method called displayDocument() that add the window that is Display Document but on that method when the compiler comes goes to – tushar sharma Jul 29 '16 at 06:58
  • the method i have added above InvocationTargetException(Throwable target) – tushar sharma Jul 29 '16 at 07:02
  • Clearly an object you're trying to interact with at that line is null. You need to figure out which one and why. – Morfic Jul 29 '16 at 07:04
  • but how to resolve this – tushar sharma Jul 29 '16 at 07:06
  • Issue resoloved by retaining the object in the session and changing the state of UI adding windows to this layout – tushar sharma Jul 30 '16 at 10:42

0 Answers0