NativeProcess and IDataInput readObject()

I have seen references on various site regarding this issue but am still getting this issue pretty consistently so thought I would see if I could get some support from here.
Basically on reading a standard output from a NativeProcess I attempt to read the IDataInput using readObject and get #2030 End of file was encountered.  I can read as a String via readUTFBytes no problem.  So whats the process to manage this IDataInput as something other than a String i.e. Object, XML etc?
Bearing in mind that I have no control over the data type received from the NativeProcess?
Cheers,
Simon

Yes, it is separately. For another experimenting, I'm running multi-chatroom
on xSocket in Java, I tried to get NP launch the chat (client) also created
in Java, not passing any message/info back to NP but to xSocket server. I
was surprise the client would stop sending/working suddenly, no error
message on both sides. If I don't use NP, it work flawlessly and able to
handle large volume of data without lost or significant delay. I am
disappoint that NP is incapable for production use.
I tried adding "flush" before and after the text is display in Java code but
it doesn't solve. Someone may solve it but how many programs are available
in sourcecode?

Similar Messages

  • Fairly certain that FileStream.writeObject() and FileStream.readObject() do not function - at all -.

    I've struggled with this since Jan 9th, 2013 (if not longer) and the only conclusion I can come to is that this simply does not function.  No matter what I try and no matter what resource (and I'm finding precious few) I follow to try to implement this within Flash Builder 4.7, Flex SDK 4.6.0 (Build 23201), AIR SDK 3.5, I only succeed in creating a file (with the correct name) that is 123 bytes in size that reads back in as NULL;
    I've tried using ByteArray.writeObject()/readObject() as an intermediary with FileStream.writeBytes()/readBytes(), with no luck.
    I've tried instantiating an object, setting properties and then using that.  I've tried instantiating my correctly formed ValueObject (including the remoteClass alias metadata tag).
    I've tried using -verbatim- the example provided in the top most suggested 'Community Help' resource http://www.switchonthecode.com/tutorials/adobe-air-and-flex-saving-serialized-objects-to-f ile It is worth noting that this solitary example of the procedure/SDK-usage is dated to Flex SDK 3.0 and at least 04/04/2009 (first comment on the article).
    My frustrating hell (one version of many methods attempted) is detailed on StackOverflow (including -all- mxml, as, and trace output), but so far, no assistance has been forthcoming, alas.  This is a severely stripped down and simplified version of what had been a far more complex attempt:
    http://stackoverflow.com/questions/14366911/flex-air-actionscript-mobile-file-writeobject- readobject-always-generates-null-w
    An earlier post* detailing a far more complex attempt interation, with, alas, just as little help (guess this isn't a hot button topic) forthcoming:
    http://stackoverflow.com/questions/14259393/flex-actionscript3-filestream-writeobject-fail s-silently-in-ios-what-am-i-doin
    * I previously suspected that it was only failing from within iOS on an iPad, but the first example (the stripped down version) made it evident that it didn't work in the AIR mobile device simulator (iPad) in the Windows environment, and indeed, didn't work in a non-mobile project in the windows environment AIR launcher.
    I'm at a loss, upset, frustrated, in major trouble with my supervisor/deadlines, etc.
    I would very much appreciate any suggestions/help/confirmation/etc.
    Just to move ahead with development I've opted for a far less preferable solution of writing out both an XML file and a JPG file.  I very much do not like this and very much want to store encapsulated serialized objects locally in the same way I assume will work for storing remotely with AMFPHP (if the project ever gets to that point *sigh*).
    Again.  Would be so grateful for any help.

    I want to add to this post as I marked it as "The Answer" though it does not indeed contain the answer directly, for those who come looking for simliar solutions.
    harUI prompted me to realize that my metadata term needed to be capitalized (RemoteClass instead of remoteClass).  As the metadata tags may be user defined, the compiler throws no errors (or warnings *grumble*)
    package vo
        import flash.display.BitmapData;
       // [remoteClass(alias="PTotmImageVO")] incorrect
       [RemoteClass(alias="PTotmImageVO")]
        public class PTotmImageVO

  • Need Info NativeProcess and Flex Builder

    Hi Guys,
    I am currently using Flex builder 3.0 and wanted to develop a project with the new Air 2.0 features
    I have done following process for Air 2.0
    ·         Downloaded Flex 3.3 sdk.
    ·         Downloaded Air 2.0 sdk
    ·         Updated Air sdk of 3.3 to 2.0
    ·         Changed the namespace to 2.0
    ·         Added “supportedProfiles” tag to –app.xml file
    Now when I try to import NativeProcess I am unable to find in package flash.desktop , is there is need to update my Flex Builder, also if not what am I doing wrong please suggest.
    Thanks & Regards,
    Mahesh

    HI ,
    For importing class of native process ,
    Download sdk 3.4
    Download AIR2.0 SDK
    Now update air library of 3.4 with AIR 2.0 SDK - for that just copy of AIR2.0's sdk content and past this into SDK 3.4's content.
    Now your library is able to handle native process.
    Now you can import native process class.
    When u want to call native process at that time u need to add
    <supportedProfiles>extendedDesktop desktop</supportedProfiles>
    into your project app.xml
    Now you can use nativeProcess class of AIR 2.0

  • NativeProcess and cmd loop

    Hello,
    cmd loop doesn't work correctly
    file = file.resolvePath("C:\\Windows\\System32\\cmd.exe");
    nativeProcessStartupInfo.executable = file;
    process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
    process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onError);
    process.addEventListener(NativeProcessExitEvent.EXIT, exitHandler);
    process.start(nativeProcessStartupInfo);
    process.standardInput.writeUTFBytes('for /f "TOKENS=1" %%i in (\'"wmic Process where (Name="cmd.exe") GET processid | findstr [0-9]"\') do call :concat %%i' + "\n");
    process.standardInput.writeUTFBytes('goto :fin' + "\n");
    process.standardInput.writeUTFBytes(':concat' + "\n");
    process.standardInput.writeUTFBytes('set str=%str%,%1' + "\n");
    process.standardInput.writeUTFBytes('goto :eof' + "\n");
    process.standardInput.writeUTFBytes(':fin' + "\n");
    process.standardInput.writeUTFBytes('@echo pid%str%' + "\n");
    public function onOutputData(event:ProgressEvent):void
    var stdOut:IDataInput = process.standardOutput;
    var data:String = stdOut.readUTFBytes(process.standardOutput.bytesAvailable);
    are.appendText(data+"\n");
    the cmd echo returns "pid%str%,%1"
    Thanks

    HI,
    if your to internal table satisfy the bellow requirements
    To use this following should be true
    1)      Both tables should be sorted with the same key ( in the above case field1 and field2 )
    2)      The mapping between primary to secondary tables should be
    a.       one to many ( for one record in primary there are multiple records in secondary )
    b.      one to one (for one record in primary there is only one in secondary )
    Please note that other than the above 2 other 2 scenarios (many to many & many to one) will not work with the above logic and make sure you donu2019t use in such case.
    3)      The secondary table should not contain a record which does not map to the primary table ( this will not happen if the secondary is fetched using for all entries from primary )
    4)      Please make sure you do not delete any record from primary before using the logic which will make the point 3 false 
    5)      If you were to use a 'AND' in where statement of the inner loop you should use or in the inner loop if condition in the above logic. 
    then you can use the
    Loop AT i_primary into wa_primary.
    Loop AT i_secondary into wa_secondary from lv_index.
    If ( wa_primary-field1 NE wa_secondary-field1 ) or
    ( wa_primary-field2 NE wa_secondary-field2 ).
    Lv_index = sy-tabix.
    Endif.
    u201C your code comes here u201C
    Endloop.
    Endloop.
    which is very fast i have check it in most of the reports gave performance issues
    you can check the link for detail
    [http://nafran.blogspot.com/2009/09/when-and-where-we-can-use-parallel.html|http://nafran.blogspot.com/2009/09/when-and-where-we-can-use-parallel.html]
    [ http://nafran.blogspot.com/2009/05/best-way-to-code-nested-loops-sap.html|http://nafran.blogspot.com/2009/05/best-way-to-code-nested-loops-sap.html]

  • Socket, setSoTimeout and SocketTimeoutException

    I am experimenting with different Socket.setSoTimeout settings while reading the inputstream with BufferedReader.readLine. I have tried to provoke a SocketTimeoutException while reading a string from the Socket.inputStream.
    I have noticed that if a timeout happens after I have flushed some strings with a BufferedWriter.write, but before I have generated a string with EOL, the BufferedReader.readLine first generates a SocketTimeoutException, and then readLine-method returns the flushed strings even though none of them had a "\n", "\r" or "\r\n".
    Now, what I have not been able to do (or at least was not aware of), is to generate a Timeout before an entire string is read by the Socket.inputStream.
    1. Is it possible that if I write "this is a test\n" that a Timeout could produce (with repetitive BufferedReader.readLine) "this i" and "s a test"?
    2. What would happen if I was using ObjectOutputStream.writeObject and ObjectInputStream.readObject?
    I have looked at the source-code of BufferedReader, but I think I could spend several days to try to understand it. If anyone has any experience or ideas regarding question 1 or 2, feel free to share them.

    Moved topic to:
    http://forum.java.sun.com/thread.jspa?threadID=666967

  • NativeProcess extendedDesktop error

    I am using NativeProcess and am required to include <supportedProfiles>extendedDesktop</supportedProfiles> in the app descriptor.
    This works fine in the debugger but when I go to export a release build, I get the following error:
    'Error creating AIR file XXX-app.xml: eror 306: Descriptor must support one of the following profiles: desktop, mobileDevice, extendedMobileDevice, tv'
    If I use <supportedProfiles>extendedDesktop desktop</supportedProfiles>   as suggested here: http://forums.adobe.com/thread/699165
    ..then NativeProcess is no longer supported in the Export Release.

    Yes, but I thought I saw somewhere/sometime that an AIR installer could be created to support nativeProcess from ADT.
    I was hoping that was the case as we utilize an auto-updating feature for seamless updates  but  that requires an AIR installer.
    That sad, I cannot find that supposed solution so will chaulk it up to my imagination   and wishful thinking.
    I'll give you the nod though - thanks.

  • NativeProcess exitCode

    im dealing here with NativeProcess and specificly with commands in OS X.
    So, i have a .sh file in same dir as my app (currently Flash IDE and not yet Native Installer) and im reaching for that file, seems to work fine
    BUT i keep getting response from NativeProcessExitEvent dispatcher...
    and the exitCode is everything between 0 - 5 .
    Interesting part is that ive got 3 exitcodes so far.
    0 - it seemed that nothing happend in native process
    1 - is was exited normally
    2 - ?
    3 - ?
    4 - ?
    5 - when everything goes wrong, but what goes wrong (probably spaces infront of all lines in run.sh file) ?
    since LanguageReference doesnt link to any page where these exitCodes are listed, i need some guidance here
    anyhow, here is the code i have (maybe not the best one but its a start)
    in the same dir where this FLA is, i got run.sh as well
    I know that im not close enough to execute .sh paramsa from AIR, so in that case if you see anything wierd or wrong, let me know.
    There isnt much to walk on when working with NativeProcesses
    import flash.desktop.NativeProcess;
    import flash.desktop.NativeProcessStartupInfo;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.events.IOErrorEvent;
    import flash.events.NativeProcessExitEvent;
    import flash.filesystem.File;
    import flash.events.MouseEvent;
    var file:File = File.applicationDirectory.resolvePath('run.sh');
         var process:NativeProcess = new NativeProcess();
         var sui:NativeProcessStartupInfo = new NativeProcessStartupInfo();
         var args:Vector.<String> = new Vector.<String>();
         args.push('chmod -x "'+file.nativePath+'"');
         sui.executable = file;
         sui.arguments = args;
         process.addEventListener(NativeProcessExitEvent.EXIT, onExitError );
         process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onInputData);
         process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, onInputData);
         process.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, onIOError);
         process.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
         process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
         process.start(sui);
         process.closeInput();
         //process.exit(true);
    function onInputData(p:ProgressEvent):void{
         trace('2->'+process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable)+ ' - ' + p.bytesTotal)
    function onExitError(n:NativeProcessExitEvent):void
         trace('exitCode ',n.exitCode);
    and run.sh
    #!/bin/sh
    exec $@
    this particular code gives me exitCode 1, but what is it, what does it and what does it mean ? :S

    UPDATE:
    when changing as3 to
    process.start(sui);
         if(process && process.running){
              process.standardInput.writeUTFBytes('say hello');
         process.closeInput();
    then i get this error
    [SWF] ShellApp.swf - 4298 bytes after decompression
    [IOErrorEvent type="standardInputIoError" bubbles=false cancelable=false eventPhase=2 text="Error #3218: Error while writing data to NativeProcess.standardInput." errorID=3218]
    exitCode  1
    [UnloadSWF] ShellApp.swf
    could someone explain ?

  • ObjectOutputStream.readObject

    I am writing a client server application which exchanges objects over a
    socket connection. A new thread is started for each client connection
    and
    ObjectInputStream.readObject is used to receive the object. Once this
    object is processed the server must check from more messages until it
    receives a disconnect message. I do this using the following code:
    while(disconnect!=true)
    try {
    SphinxMessage msg = (SphinxMessage)ois.readObject();
    this.processNormalMessage(msg);
    }catch(IOException e3) { /*do nothing*/ }
    catch (ClassNotFoundException cnfe2){
    System.out.println(" readobject cnfe");
    cnfe2.printStackTrace();
    How can i make ObjectInputStream.readObject() block until it receives
    a message because at the moment it is continously looping calling
    readObject and catching the exception.
    Any help or suggestions would be appreciated.
    David.

    Once this object is processed the server must check from more messages until it
    receives a disconnect messageFWIW, from looking at posted code, here are my comments:
    1) What does a disconnect message look like?
    2) Is this disconnect message processed by this.processNormalMessage(msg);
    -- if so, did it correctly set the variable disconnect to false so that you can break out of the loop
    (I don't see this variable being set to false inside of the loop)?
    3) Have you tried to add a e3.printStackTrace(); to see what the IOException is?
    V.V.

  • NIO and writing objects

    I was curious if anyone has found a way to write an object to a ByteBuffer besides doing this:
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(new Object());
    ByteBuffer buf = ByteBuffer.wrap(baos.toByteArray());Also, does anyone know a good way to rebuild an object that was streamed using a Non-blocking SocketChannel?
    Thanks,
    b2s

    You have found the way. If you already have a ByteBuffer you can also just put() the ByteArrayOutputStream.getBytes() into it.
    You generally need to prepend the length of the array containing the object so you know when reading that you have the entire object. Reading it is then the reverse: read the length, read that many bytes, put them into a ByteArrayInputStream, then wrap an ObjectInputStream round that and do readObject().

  • Validation messages and displaying

    I am using JDeveloper 3.0 and not having an easy time with getting my validation error messages to show up. My Oracle contact is not a programmer and tends to give me an answer she doesn't understand herself.
    Anyway, I have tried creating a validator and per the oracle person, a domain. Either method does validate the field entry and prevent the data from being stored; however, both methods do not display the useful error message I threw back. I throw a jboexception that I want displayed and instead I get messages about how the validation failed or how it was unable to create, depending on whether the exception occurs in a validator or a domain.
    I am not familiar with the code and was hoping the documentation would give me a step by step of how to override whatever it is that I need to override or do whatever it is that I need to do. I want to use the functionality of the wizards by being able to set the validation or set the type of attribute to a domain. I think I could code this in the entity object java file, but I really want to make this sort of thing easy for another developer to choose my validation routine or domain while running the wizard.
    The example in Oracle's samples walks you through a simple edit on salary (salary > 1200). The validation catches all salaries below 1200 and throws back some ugly message about how the validation failed. What does one need to do to show their personal error message like "Salary must be greater than 1200"? Why is this simple concept so HARD?
    Please help me as I am ready to throw out JDeveloper and go with another product.
    Lisa

    In the setter method for an attribute on which you've installed a validator, (say for "Salary" attribute, in setSalary method), you could trap JboException and if the exception's error-code is 27011 (the one thrown from the compare validator as per your example), you could throw another JboException. Here's a sample code-snippet:
    public void setSalary (Number n)
    try
    setAttributeInternal(COMM, value);
    catch (JboException e)
    if (e.getErrorCode().equals("27011"))
    throw new oracle.jbo.JboException ("MY ERROR MESSAGE");
    // add logic for other exceptions
    throw e;
    Also, in the JDeveloper docs you could find more on how to customize exceptions. I've pasted some snippet from one of the docs.
    Programming with Exceptions
    Use exceptions to indicate serious or unexpected error conditions, conditions from which the program cannot easily recover. This topic presents the following
    information:
    About Java exceptions
    About exception classes
    Creating custom exception classes
    Localizing exception messages
    Marshaling exceptions
    About Java Exceptions
    Java exceptions fall into two categories: either they extend java.lang.RuntimeException (these are called implicit exceptions) or they do not (these are called
    explicit exceptions). When a method uses an explicit exception to indicate an error, a Java program requires:
    A throws clause in the method signature that declares the type of exception the method will throw when an error occurs.
    A throw statement in the method body that creates and throws an exception of the type specified in the signature.
    The following code shows a method getCustName that declares and throws a ValidationException.
    public String getCustName(Customer cust) throws ValidationException {
    String name = cust.mName;
    if (name == null) {
    throw new ValidationException();
    return name;
    When you write code that calls a method that throws an exception, enclose the call in a try...catch block. For example, the following code calls getCustName, a
    method defined to throw a ValidationException. The try keyword indicates that you are about to call one or more methods that throw exceptions. The catch
    keyword marks the beginning of a code block that executes only when an exception is thrown.
    public printName(Customer cust) {
    try {
    // Call the method(s) here.
    getCustName(cust);
    catch (ValidationException dae) {
    // Handle the error here.
    System.out.println(dae.getMessage());
    Java programs are more lenient about implicit exceptions: they do not have to be declared or caught. You can write a method that throws a RuntimeException (or a
    subclass of RuntimeException) without declaring it in the method signature (although you can do so, if you prefer).
    About Exception Classes
    The Business Components framework provides many exception classes (for example, ValidationException and NameClashException). These classes extend
    oracle.jbo.JboException, which extends java.lang.RuntimeException. Therefore, a Business Component method can throw a Business Component
    exception without a throws clause in the signature.
    Business Component exceptions have an attribute that stores an error message, and they support NLS translation and message formatting. JboException uses
    java.util.ListResourceBundle to format its messages. A resource bundle class defines constants and strings to use as error messages. The default format is
    {productCode}-{errorCode}: {messageBody}
    For example,
    ORA-10234: You cannot do that.
    Business Component exception messages are derived from the following generalized set of parameters:
    Parameter
    Example
    Product code
    "OBCJ"
    Error code
    "03101"
    ResourceBundle
    "oracle.jbo.CSMessageBundle"
    an optional set of parameters
    "Vendor", "Oracle"
    details
    Any exception thrown in low-level code that is transformed
    into a Business Component exception
    Messages may need to include information known only when the exception is thrown, so error message strings can include placeholders that refer to values in an array
    of Objects passed to the exception when it's thrown. When the message is formatted for display, these parameters are placed into slots in the message (the first slot is 0)
    using the standard formatting capabilities provided by java.text.MessageFormat. Following is a an entry from CSMessageBundle.java.
    public static final String EXC_VAL_ATTR_SET_FAILED = "03101";
    // Description: Generic Attribute validation failure.
    // set<Attribute> method failed to set the value.
    // Parameter 0: Ignored.
    // Parameter 1: Entity Object/View Object name.
    // Parameter 2: Attribute name.
    // Parameter 3: New value
    {EXC_VAL_ATTR_SET_FAILED, "Attribute set with value {3} for {2} in {1} failed."},
    The JboException class provides the following methods for working with exceptions.
    Method
    Description
    JboException(String message,
    String errorCode,
    Object[] params)
    Create a Formattable Exception Object.
    JboException(Class resBundleClass,
    String errorCode,
    Object[] params)
    Create a Translatable Exception Object.
    String getProductCode()
    Return the Product code for the Message.
    String getErrorCode()
    Return the Error code.
    String getLocalizedMessage(Locale loc)
    Return the Message in the specific Locale.
    Object[] getDetails()
    Details are usually used to accommodate
    lower-level exceptions. For example, if a
    SQLException is thrown in some low-level code, the Business Component
    framework can catch it and represent it as
    one of the Business Component exceptions.
    The original SQLException becomes
    the first entry in the detail.
    String getResourceName()
    Return the name of the ResourceBundle used to
    resolve messages.
    Object[] getErrorParameters()
    Return the Parameters to the Error.
    Creating Custom Exception Classes
    You can use Business Component exception classes in your own code to indicate errors, and you can create custom exception classes. For example, you can extend
    JboException and override the getProductCode method, making it return values appropriate for your exception.
    You can throw a JboException by using a statement like this:
    throw new JboException("Don't do that.", "101", null );
    The drawback to this approach is that the hard-coded error message is not easy to localize.
    Localizing Exception Messages
    To make an exception localizable into different national languages, use the NLS framework. First, create a resource bundle for your error messages. The following code
    example defines a bundle named MyMsgBundle that stores three error messages.
    import oracle.jbo.common.util.CheckedListResourceBundle;
    public class MyMsgBundle extends CheckedListResourceBundle
    // String Constants
    public static final String BAD_EMPNO = "101";
    public static final String DEPT_NOT_FOUND = "102";
    public static final String NOT_IN_DEPT = "103";
    * Private 2-D array of key-value pairs
    private static final Object[][] sMessageStrings = {
    { BAD_EMPNO, "Invalid employee number." },
    { DEPT_NOT_FOUND, "Department {0} does not exist." }
    { NOT_IN_DEPT, "Employee {0} not found in Department {1}." }
    Then you can use the resource bundle class to define a value to pass to the constructor for your exception class or JboException.
    throw new JboException(MyMsgBundle.class /* Class of Bundle */,
    MyMsgBundle.DEPT_NOT_FOUND /* String Constant */,
    new Object[1] { localVar1 } /* Arguments to message */
    JboException provides a getLocalizedMessage method which returns the message formatted for the specified locale.
    The framework translates the message text when the client calls getLocalizedMessage rather than at creation time because the client may need to present the
    message in a number of different languages. This mechanism provides a single point for localizing and formatting messages.
    Using JboExceptionHandler
    JboExceptionHandler is user-installable exception handler for three-tier applications. When exceptions are br ought over through the piggyback mechanism, the
    normal Java language throw does not quite work, because (among other things) the piggyback may have carried back more than one exceptions. Thus, instead of
    throwing the exception, a method on the JboExceptionHandler interface is invoked with each exception unloaded from the piggyback.
    JboExceptionHandler defines:
    void handleException(Exception ex, boolean lastEntryInPiggyback);
    Where ex is the exception unloaded from the piggyback and lastEntryInPiggyback is a flag indicating whether the exception was the last entry on the piggyback.
    (Note that for two-tier execution there is no piggyback.)
    If you do not install your own handler, the default handler is used. The default handler is implemented by the Application Module. (At the interface level,
    ApplicationModule implements JboExceptionHandler.) For jbo.client.remote, this implementation ignores the exception if lastEntryInPiggyback is
    false. If lastEntryInPiggyback is true, the exception is thrown.
    To install your own handler, call the following method on the Application Module interface:
    void setExceptionHandler(JboExceptionHandler hndlr);
    and pass in your own implementation of the JboExceptionHandler interface.
    Marshaling Exceptions
    JboException can marshal itself across a network. It handles NLS issues for the middle tier, enabling one instance of a middle-tier component to serve (for example)
    French users and English users at the same time.
    If your exception contains member data that need to be marshalled, extend JboException and override readObject and writeObject. The Java serialization
    mechanism uses these methods to serialize/deserialize an object. For example, suppose you have the class MyException (shown below), and you want to carry
    memberA and memberB across tiers.
    public class MyException extends JboException
    int memberA;
    String memberB;
    Write code like the following in MyException:
    private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(memberA);
    out.writeUTF(mEntityRowHandle);
    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    memberA = in.readInt();
    memberB = in.readUTF();
    null

  • Native process execution problem in mac os

    hi,
         In my flex application i have to get mac serial  number as a unique id for each system . On searching i got one terminal command to get serial number. For that i have  run terminal command through flex native process. I have set supportedprofile as <supportedProfiles>extendedDesktop desktop</supportedProfiles> in app xml. But when i install and run application on mac terminal is getting opened but command is not executing. I couldn't trace out the problem.  I could execute cmd in windows and that worked . Please help me to findout a solution................... The test code is adding below
    private var process:NativeProcess
    =
    new NativeProcess();
    protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
                    // TODO Auto-generated method stub
                    if(NativeProcess.isSupported) {
                        Alert.show("Yes NativeProcess");
                        process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutput);
                        process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onIOError);
                        process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
                        process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOError);
                        process.addEventListener(NativeProcessExitEvent.EXIT,onIOError);
                        var info:NativeProcessStartupInfo     =     new NativeProcessStartupInfo();
                        info.executable                               =     new File("/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal");
                         /*  var startupArgs:Vector.<String>    =     new Vector.<String>();
                             startupArgs[0]                              =    'system_profiler |grep "r (system)" '; 
                             info.arguments                              =    startupArgs;*/
                        //Alert.show(String(info.arguments.length));
                         process.start(info); 
                        process.standardInput.writeUTFBytes('system_profiler |grep "r (system)" '+ "\n");
                    }else
                        Alert.show("No");
                protected function onIOError(event:IOErrorEvent):void
                    // TODO Auto-generated method stub
                    Alert.show("Error");
                protected function onOutput(event:ProgressEvent):void
                    var processID:String            =    process.standardOutput.readMultiByte(process.standardOutput.bytesAvailable,"");       
                    Alert.show("Path : " + processID );
    I have tried to set arguments but didn't execute......
    Message was edited by: aswathykrishnan

    Hello Aswathy, these days I'm also coding an application which uses AIR NativeProcess and I required to open the MacOS terminal with some parameter/commands. I also eventually turn to the AppleScript, but I considerably new to the AppleScript, yet trying to findout a way to passing parameters (the command argument) to the AppleScript; the appleScript I managed to open but not passing the argument. Can you please help? here's my some probable codes for the application:
    My appleScript is:
    #!/bin/bash
    on run argv
              tell application "Terminal"
                        set currentTab to (do script) & item 1 of argv
              end tell
    end run
    I've packaged the appleScript as an Application (Contract.app) and here's my Flex code:
    var npInfo : NativeProcessStartupInfo = new NativeProcessStartupInfo();
    npInfo.executable = new File( "/Applications/Contract.app/Contents/MacOS/applet" );
                                  var arg:Vector.<String> = new Vector.<String>;
                                      arg[0]="ssh [email protected]";
                                  npInfo.arguments = arg;
                                  process = new NativeProcess();
      process.start( npInfo );
    Can you please help?
    Thank you.

  • How do I tell the user she is out of memory?

    In my Swing app, a thread can try and get too much data from the database. It catches the OutOfMemoryError exception, and passes it back up to the GUI. And then.... the GUI crashes when it tried to display the error message, because it's out of memory.
    I tried putting System.gc() calls all over the place. No joy.
    Ideas?
    --- Eric

    Right now, what I have my app doing is warning the user when they initiate an unlimited query (queries have a default limit). The warning basically states that "If too many results are returned, then the app will abruptly exit, because it runs out of memory, and I can't figure out a way to trap this case. Have a nice day, I'm a lousy programmer."
    I wonder if there is some way to detect when the vm is running low on memory, but isn't quite out. Then it could abort the process cleanly, tidy up, and keep the app running. Here's the code that runs out of memory:
    DataInputStream in = new DataInputStream(connection);
    ObjectInputStream oin = new ObjectInputStream(in);
    thingy = oin.readObject();Has anyone attempted to subclass ObjectInputStream and override readObject() with readObject(int iAbortThresholdInKilobytes)? Would this be tough?

  • Hi all, Got a doubt on Serialization..read on..quite interesting

    package package1;
    import java.io.*;
    public class Dog implements java.io.Serializable{
    transient private Collar theCollar; //Not serialiazable
    private int dogSize;
    public Dog(Collar collar,int size){
         theCollar=collar;
         dogSize=size;
    public Collar getCollar(){
         return theCollar;
    private void writeObject(ObjectOutputStream os){
         try{
              if(os!=null){
              os.defaultWriteObject();
              os.writeInt(theCollar.getCollarSize());
              else
                   System.out.println("null!!");
              os.flush();
              os.close();
         }catch(Exception e){
              e.printStackTrace();
    private void readObject(ObjectInputStream is){
         try{
              is.defaultReadObject();
              theCollar=new Collar(is.readInt());
              is.close();
         }catch(Exception e){
              e.printStackTrace();
    public static void main(String[] args){
         Collar c= new Collar(3);
         Dog d = new Dog(c,8);
         try{
         FileOutputStream fo = new FileOutputStream("test2341.ser");
         ObjectOutputStream oo = new ObjectOutputStream(fo);
         System.out.println(d.theCollar.getCollarSize());
         if(oo!=null){
         System.out.println("not null");
         d.writeObject(oo);
         else{
              System.out.println("stream is null!!!");
         oo.flush();
         oo.close();
         }catch(Exception e){
              e.printStackTrace();
    class Collar{
    private int collarSize;
    Collar(int size){
         collarSize=size;
    public int getCollarSize(){
         return collarSize;
    Ok..the following chunk of code compiles fine but during runtime throws a Java.IO.NotActiveException!!!
    Few points on this:
    1.Dog is serializable while collar is not(hence you see the transient spec in Dog class code for Collar reference)
    2.defaultWriteObject() is called inside writeObject() (Nested call requirement satisfied)
    3.ObjectOutputStream is not null(the if block(checks for not null)and executes in almost all methods)
    Then why am i getting NotActiveException ?? Any suggestions?

    the implementing the private read and write method is not wrong.You're two weeks late and you're wrong. Please read more carefully before your answer. Nobody said implementing private readObject() and writeObject() methods was wrong. Of course it isn't. It's defined in the Serialization Specification. How could it be wrong?
    What I said was that calling them yourself is wrong. You are supposed to call ObjectOutputStream.writeObject() and ObjectInputStream.readObject() from the outside. Inside, your writeObject method should call ObjectOutputStream.defaultWriteObject(), and your readObject method should call ObjectInputStream.defaultReadObject().
    using just the read and write is not sufficient to handle transient information that needs to be serializedOf course. But 'transient information that needs to be serialized' is really a contradiction in terms. If you're doing this you have a much bigger problem than just which methods to call when.

  • Applet-Servlet communication (Serialization)

    I need to pass certain objects from server side to the client applet. My applet is embedded in the jsp. Just before calling the applet, Im able to pass the string parameters via jsp <param>tag. Now I need to pass an object which is of a class type. I resorted to serialization. When i try to serialize the object in jsp and try to deserialize it in the applet I get this exception "java.io.StreamCorruptedException: invalid stream header".The jdk versions of applet and servlet are the same. Classes are serializable. But yet am not able to find out the reason for this annoying exception. Please help!

    Thanks for your reply.
    Iam calling the writeObject on an object, writing it to ObjectOutputStream and Iam using ObjectInputStream at the applet side to readObject which is serialized! Iam making use of HttpURLConnection only. Let me cut & paste a part of my applet & JSP code here.
    APPLET:
    =======
    HttpURLConnection jspConnection = null;
              String urlString = ServerAdd+"/xyz/abc.jsp";
              try{
                   URL url = new URL(urlString);
                   jspConnection = (HttpURLConnection)url.openConnection();
              }catch(Exception e){
                   e.printStackTrace();
              jspConnection.setDoInput(true);
              jspConnection.setDoOutput(true);
              jspConnection.setUseCaches(false);
              jspConnection.setDefaultUseCaches(false);
              jspConnection.setUseCaches(false);
              jspConnection.setDefaultUseCaches(false);
              jspConnection.setRequestProperty("Content-Type", "application/octet-stream");
    try{
    System.out.println("Getting inputstream from servlet...");
                   ObjectInputStream inputFromServlet = new ObjectInputStream(jspConnection.getInputStream());
                   System.out.println("Getting bpiPackage from servlet...");
                   bpiPackage = (BPIPackage)inputFromServlet.readObject();
                   inputFromServlet.close();
                   jspConnection.getInputStream().close();
                   jspConnection.disconnect();
                   jspConnection = null;
                   System.out.println("Data transmission from servlet complete...");
              }catch(MalformedURLException e){
                   System.out.println(e);
              }catch(IOException e){
                   System.out.println(e);
              }catch(ClassNotFoundException e){
                   System.out.println(e);
    StreamCorruptedException is thrown here
    ObjectInputStream inputFromServlet = new ObjectInputStream(jspConnection.getInputStream());
    JSP side:
    ========
    BPIPackage pkg = (BPIPackage)session.getAttribute("pkg");
         try{
              System.out.println("Sending package object to applet...");
              ObjectOutputStream outputToApplet = new ObjectOutputStream(response.getOutputStream());
         System.out.println("Writing package object...");
         outputToApplet.writeObject(pkg);
         outputToApplet.flush();
         outputToApplet.close();
         System.out.println("Data transmission to applet complete...");
         }catch (IOException e){
              e.printStackTrace();
    This exception occurs only when applet tries to deserialize data passed from JSP. There is no problem in the connection because there is no exception thrown when the reverse happens (ie.serializing in the applet and deserializing in the JSP using the same jspConnection)
    I hope the code makes my problem clear to you.
    In your reply I did not get this:
    "writing it to a ByteArrrayOutputStream, and taking those bytes, and base64 encoding them, sticking the value in an applet param.
    Then the applet is getting the applet param, and building a ByteArrayInputStream from it, and calling readObject on it.Could you elaborate more?

  • Can an ADT-packaged native installer install the AIR runtime in silent mode?

    Silent installation of my app works fine when the runtime is installed, as follows:
    <path>\MyApp.exe -silent -location "\"C:\Program Files\MyApp\"" -desktopShortcut -programMenu
    However, if the runtime is not installed, the invocation does nothing. I've also tried -eulaAccepted.
    Is it possible to silently install the app, yet if the runtime is not installed, initiate the runtime install automatically from adobe, preferably with a eula prompt for the user?
    Worst case, if the runtime must be bundled in the package, is a sidecar install supported for native installers?
    I should note, I cannot package the app as .air. The app uses NativeProcess and bundles an exe.
    Thanks.

    chris.campbell wrote:
    Dmitry Svetlakov wrote:
    I try use silent mode under Mac OS - doesn't work in this situation: Adobe AIR not installed on system.
    Because isntaller needs in access from administrator.
    Log:
    Jul 18 15:36:01 user-macbook-pro /var/folders/f+/f+YgX8A8EzyL0WM6aZ2rT++++TI/-Tmp-/airNEZFRK/Adobe AIR Installer.app/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer[8694]: Could not create directory at /Applications/Adobe/Flash Player/AddIns/airappinstaller
    Jul 18 15:36:01 user-macbook-pro /var/folders/f+/f+YgX8A8EzyL0WM6aZ2rT++++TI/-Tmp-/airNEZFRK/Adobe AIR Installer.app/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer[8694]: Error occurred during copy and set resource fork operation; beginning rollback: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="Unhandled exception Error: Could not create directory /Applications/Adobe/Flash Player/AddIns/airappinstaller" errorID=3001]
    Jul 18 15:36:09 user-macbook-pro /var/folders/f+/f+YgX8A8EzyL0WM6aZ2rT++++TI/-Tmp-/airNEZFRK/Adobe AIR Installer.app/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer[8694]: Rollback complete
    Jul 18 15:36:09 user-macbook-pro /var/folders/f+/f+YgX8A8EzyL0WM6aZ2rT++++TI/-Tmp-/airNEZFRK/Adobe AIR Installer.app/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer[8694]: Got an unexpected fatal error while in stateInstalling: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="Unhandled exception Error: Could not create directory /Applications/Adobe/Flash Player/AddIns/airappinstaller" errorID=3001]
    Jul 18 15:36:09 user-macbook-pro /var/folders/f+/f+YgX8A8EzyL0WM6aZ2rT++++TI/-Tmp-/airNEZFRK/Adobe AIR Installer.app/Contents/Frameworks/Adobe AIR.framework/Versions/1.0/Adobe AIR Application Installer.app/Contents/MacOS/Adobe AIR Application Installer[8694]: Application Installer end with exit code 7
    Hi Dmitry,
    Are you trying to sub launch AIR silently through your installer?  If so, and you haven't already, please fill out the AIR distribution agreement form and you'll receive documentation that discusses silent installs and uninstall's.
    If you are just trying this out, you are correct that the runtime needs admin access.  You can achieve this by prefixing your command line with sudo.
    Thanks,
    Chris
    Yes, but that not decide our task: create custom installer from air app native installer. I hope you understand that i mean. This installer should work for anyone user - and have to install Adobe AIR Runtime.

Maybe you are looking for