Handling Exceptions thrown by EDT Thread?

Hi,
How to handle exceptions thrown by EDT Thread?. If anybody can give any link or any example, then it really helpful.
Thanks

System.setProperty( "sun.awt.exception.handler", EventThreadExceptionHandler.class.getName() );

Similar Messages

  • Catching an exception thrown from another thread

    I have a SocketServer that creates new threads to handle incoming clients. If one of the threads throw a SQLException is it possible to catch that exception in the SocketServer that created that thread.
    I tried implementing this code and I cannot get the server to catch an exception thrown in the thread. Are my assumptions correct?
    I was reading something about Thread Groups and implementing an uncoughtException() method, but this looked like overkill.
    Thanks for your time!
    Some Example code would be the following where the ClientThread will do a database query which could cause an SQLException. I'd like to catch that exception in my Socket Server
          try
                 new ClientThread( socketServer.accept() , host, connection ).start();
          catch( SQLException e )
                 System.out.println( "DataSource Connection Problem" );
                  e.printStackTrace();
          }

    hehe, why?
    The server's job is to listen for an incoming message from a client and pass it off to a thread to handle the client. Otherwise the server will have to block on that incoming port untill it has finished handling the client and usually there are many incoming clients continuously.
    The reason I would want to catch an exception in the server based on the SQLException thrown in the thread is because the SQLException is usually going to be due to the fact the datasource connection has become unavalable, or needs to be refreshed. This datasource connection is a private variable stored in the socket server. The SocketServer now needs to know that it has to refresh that datasource connection. I would normally try to use somesort of flag to set the variable but to throw another wrench into my dilemma, the SocketServer is actually its own thread. So I can't make any of these variables static, which means I can't have the thread call a method on teh socket server to change the status flag. :)
    I guess I need implement some sort of Listener that the thread can notify when a datasource connection goes down?
    Thanks for the help so far, I figured java would not want one thread to catch another thread's exceptions, but I just wanted to make sure.

  • How to handle exception thrown in standard bo method in the workflow design

    Hi Experts
        how to handle exception thrown from standard bo method in the workflow design. For example, bo BUS2032, METHOD confirm. If the user cancel it, it will throw exception. In the workflow, how to catch this exception and add corresponding steps in the workflow.

    @jrockman li
    Try to implement the logic that what ever you are performing in the BO mehtod in a FM and in the FM you have tab with name EXECPTIONS define the execption in that tab.Now in the BO method you call this FM  and if the exception occurs by using RAISE you can raise the exception in the FM and based on the number of exceptions your sy-subrc value will be set
    so when sys-subrc is not eq 0 then pass a value back t the workflow container., I think this will work.
    a sample Snippet for understanding purpose
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename         = <path>
        filetype         = 'ASC'
      IMPORTING
        filelength       = lv_len
      TABLES
        data_tab         = l_txt_tab
      EXCEPTIONS
        file_write_error = 1          " If this Exception occurs
        invalid_type     = 2
        no_authority     = 3
        unknown_error    = 4
        OTHERS           = 10.
    CASE sy-subrc.
      WHEN 1. " SY-SUBRC value will be 1 then,
          " Pass or set the value back to the workflow conatiner element
    ENDCASE.

  • How to properly handle Exception thrown in a .tag file?

    I've got a .jsp file that makes use of some custom tags, each defined in their own .tag file, and located in WEB-INF/tags. I'm having a lot of trouble with the scenario of cleanly dealing with an exception raised by scriptlets in either a .jsp file, and a .tag file. I'm using both Java and Tomcat 6....
    Originally, I wanted to use .tag files in order to componentize common elements that were present in .jsp pages, as well as move ugly scriptlets out of .jsp pages, and isolate them in tag files with their associated page elements.
    Things started getting hairy when I started exploring what happens when an exception is thrown (bought not handled) in a scriptlet in a .tag file. Basically, my app is a servlet that forwards the user to various .jsp pages based on given request parameters. The forwarding to the relevant .jsp page is done by calls to the following method:
    servletContext.getRequestDispatcher("/" + pageName).forward(request, response);
    Where 'pageName' is a String with the name of the .jsp I want to go to...
    Calls to this method are enclosed in a try block, as it throws both a ServletException, and IOException...
    When either my .jsp, or .tag throw an exception in a scriptlet, the exception is wrapped in a JSPException, which is then wrapped in a ServletException.
    I can catch this exception in my servlet... but then what? I want to forward to an error page, however, in the catch block, I can't forward in response to this exception, as that results in an IllegalStateException, as the response has already been committed. So what do I do? How do I get from this point, to my "error.jsp" page?
    It was suggested to me that I use the <% @ page isErrorPage="true" %> directive in my error.jsp,
    and the in my real .jsp, use <%page errorPage="/error.jsp" %>.
    This works great when the exception is thrown in my .jsp.... But when the exception is thrown in the .tag file... not so much...
    My .jsp page was rendered up until the point where the <my:mytag/> (the tag with the offending raised exception) was encountered. Then, instead of forwarding to the error page when the error in the tag is encountered, the error page is rendered as the CONTENT of of my TAG. The rest of the .jsp is then NEVER rendered. I checked the page source, and there is no markup from the original .jsp that lay below the my tag. So this doesn't work at all. I don't want to render the error page WITHIN the half of the .jsp that did render... Why doesn't it take me away from the .jsp with the offending tag altogether and bring me to the error.jsp?
    Then it was suggested to me that I get rid of those page directives, and instead define error handling in the web.xml using the following construct:
    <error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error</location>
    </error-page>
    <error-page>
    <error-code>404</error-code>
    <location>/error</location>
    </error-page>
    For this, I created a new servlet called ErrorServlet, and mapped it to /error
    Now I could mangle the end of the URL, which causes a 404, and I get redirected to the ErrorServlet. Yay.
    However, exceptions being thrown in either a .jsp or .tag still don't direct me to the ErrorServlet. Apparently this error handling mechanism doesn't work for .jsp pages reached via servletContext.getRequestDispatcher("/" + pageName).forward(request, response) ????
    So I'm just at a total loss now. I know the short answer is "don't throw exceptions in a .jsp or .tag" but frankly, that seems a pretty weak answer that doesn't really address my problem... I mean, it would really be nice to have some kind of exception handler for runtime exceptions thrown in a scriptlet in .tag file, that allows me to forward to a page with detailed stacktrace output, etc, if anything for debugging purposes during development...
    If anyone has a few cents to spare on this, I'd be ever so grateful..
    Thanks!!
    Jeff

    What causes the exception?
    What sort of exception are you raising from the tag files?
    Have you got an example of a tag file that you can share, and a jsp that invokes it so people can duplicate the issue without thinking too much / spending too much time?
    My first instinct would be that the buffer is being flushed, and response committed before your Exception is raised.
    What you describe is pretty much standard functionality for Tomcat in such cases.

  • Handling exception thrown by parseEscapedXML function

    Hi,
    I am using parseEscapedXML function to parse an xml string in the below format .
    <parameters><item id="" value=""/><item id="" value=""/></parameters>
    The exception thrown when input is in incorrect xml format is not caught using catchAll.
    Kindly check if anyone have any idea about this.

    Hi,
    Ideally your BAPI shouldn't raise exceptions - it is much better to use the RETURN table from your BAPI with any relevant messages - have a look at the majority of standard SAP BAPI's in transaction BAPI.
    This way, the only exceptions your try... catch block needs to handle are those related to the actual calling of your BAPI, not it's functionality.
    Also, if you can successfully run the BAPI in SE37 but it fails when called from your WD application, try using the FBGENDAT functionality to capture what data is being passed to SAP from your Web Dynpro application.  All it takes is a simple mistake in setting up your contexts or logic and you won't be calling your BAPI correctly.
    Hope this helps,
    Gareth.

  • How to handle exceptions thrown by event

    Hi all,
    i have this slight problem, i'm trying to handle accessing a databse from a button click, i'm trying to simulate somebody logging on to a network. the code is as follows;
    *@author James Taylor
    *@version 30-11-2003
    *Logon gui
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    public class LogonUI extends JFrame {
         //instance variables
         private JLabel userNameL;
         private JPasswordField password;
         private JButton logon;
         ButtonHandler handler;
         Connection con;
         Statement stmt;
          *Constructor initialises and creates UI, adds functionality to the button.
         public LogonUI() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              super("Employee Logon");
              Container c = getContentPane();
              c.setLayout(new FlowLayout() );
              //handles what happens when user presses the button
               handler = new ButtonHandler();
              userNameL = new JLabel("Please Enter Password:");
              c.add(userNameL);
              password = new JPasswordField(15);
              c.add(password);
              logon = new JButton( "Logon" );
              //anonymous inner class that is created once the button is pressed.
              //it connects to database to validate user
              logon.addActionListener( handler );
              c.add(logon);
              c.setBackground( Color.pink );
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              setSize(250,150);
              setVisible(true);
          *class that opens connection to validate user
         private class ButtonHandler implements ActionListener {
              public void actionPerformed(ActionEvent ae)throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
                   try{
                        boolean isValidUser = false;
                        //Load mysql driver
                         Class.forName("com.mysql.jdbc.Driver").newInstance();
                         //make a connection
                        String url = "jdbc:mysql://localhost/flight";
                        con = DriverManager.getConnection(url)
                        //Create and instantiate a statement obj
                        stmt = con.createStatement();
                        //get a result set
                        ResultSet rs = stmt.executeQuery("SELECT Password FROM employees");
                        //Iterate through the result set
                        while ( rs.next() ){     
                             String savedPassword = rs.getString("Password");
                             if (password.getText().equals(savedPassword) ){
                                  isValidUser = true;
                                  JOptionPane.showMessageDialog(null,"Yipeeeee");
                        if (isValidUser == false){
                             JOptionPane.showMessageDialog(null,"Invalid Password");     
                        stmt.close();
                        con.close();
                   }catch(Exception e){ e.printStackTrace();}
              public static void main (String[] args) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              LogonUI testAirApp = new LogonUI();
    }When the user presses the button the app tries to validate the user.
    I have not been able to test the code due to SQL Exceptions thrown in the handler class, and when i try and throw them up from here i get;
    LogonUI.java:52: actionPerformed(java.awt.event.ActionEvent) in LogonUI.ButtonHandler cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; overridden method does not throw java.lang.InstantiationExceptionAny ideas on my code and how to handle these exceptions will be very appreciated. Regards, James

    Turn your checked exceptions into unchecked exceptions and retrieve the cause later:
    RuntimeException unchecked = new RuntimeException(checked);
    Throwable t = unchecked.getCause();Stephen

  • How webDynpro handles exception thrown by adaptive web service

    Hi people,
    in design time, webdynpro can handle web service's exception by defining return structure based on the <b>Fault </b>which is the exception defined in the web service. But in the runtime, when web service throws exception, webDynpro can not handle it, WD framework will throw nullPointerException.
    The reason behind it might be: let me assume a WS <b>getEmployeeNumber</b>, the WS returns employee number as a element <b><EmployeeNumber></b>12345<b></EmployeeNumber></b> in the return SOAP document. I think WD always expects the element <b><EmployeeNumber></b> in the SOAP document, but in case of exception, web service throws exception and will not provide employee number in the return SOAP which is logical, thus the element <EmployeeNumber> will not be available in the SOAP document, therefore causes WD framework to raise <b>nullPointerException</b>.
    So any of you have any suggestion to make webDynpro working in case an exception is thorwn in the web service?
    Thanks for your infor
    Jayson

    To encourage people, I include the text of the xml response from the test of Web Service Navigator window :
    HTTP/1.1 500 Internal Server Error
    Connection: close
    Server: SAP J2EE Engine/6.40
    Content-Type: text/xml; charset=UTF-8
    Set-Cookie: <value is hidden>
    Date: Mon, 27 Mar 2006 09:30:50 GMT
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
    <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
    <faultcode>SOAP-ENV:Client</faultcode>
    <faultstring>Hi, I'm the new exception</faultstring>
    <detail>
    <ns1:throwException_com.sap.demo.testexception.TestException xmlns:ns1='urn:TestExceptionServiceWsd/TestExceptionServiceVi' xmlns:pns='urn:com.sap.demo.testexception'>
    <pns:message>Hi, I'm the new exception</pns:message>
    </ns1:throwException_com.sap.demo.testexception.TestException>
    </detail>
    </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    I've found too a strange workaround :
    The fact seems that you have to design your session bean without throwing custom exceptions, then generates the VI and after that, adding the custom exceptions throws.
    Or if you don't want to modify the bussiness methods.
    The point is to eliminate the exceptions (faults) sections from the VI and WS deployment descriptor.
    You have to access from Package Explorer, and edit with a Text Editor the following files :
    *.videf from the package, and remove <Function.Faults> sections
    ws-deployments-descriptor.xml in META-INF, and remove <fault> sections
    After that, the WS Configurations will give an error, so delete the configuration and remake it. Now, the VI stills looks bad, so close the project, close NetViewer and reopen it to flush whatever cache it seems to keep.
    Now, your VI will looks better without exceptions, and you'll get their messages when you catch them in the WebDynpro applicattion.
    So, now the question is: Could anybody explain me why ?

  • Client side handling of exceptions thrown by a webservice

    I have a webservice that is deployed in Tomcat 5.5 running on Windows XP, Java version is 1.5, using jwsdp 1.5. My client, when run as an applet in a browser (have tried IE 6 and FireFox 1), seems to be unable to parse any exception thrown from the webservice. Instead the following exception is caught by the client:
    ==========================================================
    Checking the security service exception that occurred [Runtime exception; nested exception is:
    XML parsing error: com.sun.xml.rpc.sp.ParseException:1: Document root element is missing]
    com.irista.security.services.data.SecurityServiceException: Runtime exception; nested exception is:
    XML parsing error: com.sun.xml.rpc.sp.ParseException:1: Document root element is missing
    at com.irista.security.services.webclient.SecurityServiceProxy.removeAuthenticatio nProfile(SecurityServiceProxy.java:1276)
    at com.irista.security.ui.applet.AuthenticationProfilesListPanel.deleteAction(Auth enticationProfilesListPanel.java:131)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.irista.ui.webapp.framework.WebAppletPane.performAction(WebAppletPane.java:1 80)
    at com.irista.ui.webapp.framework.WebAppletPane.performAction(WebAppletPane.java:1 51)
    at com.irista.ui.webapp.framework.WebAppToolbar$ButtonActionListener.actionPerform ed(WebAppToolbar.java:368)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    ==========================================================
    If I run the client outside of a browser it catches the exception that is actually thrown by the webservice.
    Is there possibly a problem with the java 5 plugin handling exceptions thrown by webservices?
    I have not found any bug reports or forumn posts regarding this so any assistance would be greatly appreciated.
    thanks,
    scott

    Thanks for the reply, here is what the printStackTrace() output:
    java.rmi.RemoteException: Runtime exception; nested exception is:
         XML parsing error: com.sun.xml.rpc.sp.ParseException:1: Document root element is missing
         at com.sun.xml.rpc.client.StreamingSender._handleRuntimeExceptionInSend(StreamingSender.java:318)
         at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:300)
         at com.irista.security.services.webservice.SecurityServiceIF_Stub.removeAuthenticationProfile(SecurityServiceIF_Stub.java:1963)
         at com.irista.security.services.webclient.SecurityServiceProxy.removeAuthenticationProfile(SecurityServiceProxy.java:1266)
         at com.irista.security.ui.applet.AuthenticationProfilesListPanel.deleteAction(AuthenticationProfilesListPanel.java:131)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at com.irista.ui.webapp.framework.WebAppletPane.performAction(WebAppletPane.java:180)
         at com.irista.ui.webapp.framework.WebAppletPane.performAction(WebAppletPane.java:151)
         at com.irista.ui.webapp.framework.WebAppToolbar$ButtonActionListener.actionPerformed(WebAppToolbar.java:368)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: XML parsing error: com.sun.xml.rpc.sp.ParseException:1: Document root element is missing
         at com.sun.xml.rpc.streaming.XMLReaderImpl.next(XMLReaderImpl.java:120)
         at com.sun.xml.rpc.streaming.XMLReaderBase.nextContent(XMLReaderBase.java:23)
         at com.sun.xml.rpc.streaming.XMLReaderBase.nextElementContent(XMLReaderBase.java:41)
         at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:123)
         ... 34 more

  • Know Exceptions thrown in Java Finalizer thread...

    Hello,
    I have one question regarding java finalizer thread.
    How can i know about exceptions thrown by finalize method which has been called from the finalizer thread of JVM?.
    Any help would be appreciated?
    Thanks and Regards

    vinodpatel2006 wrote:
    Hello,
    Thanks for reply...
    But why i can't? There must be some mechanisum using i can know thrown exception.No
    >
    Because, in my application, i am writing finalize methods for each and every object to null out the member variable. I want to make sure that each of those methods work perfactly. I mean, does any of them throws exception OR not.What? Why are you doing that? That sounds pretty stupid. The GC will take care of those objects.
    Kaj

  • Additional uncaught exception thrown while handling exception.

    Hello all! I am *trying* to surf around the internet and do a little online shopping. I keep getting this error though and it is really bugging me/ruining my night. I am about ready to through my computer at a wall.
    Here is the error:
    Additional uncaught exception thrown while handling exception.
    Here is the full error as it appears on my screen:
    Additional uncaught exception thrown while handling exception.
    Original
    RedisException: Redis server went away in Redis->setOption() (line 23 of /home/www/usa.hunter-boot.com/htdocs/drupalroot/sites/all/modules/contrib/redis /lib/Redis/Client/PhpRedis.php).
    Additional
    RedisException: Redis server went away in Redis->setOption() (line 23 of /home/www/usa.hunter-boot.com/htdocs/drupalroot/sites/all/modules/contrib/redis /lib/Redis/Client/PhpRedis.php).
    It is REALLY bugging me. I don't know that much about computers other then the basics. I only use mine to write papers and go on the internet so if someone is nice enough to try and help me fix this issue then please don't use fancy tech lingo (dumb it down for me). Thank you!

    That's a problem on the web server, not on your computer.

  • Possible to determine exception thrown in a finally block?

    I believe the answer to this is 'no', but I thought I would ask just to confirm.
    If an exception is thrown in a try block, is there a way in the finally block to determine what exception was thrown? I tried using Throwable#fillinStackTrace and Thread#getStackTrace and did not get anywhere. I did see other methods like Thread#getAllStackTraces and perhaps going up to a parent ThreadGroup and inspecting other child Thread instances, but at least in my debugger, I did not see anything useful.
    The basic idea I am trying to achieve is to detect if an exception is thrown in the try, if yes, chain any exception thrown in the finally block to the original exception. I know I can do this on a case-by-case basis by storing the exception caught and then manually chaining it in the finally block. I was looking for something more generic/applicable to all finally blocks.
    Thanks.
    - Saish

    Thanks JSchell, have done that many times in the past.
    I was looking for a more generic (not generics) solution to the problem. So that an error handler could be written to automatically chain exceptions thrown in the finally clause (granted, one still needs to invoke the error handler). My hope was the stack in the finally clause would look different if an exception was thrown in the try block versus none at all.
    - Saish

  • How to handle exceptions in a Service

    Hi,
    I'm trying to get the new Service (background thread) stuff working and am close but I have a problem with handling exceptions that are thrown in my Task. Below is my code, does anyone know if I am doing something wrong, or is this just a flaw in the system at the moment:
    Here is my service:
    public class TestService extends Service<String>
        protected Task<String> createTask()
            return new Task<String>()
                protected String call() throws Exception
                   System.out.println("About to throw exception from inside task");
                   throw new Exception("Test failure");
    }Here is my code using this service:
    public void doTest()
        final TestService test = new TestService();
        test.stateProperty().addListener(new ChangeListener<Worker.State>()
            public void changed(ObservableValue<? extends Worker.State> source, Worker.State oldValue, Worker.State newValue)
                System.out.println("State changed from " + oldValue + " to " + newValue);
        test.start();
    }When the task throws its exception I was hoping to get a state change to FAILED but the callback is never triggered. I've tried listening for invalidation of the state and also tried listening to all the other properties on Service (running, progress, exception, etc). There doesn't seem to be any feedback after the exception has been thrown.
    Am I using this wrong, or is it a bug?
    Cheers for you help,
    zonski

    Hi,
    This was working in the build #32. I updated the JavaFX to build #36 and it stopped working.
    I checked in the latest build #37 as well which was released last week and this doesn't work here as well.
    If the task is succeeding the state is getting changed to SUCCEEDED but in case of an exception there is no change in the state
    Edited by: user12995677 on Aug 3, 2011 2:07 AM

  • Handling exceptions from Future/FutureTask.get()  : a question

    Hello.
    While trying to understand the way (possible) exceptions from Future/FutureTask.get() method can be handled, I found the following example on how this could be done:
    [http://www.javaconcurrencyinpractice.com/listings.html]
    * StaticUtilities
    * @author Brian Goetz and Tim Peierls
    public class LaunderThrowable {
         * Coerce an unchecked Throwable to a RuntimeException
         * <p/>
         * If the Throwable is an Error, throw it; if it is a
         * RuntimeException return it, otherwise throw IllegalStateException
        public static RuntimeException launderThrowable(Throwable t) {
            if (t instanceof RuntimeException)
                return (RuntimeException) t;                // Line #1
            else if (t instanceof Error)
                throw (Error) t;                                    // Line #2
            else
                throw new IllegalStateException("Not unchecked", t);// Line #3
    }And here is an example on how this handler is supposed to be used:
    * Preloader
    * Using FutureTask to preload data that is needed later
    * @author Brian Goetz and Tim Peierls
    public class Preloader
        ProductInfo loadProductInfo() throws DataLoadException {
            return null;
        private final FutureTask<ProductInfo> future =
            new FutureTask<ProductInfo>(new Callable<ProductInfo>() {
                public ProductInfo call() throws DataLoadException {
                    return loadProductInfo();
        private final Thread thread = new Thread(future);
        public void start() { thread.start(); }
        public ProductInfo get()
        throws DataLoadException, InterruptedException
            try {
                return future.get();
            } catch (ExecutionException e) {
                Throwable cause = e.getCause();
                if (cause instanceof DataLoadException)
                    throw (DataLoadException) cause;
                else
                    throw LaunderThrowable.launderThrowable(cause);
        interface ProductInfo {  }
    class DataLoadException extends Exception { }Everything is clear in general, except for one thing:
    Why is the LaunderThrowable.launderThrowable() method re-throws Error and IllegalStateException (Line #2 and #3 above) and just returns RuntimeException (Line #1)? Especially taking into consideration that whatever is returned from launderThrowable() is re-thrown in any case...
    Any ideas?
    Thanks.

    ...Why is the LaunderThrowable.launderThrowable() method re-throws Error and IllegalStateException (Line #2 and #3 above) and just returns RuntimeException (Line #1)?this is explained in the end of paragraph [5.5.2. FutureTask|http://www.javaconcurrencyinpractice.com/]:
    +"...When get throws an ExecutionException in Preloader, the cause will fall into one of three categories: a checked exception thrown by the Callable, a RuntimeException, or an Error. We must handle each of these cases separately, but we will use the launderThrowable utility method in Listing 5.13 to encapsulate some of the messier exception-handling logic. Before calling launderThrowable, Preloader tests for the known checked exceptions and rethrows them. That leaves only unchecked exceptions, which Preloader handles by calling launderThrowable and throwing the result. If the Throwable passed to launderThrowable is an Error, launderThrowable rethrows it directly; if it is not a RuntimeException, it throws an IllegalStateException to indicate a logic error. That leaves only RuntimeException, which launderThrowable returns to its caller, and which the caller generally rethrows..."+
    ...Especially taking into consideration that whatever is returned from launderThrowable() is re-thrown in any case...As far as I understand, assumption about re-throwing in any case is not quite correct. launderThrowable is intended to be a general utility, #) so it leaves a way for client to handle the returned value in a way different from re-throwing.
    #) intended to be a general utility -- launderThrowable is used not only in Preloader, but in [other listings|http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fwww.javaconcurrencyinpractice.com%2Flistings+launderThrowable] as well

  • Uncaught exceptions thrown in overridden ThreadGroup.uncaughtException

    Hi,
    To process uncaught exceptions in threads I spawn, I have created a ThreadGroup and overridden the uncaughtException method. This works flawlessly, but it brought up the following question:
    What happens to an exception that is thrown in an overridden uncaughtException method that is not caught?
    I assumed that an uncaught exception in an uncaughtException method would call the uncaughtException method in the parent thread group, but this does not seem to be the case. The uncaught exception just seems to disappear.
    Can somebody please confirm my finding that an uncaught exception thrown there just disappears and does not get handled anywhere else? Can somebody point me to the right sections of the Java Language Specs or the JVM Specs that deal with this issue?
    Below is a test program that I wrote to investigate. It throws an exception in an "outer thread", part of an "outer group" thread group; an exception in an "inner thread", part of an "inner group" thread group; and an exception in the uncaughtException method of the "inner group" thread group. I expected that the first two invoke the uncaughtException of the "outer group", while the last one invokes the method of the "inner group". Contrary to my expectations, the exception thrown in the uncaughtException method of the "inner group" does not seem to invoke anything.
    Thanks in advance.
    Yours,
    --Mathias
    public class ThrowInUncaughtExceptionHandler {
    public static void main(String[] args) {
    (new ThrowInUncaughtExceptionHandler()).run();
    public void run() {
    ThreadGroup outerGroup = new ThreadGroup("outer") {
    public void uncaughtException(Thread t, Throwable e) {
    System.out.println("in outerGroup.uncaughtException: "+e);
    final Thread outerThread = new Thread(outerGroup, new Runnable() {
    public void run() {
    System.out.println("in outerThread.run");
    System.out.println("\tthread group: "+Thread.currentThread().getThreadGroup());
    System.out.flush();
    ThreadGroup innerGroup = new ThreadGroup("inner") {
    public void uncaughtException(Thread t, Throwable e) {
    System.out.println("in innerGroup.uncaughtException: "+e);
    System.out.println("\tthrowing another exception...");
    throw new RuntimeException("thrown in innerGroup.uncaughtException");
    final Thread innerThread = new Thread(innerGroup, new Runnable() {
    public void run() {
    System.out.println("in innerThread.run");
    System.out.println("\tthread group: "+Thread.currentThread().getThreadGroup());
    System.out.flush();
    throw new RuntimeException("thrown in innerThread");
    innerThread.start();
    try { innerThread.join(); }
    catch(InterruptedException ioe) { /* ignore */ }
    throw new RuntimeException("thrown in outerThread");
    outerThread.start();
    }

    Hi tigerxx:
    Thank you for your reply. Unfortunately, your suggestion does not help. I had tried it already, even though according to the Java API Javadocs, this is not necessary anyway: If no thread group is specified as parent of a thread group, then the current thread's thread group is used. Since innerGroup is created by a thread in outerGroup, innerGroup's parent is outerGroup.
    Thanks again, though, for taking the time to read and reply.
    --Mathias                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Lots of exceptions thrown with JRockit JVM

    Hi,
    We are switching to test our codes based on JRockitRealTime 3.0.0, 1.6, linux 64 from Sun HotSpot.
    Our Coherence version is 3.3.1
    We notice a quite a few things are significant slower when compared to the results based on HotSpot.
    Turning on the Xverbose:exceptions=debug, we see lots of exceptions thrown, the following is just 1 example of many (with different kinds of stack trace too) related to Coherence API calls. And we believe they are the main cause to the slowdown. Has this kind of problem observed and reported to Coherence before? We did not see the exceptions from running HotSpot JVM, and looks like there is no need/way to turn on the exception traces from HotSpot HVM so we assume there were no exceptions thrown when we ran our applications based on HotSpot JVM.
    Regards,
    Jasper
    DEBUGexcepti00180 java/lang/NoSuchMethodException: java.lang.String.clone()^M
    at jrockit/vm/Reflect.fillInStackTrace0(Ljava/lang/Throwable;)V(Native Method)^M
    at java/lang/Throwable.fillInStackTrace()Ljava/lang/Throwable;(Native Method)^M
    at java/lang/Throwable.<init>(Throwable.java:196)^M
    at java/lang/Exception.<init>(Exception.java:41)^M
    at java/lang/NoSuchMethodException.<init>(NoSuchMethodException.java:32)^M
    at java/lang/Class.getMethod(Class.java:1605)^M
    at com/tangosol/run/xml/PropertyAdapter.<init>(PropertyAdapter.java:152)^M
    at com/tangosol/run/xml/SimpleAdapter.<init>(SimpleAdapter.java:59)^M
    at com/tangosol/run/xml/SimpleAdapter$StringAdapter.<init>(SimpleAdapter.java:1415)^M
    at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)^M
    at jrockit/vm/Reflect.invokeMethod(Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Native Method)^M
    at sun/reflect/NativeConstructorAccessorImpl.newInstance0(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)Ljava/lang/Object;(Native Method)^M
    at sun/reflect/NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)^M
    at sun/reflect/DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)^M
    at java/lang/reflect/Constructor.newInstance(Constructor.java:513)^M
    at com/tangosol/run/xml/XmlBean$BeanInfo.makeAdapter(XmlBean.java:1141)^M
    at com/tangosol/run/xml/XmlBean$BeanInfo.<init>(XmlBean.java:966)^M
    at com/tangosol/run/xml/XmlBean.initBeanInfo(XmlBean.java:874)^M
    at com/tangosol/run/xml/XmlBean.findBeanInfo(XmlBean.java:814)^M
    at com/tangosol/run/xml/XmlBean.getBeanInfo(XmlBean.java:362)^M
    at com/tangosol/util/ExternalizableHelper.writeXmlBean(ExternalizableHelper.java:2009)^M
    at com/tangosol/util/ExternalizableHelper.internalWriteObject(ExternalizableHelper.java:2505)^M
    at com/tangosol/util/ExternalizableHelper.toBinary(ExternalizableHelper.java:169)^M
    at com/tangosol/coherence/component/util/daemon/queueProcessor/service/DistributedCache$ConverterKeyToBinary.convert(DistributedCache.CDB:30)^M
    at com/tangosol/util/ConverterCollections$ConverterMap.put(ConverterCollections.java:1317)^M
    at com/tangosol/coherence/component/util/daemon/queueProcessor/service/DistributedCache$ViewMap.put(DistributedCache.CDB:1)^M
    at com/tangosol/coherence/component/util/SafeNamedCache.put(SafeNamedCache.CDB:1)^M
    at com/oracle/ngc/prototype/platform/CacheHelper.createObject(CacheHelper.java:808)^M
    at com/oracle/ngc/prototype/object/Account.BulkCreate(Account.java:186)^M at com/oracle/ngc/prototype/loader/PopulateSubscriptionCache$LoadDaemon.run(PopulateSubscriptionCache.java:379)^M
    at com/tangosol/util/Daemon$DaemonWorker.run(Daemon.java:519)^M
    at java/lang/Thread.run(Thread.java:619)^M
    at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)^M
    --- End of stack trace^M                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hi Jasper,
    First, I'd like to underscore that what you see are exceptions that are expected and handled gracefully by the standard Java serialization or Coherence classes.
    The reason you don't see those exceptions with Sun's JVM is that it does not have an option (at least to my knowledge) to show them. This is a very nice debugging feature of JRockit that allows you to see what is going on (and always has been!) under the hood.
    The example you gave is a part of the XmlBean introspection logic checking for a public "clone" method. This code runs once per a class initialization as a part of the static initializer and, as a result, does not impact an application performance. However, if you see exceptions that are occurring constantly, it definitely should be of concern.
    Regards,
    Gene

Maybe you are looking for

  • Error While Deploying ADF BC JSF Application on Oracle WebLogic Server 10.3

    Hi All, I am Deploying ADF BC JSF Application on Oracle WebLogic Server 10.3 My JDeveloper Version is - JDeveloper10.1.3.0.4 I followed Following Links for Deployment http://download.oracle.com/otn_hosted_doc/jdeveloper/11/demos/wls/wls.html http://b

  • Tree View Node Element Resize

    Hello, Is there any way to resize Tree View Node Element programatically. In .fr file the height of the tree view node element is set to 90. On a button click I want to resize the element height to 18. I have tried using IControlView->SetFrame(TmpRec

  • Anyone Created a Widget Yet? Thoughts?

    The next project I want to tackle is to learn how to create a Captivate widget. I took a look at the stub code for them and it seemed a little confusing, and the documentation doesn't say much. Has anyone successfully created an AS3 widget yet? I con

  • Error Code 2 on updating template links

    When I attempt to update the links to my templates I receive an error message: Error accessing file "...\Templates\PageTemplate.dwt", file not found (error code 2). The error comes up three times as some 22 pages are being updated. I imagine that whe

  • Error while trying to Create Recovery Disks - Lenovo 300 N200

    Hi, when trying to make Recovery Disks the program starts to extract files but after a few minutes i get this error: "An Internal error has caused this process to fail" when running lenovo system update i got an error: "An error occurred while gather