Menu

Failed to spawn the peer VM!

Help
drai
2011-09-12
2014-12-23
1 2 > >> (Page 1 of 2)
  • drai

    drai - 2011-09-12

    I am using JWebBrowser in swing application. It has been working fine but
    recently I started getting following error on NativeInterface.open().

    Exception in thread "main" java.lang.IllegalStateException: Failed to spawn
    the peer VM!
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createPro
    cess(SWTNativeInterface.java:909)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOut
    ProcessMessagingInterface(SWTNativeInterface.java:949)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOut
    ProcessCommunicationChannel(SWTNativeInterface.java:738)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInter
    face.java:321)
    at
    chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
    at fw.MainApp.main(MainApp.java:47)

    Any pointers will be helpful.

    Thanks!

     
  • Christopher Deckers

    Does it happen frequently? Does it happen frequently enough so we can add
    debugging statements and try to reproduce it to better understand what is
    happening?

    -Christopher

     
  • benchpresser

    benchpresser - 2011-09-21

    can be it a later installed firewall or changed security setting?

     
  • drai

    drai - 2011-09-21

    Hi,

    Thanks for your reply. I can't run my project since I started getting this
    exception. There is no change in system security settings.

    How can I print debug statements?

    Thanks!

     
  • benchpresser

    benchpresser - 2011-09-22

    you can look to systemproperties file

    for example you may set system property such as

    nativeswing.swt.device.debug

     
  • drai

    drai - 2011-09-22

    I have tried several system properties to print debug messages but nothing
    made anything printed except following property:
    -Dnativeswing.peervm.debug.printCommandLine=true

    I could see few "Native Commands" before exception. I figured that for some
    reason those commands were using java from jre folder under java JDK (root JDK
    directory is in my class path). As soon as I rename jre folder to something
    else it started working. That is so bizarre.

    Here is what I get from debug output

    Native Command:

     
  • Christopher Deckers

    Hi,

    The spawned process uses the same JRE that is used to launch the application.
    For some reasons, it seems there is a problem with the version of Java you are
    using...

    Do you have any ideas which JRE is used when you renamed the JRE folder?

    -Christopher

     
  • Michael Dänzer

    Michael Dänzer - 2011-10-18

    Hello All

    I have exactly the same problem at a customer of use. We updated from 0.98 to
    1.02preview (for MacOS support) and since then we have at one customer the
    same errors with the same stack trace. The customer says that it happens on
    Windows 7 and Windows XP PC's with different Java versions ranging from 1.6.23
    to 1.6.27.

    We will try to add debug output to the customer's installation, but just to
    let you know that more people are pending on that :-(.

    Thanks and kind regards
    Michael

     
  • Christopher Deckers

    Michael,

    All native code is isolated in a secondary process, and there seems to be an
    issue when launching that process.

    I just uploaded a new 1.0.2 preview which may have more information (a cause
    to the exception that you are seeing) which may help us identify the problem.
    That build is: DJNativeSwing-SWT-1-0-2-20111018.zip

    Moreover, adding the system property to print the parameters would be useful:
    -Dnativeswing.peervm.debug.printCommandLine=true

    Please, let me know if you get those additional lines in the log or more
    information.
    -Christopher

     
  • Reto Weiss

    Reto Weiss - 2011-11-02

    Hi Christopher,

    I'm working in the same company as Michael. Because Michael is out of the
    country I have taken over this problem from him.
    I found the cause of the problem. The problem occurs if you have a \"
    character sequence in your PATH environment variable. The arguments of the
    spawned secondary process are then mismatched and the main class cannot be
    evaluated correctly.
    The problem can be solved by removing the \" character sequence from the PATH
    environment variable.
    Example:

    Problematic PATH Variable:

    C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOW\System32\Wbem;C:\Programme\IBM\Inform
    ix\Connect\bin;"C:\Programme\Humingbird\Connectivity\7.00\Accessories\";C:\Pro
    gramme\Autodesk\DWG True View\;C:\WINDOWS\system32\WindowsPowerShell\v1.0

    Unproblematic PATH Variable:

    C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOW\System32\Wbem;C:\Programme\IBM\Inform
    ix\Connect\bin;C:\Programme\Humingbird\Connectivity\7.00\Accessories;C:\Progra
    mme\Autodesk\DWG True View\;C:\WINDOWS\system32\WindowsPowerShell\v1.0

    Causes the following errors in the java console:
    NativeSwing: Error: Could not find or load main class Everybody;;"C:\Program
    NativeSwing: Error: Could not find or load main class Everybody;;"C:\Program
    Detected from bootclasspath: C:\Program Files
    (x86)\Java\jre7\lib\deploy.jar
    Could not launch from cache. Will try online mode.
    NativeSwing: Error: Could not find or load main class Everybody;;"C:\Program

    Java Web Start Error:

    Failed to connect to spawned VM!

    As you see the main class is not correct and contains parts of the my PATH
    variable.

    This is a critical issue for our customers. They can work around it by
    redefining the PATH variable but it would be very nice if you can fix it asap
    by escaping the command line arguments of the spawned secondary process
    correctly.

    Thanks

    Reto

     
  • Christopher Deckers

    Hi Reto,

    When it does not work, could you show me the console trace from activating
    this property:
    -Dnativeswing.peervm.debug.printCommandLine=true

    Cheers,
    -Christopher

     
  • Reto Weiss

    Reto Weiss - 2011-11-17

    Hi Christopher

    I have set the property as you recommended. Here is the result:
    Native Command:
    NativeSwing: Error: Could not find or load main class blah;

    I have set the system path to:
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\Sys
    tem32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program
    Files\SlikSvn\bin\;C:\Program Files\TortoiseGit\bin;C:\Program Files
    (x86)\ICW\bin;"c:\temp\";c:\temp blah; c:\temp

    The problem occurs if you have a \" in your system path which causes a wrong
    escaping in the argument -Djava.library.path=...;\"c:\temp\";c:\temp blah;
    c:\temp;...

    I think the problem is the character sequence \"

    Regard Reto

     
  • Christopher Deckers

    Hi Reto,

    I investigated this issue and I have several conclusions. First, this seems to
    be a Windows only problem. When creating a process and passing a parameter
    which is setting a system property containing quotes, it is as if the command
    gets generated wrong by ProcessBuilder.start.

    The second thing I tried was to find a rule that allows me to escape special
    characters in a reliable way, but I failed to find such a way. If anyone can
    find a sensible solution...
    In the meantime, here is the best effort approach I could come up with:
    https://github.com/Chrriis/DJ-Native-Swing/blob/master/DJNativeSwing-SWTCore/
    src/chrriis/dj/nativeswing/swtimpl/core/DefaultPeerVMProcessFactory.java#L92

    The latest 1.0.2 preview contains the fix. I hope my changes do not break
    other cases, but I would love to have confirmation from your end once you get
    to try it (both for cases that used to fail and also where it used to work).

    Cheers,
    -Christopher

     
  • Reto Weiss

    Reto Weiss - 2011-12-16

    Hi Christopher

    I tested your fix with the version 1.0.2-20111211. It works perfect. Thanks a
    lot. When will the 1.0.2 release be officially available?

    Cheers

    Reto

     
  • Christopher Deckers

    Hi Reto,

    Thank you very much for letting me know the result of your tests.

    1.0.2 does not have any release dates, because I don't have any real added
    features... Eventually if a serious bug or incompatibility is found I would
    fix it and release 1.0.2 but in the meantime I would suggest using the 1.0.2
    preview. It is stable and fixes a few bugs.

    Hope this helps,
    -Christopher

     
  • Reto Weiss

    Reto Weiss - 2011-12-20

    Hi Christopher,

    I come back with this issue, because we found a new problem with the newest
    1.0.2 prerelease. On Mac we get the following NPE if we have two Browsers in
    tabs of a tab pane. The NPE occurs if we change the selected tab or if we
    close a tab:
    java.lang.NullPointerException
    at org.eclipse.swt.widgets.Shell.setEnabled(Unknown Source)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeComponent$CMN_setControlParent
    Enabled.run(SWTNativeComponent.java:1174)
    at chrriis.dj.nativeswing.swtimpl.CommandMessage.runCommand(CommandMessage.jav
    a:61)
    at chrriis.dj.nativeswing.swtimpl.core.ControlCommandMessage.runCommand(Contro
    lCommandMessage.java:166)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.runMessageCommand(NativeInte
    rface.java:168)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.runMessageCommand(SW
    TNativeInterface.java:1328)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.runMessage(Messaging
    Interface.java:121)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.processReceivedMessa
    ges(MessagingInterface.java:106)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.access$2(MessagingIn
    terface.java:94)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface$2$2.run(MessagingInt
    erface.java:438)
    at org.eclipse.swt.widgets.RunnableLock.run(Unknown Source)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Unknown Source)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess.runSWTEven
    tPump(SWTNativeInterface.java:670)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess.access$1(S
    WTNativeInterface.java:665)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess$5.run(SWTN
    ativeInterface.java:657)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess$4.run(SWTN
    ativeInterface.java:608)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Unknown
    Source)
    at org.eclipse.swt.widgets.Display.applicationProc(Unknown Source)

    With an older prerelease of 1.0.2 (from August) we haven't had this error.

    Regards

    Reto

     
  • Christopher Deckers

    Hi Reto,

    The bug seems to occur in SWT itself (Shell class). Could you try a recent SWT
    (3.8M4 for example):
    http://download.eclipse.org/eclipse/downloads/drops/S-3.8M4-201112091447/inde
    x.php#SWT

    And if it still has the issue, could you add the SWT debug version to your
    classpath instead of the regular one so I know which line is the culprit?

    Cheers,
    -Christopher

     
  • fs

    fs - 2011-12-28

    Hello Christopher

    I working with Reto and have tested the mac version. With the newest version
    the same exception occurs. Here the exception:

    java.lang.NullPointerException
    at org.eclipse.swt.widgets.Shell.setEnabled(Shell.java:1644)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeComponent$CMN_setControlParent
    Enabled.run(SWTNativeComponent.java:1174)
    at chrriis.dj.nativeswing.swtimpl.CommandMessage.runCommand(CommandMessage.jav
    a:61)
    at chrriis.dj.nativeswing.swtimpl.core.ControlCommandMessage.runCommand(Contro
    lCommandMessage.java:166)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.runMessageCommand(NativeInte
    rface.java:168)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.runMessageCommand(SW
    TNativeInterface.java:1328)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.runMessage(Messaging
    Interface.java:121)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.processReceivedMessa
    ges(MessagingInterface.java:106)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.access$2(MessagingIn
    terface.java:94)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface$2$2.run(MessagingInt
    erface.java:438)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at
    org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3945)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3622)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess.runSWTEven
    tPump(SWTNativeInterface.java:670)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess.access$1(S
    WTNativeInterface.java:665)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess$5.run(SWTN
    ativeInterface.java:657)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess$4.run(SWTN
    ativeInterface.java:608)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.ja
    va:4886)
    at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5233)

    Thanks for your work!

    Cheers, fs

     
  • Christopher Deckers

    Hi,

    You are hitting a problem that I already raised to the SWT developers:
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=344401

    I would suggest you vote for the bug and indicate that the fact you are using
    a library that is hitting this bug is a showstopper for you (no possibility to
    change the library code, etc.)

    -Christopher

     
  • Eric Lopez

    Eric Lopez - 2012-04-10

    Hi Christopher,

    I am trying to activate the log using the VM parameter
    -Dnativeswing.peervm.debug.printCommandLine=true
    however I am not able to find the log(s). Could you please tell me the name of
    the log it produces? Or, the possible location where it goes to?

    Thank you in advance,

     
  • Christopher Deckers

    Hi,

    This does not activate logging, but prints the information to the console.

    Hope this helps,
    -Christopher

     
  • Greg Hanowski

    Greg Hanowski - 2013-04-18

    Hi,
    I am having the same problem. Getting Exception in thread "main" java.lang.IllegalStateException: Failed to connect to spawned VM!
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOutProcessMessagingInterface(SWTNativeInterface.java:1020)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOutProcessCommunicationChannel(SWTNativeInterface.java:762)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface.java:337)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)

    It was working fine for months using version .98. Then I let Windows Update do it's thing and ever since I cannot compile the program. I updated to DJNativeSwing-SWT-1-0-2-20120308 but same error. I am using NetBeans 6.5. I tried removing the library references and adding them back in, using relative and absolute paths. Nothing works.

    I see the last post was over 1 year ago and seems to end with no solution. Is there a fix to this? If the advice is to turn on debugging, please explain exactly how to do that.
    Thank you.
    Greg

     
  • Christopher Deckers

    Hi Greg,

    Maybe a firewall issue? Or maybe the antivirus software is blocking the ports that the Java application needs to communicate?

    You could try to activate these system properties:
    -Dnativeswing.localhostAddress.debug.printDetection=true
    -Dnativeswing.peervm.debug.printCommandLine=true

    These should print to the console the detection of the IP that is internally used to communicate between the 2 involved processes, and the command line used to start the second process.

    Hope this helps,
    -Christopher

     
    • Greg Hanowski

      Greg Hanowski - 2013-04-19

      I turned off the firewall and antivirus. Same problem. I traced your code and found that the socket connection is being refused, which causes the noted exception. I googled java.net.ConnectException: Connection refused and found "This exception usually occurs when there is no service listening on the port you are trying to connect to."

      Also, how exactly do I
      activate these system properties?:
      -Dnativeswing.localhostAddress.debug.printDetection=true
      -Dnativeswing.peervm.debug.printCommandLine=true

       
  • Christopher Deckers

    The system properties are set on the java command: they are VM arguments.
    You can also set them programmatically as the first thing in your main method:
    System.setProperty("nativeswing.localhostAddress.debug.printDetection", "true");
    System.setProperty("nativeswing.peervm.debug.printCommandLine", "true");

    Hope this helps,
    -Christopher

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.