Streaming throws Exception of IO interrupted

I use the Streaming code given at the following link

http://supportforums.BlackBerry.com/T5/Java-development/streaming-media-start-to-finish/Ta-p/488255

But when I stop the thread it shows lifted UncaughtException - InterruptedException... ConnectionClosed exception. How to handle?

I checked the application on the device and works very well. Don't know what problem about Simulator.

But his works well on the device.

Tags: BlackBerry Developers

Similar Questions

  • Throwing exceptions of h

    HIE

    I have a public method in my AM I want to expose as a client method to call from a managed bean.

    I have a method like signature

    public Long myMethod (String val);

    If I go to AM and click the Edit then I see this method on the left side of the shuttle to expose it.

    But as soon as I add bird Exception this method is no longer available.

    So why does this happen?

    Hello

    You throw exceptions?
    You may need to use local instead of Exception.

  • Throwing exceptions in PL/SQL

    Hi friends

    I have the following code:

    declare

    var1...
    var2...
    cursor c1

    Start

    Insert stmt;

    Update stmt;

    Update stmt;

    to r1 c1 loop
    end loop;

    end;

    Each month I will be having about 6 million lines in the process. In order to throw exceptions, I think of one of the following options:

    Option 1_
    declare

    var1...
    var2...
    var3 exception;
    var4 exception;
    VAR5 exception;

    cursor c1

    Start

    Insert stmt;

    Update stmt;
    IF SQL % NOTFOUND then
    var3;
    end if;


    Update stmt;

    IF SQL % NOTFOUND then
    var4;
    end if;


    to r1 c1 loop
    end loop;

    IF SQL % NOTFOUND then
    VAR5;
    end if;

    Exception
    When var3 then blah blah
    When var4 then blah blah
    When var5 then blah blah

    end;

    Option 2_

    declare

    var1...
    var2...

    cursor c1

    Start

    Insert stmt;

    Update stmt;

    Update stmt;


    to r1 c1 loop
    end loop;

    Exception
    While some other then blah blah
    end;

    In terms of performance, which is better? And is there a better option?

    Thank you...

    Ways to handle exceptions known or predictable management of exceptions.

    The use of OTHERS WHEN in most cases implies that you don't know what exceptions will occur and so it's a bad habit.

    It is always better to define known exceptions and capture those explicitly and manage them properly. Then, if any exception occurs, she really is and the exception and should cause the program to fail and certainly should not be ignored, because it was not intended.

  • InputStream in device throws exception SaxParser

    Hi all, I am working on OS 5.0.

    In my application, I have connected to the network using HttpConnection. I've added the necessary parameters to test the device. The connection sets up in the device, but it is throwing

    '& #x1f' SaxParser invalid character exception

    I don't know that that's the problem with InputStream, but not with the Httpconnection.

    a strange beviour, I've observed while debugging in the Simulator is... When I pass a URL with parameters make me same thing '& #x1f' bad character SaxParser exception, but if I pass the direct URL without setting the XML file is the analysis and works very well.

    any1 has faced previously this kind of problem? How to solve this problem?

    If the data from the server is compressed, then you will need to decompress before feeding it to the parser. If the data are encoded with gzip (uncompressed), try something like this:

    HttpConnectionFactory connFactory = new HttpConnectionFactory(_XMLUrl);connection = (HttpConnection)connFactory.getNextConnection();if (connection.getResponseCode() == HttpConnection.HTTP_OK) {    inputstream = new GZIPInputStream(connection.openInputStream());    parser.parse(new InputSource(inputstream));} else {    // error}
    

    If the server really uses zip compression, then you will need to use a ZlibInputStream. It is less likely, because the zip compression is oriented file, while gzip is aligned flow and more commonly used for responses from the server.

    A few other notes about your code:

    1. you don't need to create an InputStreamReader; the Analyzer can understand the encoding of the data of the (inflated) input stream itself.
    2. You must use connection.openInputStream () instead of connection.openDataInputStream (). Expect UTF-8 text, not Java data types, in the input stream.
    3. Definition of the Content-Type request property is not make sense unless you publish data to _XMLUrl (which, from your code, you do not).
    4. If the server powers up properly the response headers, you can check if the answer is gzip-ed using "gzip".equals (connection.getEncoding ()) after the call to connection.openInputStream (). " (My suggested code blindly guess gzip). Don't forget to check, however, that the process server is actually defining the header of the correct answer. many authors of server scripts don't know or are lazy about it. (If you control both sides, of course, you can safely be lazy.)
    5. In your second example in code, you should probably be defining the request text/xml HEADER_ACCEPT, instead of HEADER_ACCEPT_ENCODING property. Typical values for Accept-Encoding are 'gzip', 'compress' and 'identity', not ' text/xml '.
  • DeviceInfo.getDeviceName throws exceptions?

    Hello

    In my application I want to know what mobile, the application runs. Then I use the DeviceInfo functions.

    But DeviceInfo.getDeviceName () sometimes throws an exception!

    DeviceInfo.getDeviceId () a front line still works well.

    So far I can't tell when DeviceName works and when not... But it's the same application on the same mobile.

    Any idea?

    Here is the log:

    Unauthorized attempt to attach to this applicationnet_rim_cldc-9(4E68CC9F)
     Application
     getApplication
     0x336F
    net_rim_cldc-8(4E68CC9F)
     EventListenerManager
     add
     0x255C
    net_rim_cldc-9(4E68CC9F)
     MemoryCleanerManager
     addListener
     0x78C1
    net_rim_cldc-9(4E68CC9F)
     MemoryCleanerDaemon
     addWeakListener
     0x7625
    net_rim_cldc-6(4E68CC9F)
     ResourceBundleFamily$MyIntHashtable
     
     0xB223
    net_rim_cldc-6(4E68CC9F)
     ResourceBundleFamily
     
     0xB1B5
    net_rim_cldc-6(4E68CC9F)
     ResourceBundle
     getBundle
     0xAC43
    net_rim_cldc-6(4E68CC9F)
     ResourceBundle
     getBundle
     0xABD4
    net_rim_cldc-11(4E68CC9F)
     DeviceInfo
     getDeviceName
     0x16B1
    

    interpreting the stacktrace that looks like a bug to me, report it in jira.

  • GuestScript feeder throws exception socket

    Hi all

    GuestScript feeder throws the following exception.

    [08:01:53.722 2016-06-30] [W] unknown error. The error happened the following output handler:; nested exception is:

    java.net.SocketTimeoutException: read timed out (Workflow: Get deals with the task (item1) invited / Scriptable #8)

    It is impossible to read the client process. Any suggestions?

    Thank you

    Well... There was 1 cpu which has been 100%...added another CPU, which solved the problem

  • Closing popup workflow throws exceptions of serialization is not the managed beans.

    JDev 11.1.1.6

    When a popup that is launched from a work stream is closed, this exception is thrown for a lot of managed beans I set:

    [< SessionBasedScopeMap > < writeScopeMap > ADFc: scope objects serialization failed (no serializable object), scope='viewScope[/WEB-INF/get-value-rules-task-flow.xml#get-value-rules-task-flow@GetValueRules]', objectKey = 'GetValueRuleBean', 'com.mtg.fwd.view.beans.GetValueRuleBean' = objectType.

    < SessionBasedScopeMap > < writeScopeMap >

    java.io.NotSerializableException: com.mtg.fwd.view.beans.GetValueRuleBean

    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)

    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)

    at oracle.adfinternal.controller.util.Utils.verifySerializable(Utils.java:341)

    at oracle.adfinternal.controller.state.SessionBasedScopeMap.writeScopeMap(SessionBasedScopeMap.java:122)

    at oracle.adfinternal.controller.state.ViewScope.writeObject(ViewScope.java:90)

    ...

    Related Posts: ADFC-0619: check failure of popup by taskflow application approval

    I tried setting the scope of control of data in the workflow for the popup shared and isolated, the behavior is the same.  I thought that the scope must be insulated for the tf of the pop-up window.  The data-control-scope on the calling workflow shared.

    No idea why?

    Thanks - Rudy

    I don't know if you can disable registration points. However, I'd go for the second option to bind components to ask the beans reach max.

    This way you don't have problems later and it is best practice not to tie UI components to the higher bean then ask. You can adopt the UIManager (https://blogs.oracle.com/groundside/entry/the_uimanager_pattern) model.

    Or use ComponentReference as shown here https://blogs.oracle.com/ATEAM_WEBCENTER/entry/rules_and_best_practices_for

    Timo

  • EXECUTE IMMEDIATE throws exception NO_DATA_FOUND when it should not

    Hi all

    I wrote an anonymous PL/SQL block that, on paper, should be OK, but one of its commands EXECUTE IMMEDIATE is runnning slowing prematurely and throw an exception NO_DATA_FOUND, when it should not because I know that there is data in the table.

    Here is the line that I suspect is out of steam after 8 attempts:


    ---
    immediately execute "INSERT INTO ple101.circular35 (ID, SLAVETABLEID, SLAVEITEMID, MASTERTABLEID, MASTERITEMID, PRO) (SELECT * FROM SLAVETASKS where mastertableid =' |)" subTableID | "and masteritemid =' |" subitemID |' and subtableid =' | mastTableID | "and SLAVEITEMID =' |" mastItemId |') ' ;
    ------

    It is supposed to search the entire SLAVETASKS table for documents that match the WHERE clause, but gives up after 8 cycles.
    Table SLAVETASKS got 10228 records.

    The above statement (and the whole of the PLSQL block) is good in that it gets records if they are wthin the first 8 records in the SLAVETASKS table, but like I said after 8 records, to throw an exception NO_DATA_FOUND.

    Published by: user10390960 on April 28, 2012 03:21

    Published by: user10390960 on April 28, 2012 03:22

    Published by: user10390960 on April 28, 2012 03:23

    Published by: user10390960 on April 28, 2012 05:08

    Hi Goofy,

    The above script is for PLSQL and if you want to display the data in circular 35 follow like that

    # Save the code below in the sqlscript for example. circular_process_display. SQL and run as

    sqlplus /@ @circular_process_display.sql

    -- CREATE TABLE circular 35
    CREATE TABLE circular35
    ....
    ..
    /
    
    -- Execute PLSQL Block as given in my earlier post
    DECLARE
    ...
    BEGIN
    ...
    EXCEPTION
    ...
    END;
    /
    
    -- Run SQL to display output on screen.
    SET SERVEROUTPUT ON SIZE 100000 FEEDBACK ON LINESIZE 200;
    
    SELECT *
    FROM circular35
    /
    
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    
  • Plugins and Java methods that throw exceptions

    I am trying to determine how to deal with my plugin with expose an object method java which could raise and exception.  For the example below, I've added a mapping object for the exception class and the getErrno and getReason methods

    I have in my java script

    try {}

    Method.Invoke ();

    }

    {} catch (e)

    errno = e.getErrno ();

    }

    the e I catch is going to be my java exception object, or is it something else?

    When I run it (whose value invoke throws the exception) I get "TypeError: function getErrno is not found.

    Basically, all exceptions are string message, not the exception objects. What you can do is to serialize the error and the message that the Exception string is the excpeptions object.

  • Throwing exception of validation is not shown in the jspx page

    Hello

    I have a page with af:table that uses a display object. This view object uses an entity object. In the method of the EntityImpl of my entity object class I throw ValidationException.I debug the application and I saw that it is throwing the exception. But it is not displayed on the page. What could be wrong here?

    try {}
    setAttributeInternal (BANKTYPE, value);
    }
    {} catch (TooManyObjectsException e)
    e.printStackTrace ();
    throw new ValidationException ("you try to add the existing record");

    }
    Is to have my page jspx * < af:messages id = "m1" / > *.
    Jspx page should any configuration to show the exception thrown in a popup?

    Kind regards
    Priya.

    You can try the same thing with the local...

  • Help with «throw exception error native function»

    Can someone help me find a soultion error with dreamweaver mx2004. I use the software successfully for several years and everything has started to develop a new site with .htm files.

    When connecting to a css file, I get the following error when I swith from design mode, the system displays the error code, then crashes, but only on a single page, another page using the same css file works fine! I'm totally baffled...

    The error is:

    When executing command DW_DesignView in toolbars.xml, the following JavaScript error occurred: exception throw in native function


    I hope that its not me, but it just may be, please help.

    If this is the case with a single file, there is something wrong with this file. Or to be more precise, there is something in this file that gives indigestion to Dreamweaver. You must check the file with the validator W3C CSS (http://jigsaw.w3.org/css-validator/).

    There is a known issue with Dreamweaver CS3, for which a file that is exactly 8 KB or multiples of it causes Dreamweaver to crash. I've never heard of him with Dreamweaver MX 2004, but if the file is valid, try to open it in a text editor and add something, as a CSS comment. This increases the size of the file and get rid of the problem.

    If these ideas do not resolve the problem, I'm afraid, I'm out of ideas. Adobe will not help you because your version of Dreamweaver is no longer supported.

  • setARRAYatName throws exception-&gt; discussion of named parameter by default/now

    Hi, I'm pretty new with the help of JDBC and
    I have a question about using the following method of an OracleCallableStatement setARRAYatName, so I don't have to fill in default values (I guess this is corect?)
    the signing of sqlmethod I call

    PROCEDURE create_timecard_bb)
    p_start_time IN hxc_time_building_blocks.start_time%TYPE,
    p_stop_time IN hxc_time_building_blocks.stop_time%TYPE,
    -p_approval_status IN hxc_time_building_blocks.approval_status%TYPE,
    p_resource_id IN hxc_time_building_blocks.resource_id%TYPE,
    -default to anyone because there is no other type of resource at the present time.
    p_resource_type IN hxc_time_building_blocks.resource_type%TYPE
    DEFAULT hxc_timecard.c_person_resource
    -We can't use approval_style_name because it is not unique.
    p_approval_style_id IN hxc_time_building_blocks.approval_style_id%TYPE
    DEFAULT NULL,
    p_comment_text IN hxc_time_building_blocks.comment_text%TYPE
    DEFAULT NULL,
    p_app_blocks hxc_block_table_type IN OUT NOCOPY,
    p_time_building_block_id OUT NOCOPY hxc_time_building_blocks.time_building_block_id%TYPE
    );

    The following code works.

    String stmtString = "start HXC_TIMESTORE_DEPOSIT.create_timecard_bb(?,?,?,?,?,?,?,?); end; « ;
    cstmt = conn.prepareCall (stmtString) (OracleCallableStatement);
    System.out.println (cstmt.getParameterMetaData (). GetParameterCount());
    / * FOLLOWIG CODE WORKS BUT IT IS WITH INDEX
    */
    GregorianCalendar calendar = new GregorianCalendar();
    Calendar.Set (2009, Calendar.JUNE, 1);
    cstmt.setDate (1, java.sql.Date (calendar.getTime () .getTime ())) of new;
    Calendar.Set (2009, Calendar.JUNE, 7);
    cstmt.setDate (2, new java.sql.Date (calendar.getTime () .getTime ()));
    cstmt.setInt (3, 4760);
    cstmt.setString(4,"PERSON"); default value
    cstmt.setInt (5,267); set, a value can also be null by default
    cstmt.setNull VARCHAR (6); default value is normally zero
    cstmt.setARRAY (table 7);
    cstmt.registerOutParameter(8,INTEGER);
    cstmt.registerOutParameter (TABLE 7, "HXC_BLOCK_TABLE_TYPE");

    ... during the extraction of results

    the following does NOT work code and throws an exception that er is een parameternaam geprobeerd in you stellen die niet voorkomt in SQL code of. : p_app_blocks (translated: you have tried to assign a parametername which does not excist in sql code)

    String stmtString = "start HXC_TIMESTORE_DEPOSIT.create_timecard_bb(?,?,?,?,?,?,?,?); end; « ;
    cstmt = conn.prepareCall (stmtString) (OracleCallableStatement);
    System.out.println (cstmt.getParameterMetaData (). GetParameterCount());
    / * the following code does not work, for arrayatname, difference which is parametesr with the default are not assigned by name, otherwise they are now affected by his name,

    GregorianCalendar calendar = new GregorianCalendar();
    Calendar.Set (2009, Calendar.JUNE, 1);
    cstmt.setDate ("p_start_time", new java.sql.Date (calendar.getTime () .getTime ()));
    Calendar.Set (2009, Calendar.JUNE, 7);
    cstmt.setDate ("p_stop_time", new java.sql.Date (calendar.getTime () .getTime ()));
    cstmt.setInt ("p_resource_id", 4760);
    cstmt.setARRAYAtName ("p_app_blocks", array); <-DURATION says this line throws an exception
    cstmt.registerOutParameter ("p_time_building_block_id", INTEGER);
    cstmt.registerOutParameter ("p_app_blocks", ARRAY "HXC_BLOCK_TABLE_TYPE");

    */

    So I make a false assumption that if you assign one with the name of those you do not assign a default value?
    Or something is wrong with setARRAYAtName?

    PS the trace (in Dutch)

    Exception in thread "main" java.sql.SQLException: Er is een parameternaam geprobeerd in you stellen die niet voorkomt in SQL code of. :
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.OraclePreparedStatement.setARRAYAtName(OraclePreparedStatement.java:6065)
    at be.interaccess.timecard.TimecardDaoImpl._doCreateTimecard(TimecardDaoImpl.java:268)
    at be.interaccess.timecard.TimecardDaoImpl.main(TimecardDaoImpl.java:210)

    Published by: user2561357 on May 27, 2009 13:48

    Looks like it says here

    http://download.Oracle.com/docs/CD/B28359_01/Java.111/b31224/oraint.htm#CHDBGJFG

    (b) bind parameters by name

    What is the reason behind this requirement? Any reason why you cannot use solution 1?

  • XmlType extractValue with namespace throw exception "invalid token".

    Hello. I have XML stored as XMLTYPE and with content, such as:

    + < notificationEF > +.
    + < oos:id > 2812301 < / oos:id > +.

    When I try to run

    extractValue (XML_CLOB, ' notificationEF / oos:id ')

    I catch exception "LPX-00601: token not valid in:" notificationEF / oos:id' "."

    What's wrong? And how do I fix it?

    Thank you.

    Here's one way:

    SQL> var xmldoc varchar2(4000)
    SQL>
    SQL> begin
      2   :xmldoc :=
      3  '
      4  
      7   
      8    4711561
      9    4711561
     10   
     11  ';
     12  end;
     13  /
    
    PL/SQL procedure successfully completed
    
    SQL> SELECT x.id
      2  FROM XMLTable(
      3         XMLNamespaces(
      4           default 'http://example.ru/oos/export/1'
      5         , 'http://example.ru/oos/types/1' as "oos"
      6         )
      7       , '/export/contract/oos:id'
      8         passing xmltype(:xmldoc)
      9         columns id number path '.'
     10       ) x
     11  ;
    
            ID
    ----------
       4711561
       4711561
     
    
  • JavaFX binding throws illegal state Exception: not on the thread of Application FX

    Hi all

    I am updating a label of a task using bindings.

    However, when I 'Bind' the label text property with a property of the task, Illegal state exception string is thrown. Saying: this is not not on the thread of JavaFX.

    The Exception occurs whenever I try to set the property of the task of the Interior string.

    Please do not suggest to use the platform. RunLater(). I want to do this through links as the values I am trying to display in the label (later on) could change too frequently, and I don't want to flood the queue of the thread of the user interface with executable objects.

    Please let me know what I'm doing wrong and what I need to change to make it work properly with links. (I'm new to links and concurrency JavaFx API)

    Here is my Code.

    public class MyTask extends Task<String>{
    
        MyTask(){
           System.out.println("Task Constructor on Thread "+Thread.currentThread().getName());
    
    
        }
        private StringProperty myStringProperty = new SimpleStringProperty(){
            {
                System.out.println("Creating stringProperty on Thread "+Thread.currentThread().getName());
            }
        };
        private final void setFileString(String value) {
            System.out.println("Setting On Thread"+Thread.currentThread().getName());
            myStringProperty.set(value); }
        public final String getFileString() { return myStringProperty.get(); }
        public final StringProperty fileStringProperty() {
            System.out.println("Fetching property On Thread"+Thread.currentThread().getName());
            return myStringProperty; }
        
        @Override
        public String call() throws Exception{
            System.out.println("Task Called on thread "+Thread.currentThread().getName());
    
    
           for(int counter=0;counter<100;counter++){
               try{
               setFileString(""+counter);
               }catch(Exception e){
                   e.printStackTrace();
               }
               Thread.sleep(100);
               System.out.println("Counter "+counter);
           }
           return "COMPLETED";
        }
    }
    
    
    public class MyService extends Service<String> {
    
    
        MyTask myTask;
    
        public MyService(){
            System.out.println("Service Constructor on Thread "+Thread.currentThread().getName());
            myTask=new MyTask();
        }
    
        @Override
        public Task createTask(){
            System.out.println("Creating task on Thread "+Thread.currentThread().getName());
            return myTask;
        }
    
    }
    
    
    public class ServiceAndTaskExperiment extends Application {
        @Override
        public void start(Stage stage) throws Exception {
            Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
            Scene scene = new Scene(root);
            stage.setScene(scene);
            stage.show();
        }
        public static void main(String[] args) {
            launch(args);
        }
    }
    
    
    public class SampleController implements Initializable {
        @FXML
        private Label label;
    
        @FXML
        private void handleButtonAction(ActionEvent event) {
            System.out.println("You clicked me!");
            myTestService.start(); //This will throw out exceptions when the button is clicked again, it does not matter
        }
    
        MyService myTestService=new MyService();
        @Override
        public void initialize(URL url, ResourceBundle rb) {
            label.setText("Hello World!");
            //adding the below Line causes the exception
            label.textProperty().bind(myTestService.myTask.fileStringProperty()); //removing this line removes the exception, ofcourse the label wont update.
        } 
    }
    //sample.fxml
    <?xml version="1.0" encoding="UTF-8"?>
    <?import java.lang.*?>
    <?import java.util.*?>
    <?import javafx.scene.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    
    
    <AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="serviceandtaskexperiment.SampleController">
        <children>
            <Button layoutX="126" layoutY="90" text="Click Me!" onAction="#handleButtonAction" fx:id="button" />
            <Label layoutX="126" layoutY="120" minHeight="16" minWidth="69" fx:id="label" />
        </children>
    </AnchorPane>
    
    
    
    

    And it is the output with links on:

    Output: when the link is activated label.textProperty () .bind (myTestService.myTask.fileStringProperty ());

    Service on JavaFX Application Thread constructor

    Creating string on thread JavaFX Application Thread

    Task, Builder on JavaFX Application Thread

    Get the property on request ThreadJavaFX wire

    You clicked me!

    Creating a task on a thread Thread Application JavaFX

    Task called threadThread-4

    Setting on ThreadThread-4

    java.lang.IllegalStateException: not on the application thread FX; currentThread = Thread-4

    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:237)

    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:398)

    to javafx.scene.Parent$ 1.onProposedChange(Parent.java:245)

    at com.sun.javafx.collections.VetoableObservableList.setAll(VetoableObservableList.java:90)

    at com.sun.javafx.collections.ObservableListWrapper.setAll(ObservableListWrapper.java:314)

    at com.sun.javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:602)

    at com.sun.javafx.scene.control.skin.LabeledSkinBase.handleControlPropertyChanged(LabeledSkinBase.java:209)

    to com.sun.javafx.scene.control.skin.SkinBase$ 3.changed(SkinBase.java:282)

    at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:107)

    to com.sun.javafx.binding.ExpressionHelper$ SingleChange.fireValueChangedEvent (ExpressionHelper.java:196)

    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)

    at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:121)

    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:128)

    in javafx.beans.property.StringPropertyBase.access$ 100 (StringPropertyBase.java:67)

    to javafx.beans.property.StringPropertyBase$ Listener.invalidated (StringPropertyBase.java:236)

    to com.sun.javafx.binding.ExpressionHelper$ SingleInvalidation.fireValueChangedEvent (ExpressionHelper.java:155)

    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)

    at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:121)

    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:128)

    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:161)

    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:67)

    to serviceandtaskexperiment. MyTask.setFileString (MyTask.java:24)

    to serviceandtaskexperiment. MyTask.call (MyTask.java:36)

    to serviceandtaskexperiment. MyTask.call (MyTask.java:11)

    to javafx.concurrent.Task$ TaskCallable.call (Task.java:1259)

    at java.util.concurrent.FutureTask.run(FutureTask.java:262)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    to java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:615)

    at java.lang.Thread.run(Thread.java:724)

    Output with links removed: (label will not be updated)

    Service on JavaFX Application Thread constructor

    Creating string on thread JavaFX Application Thread

    Task, Builder on JavaFX Application Thread

    You clicked me!

    Creating a task on a thread Thread Application JavaFX

    Task called threadThread-4

    Setting on ThreadThread-4

    Counter 0

    Setting on ThreadThread-4

    1 meter

    Setting on ThreadThread-4

    2 meter

    Setting on ThreadThread-4

    If myStringProperty is bound to the textProperty of etiquette, you can only change it on the Thread of the JavaFX Application. The reason is that change its value will result in a change of the label, and changes of live parts of the graphic scene cannot be performed on the Thread of the JavaFX Application.

    Task and Service classes expose a messageProperty you could use here. The Task class has a updateMessage (...) method that changes the value of the message on the Thread of the JavaFX Application property. It also merges calls in order to prevent the flooding of this thread. If you could do the following in your MyTask.call () method:

    updateMessage(""+counter);
    

    and then in your controller just do

    label.textProperty().bind(myTestService.messageProperty());
    

    If you don't want to use the messageProperty for some reason any (for example you are already using it for something else, or you want to make something similar to a property that is not a string), you must merge the updates yourself. What follows is based on the source code of the task:

    public class MyTask extends Task {
    
         // add in the following:
        private final AtomicReference fileString = new AtomicReference<>();
    
        private void updateFileString(String text) {
            if (Platform.isFxApplicationThread()) {
                setFileString(text);
            } else {
                if (fileString.getAndSet(text) == null) {
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            final String text = fileString.getAndSet(null);
                            MyTask.this.setFileString(text);
                        }
                    });
                }
            }
        }
    
       // Now just call updateFileString(...) from your call() method
    }
    
  • Persist does not throw an exception in a JUnit test

    I implement a JUnit test by using Toplink JPA provider. I must be missing something because I try to keep twice the same entity and no exception is thrown. PersistenceException, nor any other type of exception. The code can not be easier:


    @Test
    Public Sub testAddExistingTeam() throws Exception {}

    Team = new Team ("team2");

    try {}

    EntityManagerFactory emf =
    Persistence.createEntityManagerFactory ("Fisher");
    EntityManager em = emf.createEntityManager ();

    em.getTransaction () .begin ();

    EM. Persist (Team);
    EM. Persist (Team);

    em.getTransaction () .commit ();
    EM. Close();
    }
    catch (Exception e) {}
    e.printStackTrace ();
    }

    }

    Note the two em.persist (team).

    This code does not enter into the catch block or produce any kind of exception. On the other hand, I checked after the first
    EM. Persist (Team); the team is really successful.

    The relevant parts of the team following class definition:

    @Entity
    @Table (name = 'TEAM')
    Team/public class implements Serializable {}
    @Id
    @Column (name = "NAME")
    private String name;

    @ManyToOne
    @JoinColumn (name = "CLUB_NAME", referencedColumnName = "NAME")
    Club private;
    category private;
    private String email;

    @ManyToMany (mappedBy = "teams")
    list < competition > competition private;


    public Team (String name) {}
    myIdName = name;
    This.Club = null;
    This.competitions = new ArrayList < competition > ();
    }

    more than builders...getters/setters...and.
    }

    I'm really intrigued by this problem. Could someone help? I would be really grateful!


    Josepma

    This is expected behavior as persist is a no - op if called on one managed entity (other than to the waterfall on relationships with cascade. Persist), and the first call to persist makes the past in team managed entity.

    Try calling em.flush (); and em.clear (); between calls persist to get an exception.
    The first flush will ensure that the team is inserted into the database, while that clear it peel while the second call persist will attempt to insert the team. JPA providers should not throw the entityExistsException persist - it can be delayed until the transaction either emptied or committed, then you are likely to get a PersistenceException validation instead of EntityExistsException to persist.

    Best regards
    Chris

Maybe you are looking for