Griffon
  1. Griffon
  2. GRIFFON-207

"griffon run-app" gives java.lang.UnsatisfiedLinkError after a fresh install and creation of app

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 0.9
    • Fix Version/s: 0.9
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XPSP2
    • Number of attachments :
      3

      Description

      Installed 0.3.2 on Windows XP, then did a griffon create-app test032 followed by a cd test032 and griffon run-app which gives the following error :

      C:\Users\marcpa\test032>griffon run-app
      Welcome to Griffon 0.3.2 - http://griffon.codehaus.org/
      Licensed under Apache Standard License 2.0
      Griffon home is set to: C:\Tools\griffon-0.3.2
      
      Base Directory: C:\Users\marcpa\test032
      Running script C:\Tools\griffon-0.3.2\scripts\RunApp.groovy
      Environment set to development
      Warning, target causing name overwriting of name default
          [mkdir] Created dir: C:\Users\marcpa\.griffon\0.3.2\projects\test032\classes
        [groovyc] Compiling 11 source files to C:\Users\marcpa\.griffon\0.3.2\projects\test032\classes
          [mkdir] Created dir: C:\Users\marcpa\.griffon\0.3.2\projects\test032\resources\griffon-app\i18n
          [mkdir] Created dir: C:\Users\marcpa\.griffon\0.3.2\projects\test032\resources\griffon-app\resources
           [copy] Copying 1 file to C:\Users\marcpa\.griffon\0.3.2\projects\test032\resources\griffon-app\i18n
           [copy] Copying 8 files to C:\Users\marcpa\.griffon\0.3.2\projects\test032\resources\griffon-app\resources
           [copy] Copying 1 file to C:\Users\marcpa\.griffon\0.3.2\projects\test032\classes
           [copy] Copying 11 files to C:\Users\marcpa\.griffon\0.3.2\projects\test032\resources
           [copy] Copied 7 empty directories to 6 empty directories under C:\Users\marcpa\.griffon\0.3.2\projects\test032\resources
           [copy] Copying 1 file to C:\Users\marcpa\test032\staging
           [copy] Copying 1 file to C:\Users\marcpa\test032\staging
      java.lang.UnsatisfiedLinkError: C:\jre16\bin\awt.dll: The referenced assembly is not installed on your system
              at griffon.util.SwingUIThreadHandler.isUIThread(SwingUIThreadHandler.groovy:27)
              at griffon.util.UIThreadHandler$isUIThread.callCurrent(Unknown Source)
              at griffon.util.SwingUIThreadHandler.executeSync(SwingUIThreadHandler.groovy:35)
              at griffon.util.UIThreadHandler$executeSync.call(Unknown Source)
              at griffon.util.UIThreadHelper.executeSync(UIThreadHelper.groovy:100)
              at griffon.util.UIThreadHelper$executeSync.call(Unknown Source)
              at griffon.util.GriffonApplicationHelper.runScriptInsideUIThread(GriffonApplicationHelper.groovy:157)
              at griffon.util.GriffonApplicationHelper$runScriptInsideUIThread.call(Unknown Source)
              at griffon.core.BaseGriffonApplication.initialize(BaseGriffonApplication.groovy:94)
              at griffon.core.GriffonApplication$initialize.call(Unknown Source)
              at griffon.application.SwingApplication.initialize(SwingApplication.groovy)
              at griffon.core.GriffonApplication$initialize.call(Unknown Source)
              at griffon.util.GriffonApplicationHelper.prepare(GriffonApplicationHelper.groovy:62)
              at griffon.util.GriffonApplicationHelper$prepare.call(Unknown Source)
              at griffon.application.SwingApplication.bootstrap(SwingApplication.groovy:44)
              at griffon.application.StandaloneGriffonApplication$bootstrap.call(Unknown Source)
              at griffon.application.SwingApplication.main(SwingApplication.groovy:104)
      C:\Users\marcpa\test032>
      

      Although it may look like a manifestation of GRIFFON-156 or one of its duplicates, I am running a build (101 I think) where these are flagged as fixed and I took great care in trying to have no paths with spaces in them :

      • my user home is c:\Users\marcpa
      • my USERPROFILE is c:\Users\marcpa
      • java is installed under c:\jre16
      • griffon is installed under c:\Tools

      This works with griffon 0.3.1 and also it works without problems with 0.3.2 on Mac OS X.

      1. java-version.txt
        0.2 kB
        Marc Paquette
      2. session-with-jdk1.6.0_20.txt
        6 kB
        Marc Paquette
      3. user-env.txt
        1 kB
        Marc Paquette

        Issue Links

          Activity

          Hide
          Marc Paquette added a comment -

          File session-with-jdk1.6.0_20.txt contains a session log after I updated java to JDK 1.6.0_20, but result is the same.

          Show
          Marc Paquette added a comment - File session-with-jdk1.6.0_20.txt contains a session log after I updated java to JDK 1.6.0_20, but result is the same.
          Hide
          Richard Bradford added a comment -

          I have got around this "UnsatisfiedLinkError" (I get it on both 0.3.1 and when trying out 0.9-SNAPSHOT).
          I edited the exec line in RunApp.groovy from:

          Process p = Runtime.runtime.exec(cmd as String[], new String[0], jardir)
          

          to:

          Process p = Runtime.runtime.exec(cmd as String[], null, jardir)
          

          The "null" means the exec'ed java process inherits the environment from the script executing RunApp.groovy, and this seems to preserve whatever environment is required by java.exe to resolve its DLLs correctly.

          Note: to get this to work, you must "switch off" the pre-compiled <griffon home>/dist/griffon-scripts-<version>.jar - just rename it to e.g. "griffon-scripts-<version>.jar.off". Otherwise, you'll waste half an hour trying to work out why your edits to RunApp.groovy have no effect....

          I think the section:

              // setup the vm
              if (!binding.variables.javaVM) {
                  javaVM = [System.properties['java.home'], 'bin', 'java'].join(File.separator)
              }
          

          should take into account the settings of JAVA_HOME. "java.home" always finds the jre for the default java install - which may not be what you set up with JAVA_HOME. (In my case I have JAVA_HOME pointing at a jdk, not a jre).
          I cannot work out how "binding.variables" is set up - I assume it is possible to set "binding.variables.javaVM" somehow, and if so, there is probably something that could be done from startGriffon.bat to set javaVM...

          Show
          Richard Bradford added a comment - I have got around this "UnsatisfiedLinkError" (I get it on both 0.3.1 and when trying out 0.9-SNAPSHOT). I edited the exec line in RunApp.groovy from: Process p = Runtime.runtime.exec(cmd as String[], new String[0], jardir) to: Process p = Runtime.runtime.exec(cmd as String[], null, jardir) The "null" means the exec'ed java process inherits the environment from the script executing RunApp.groovy, and this seems to preserve whatever environment is required by java.exe to resolve its DLLs correctly. Note: to get this to work, you must "switch off" the pre-compiled <griffon home>/dist/griffon-scripts-<version>.jar - just rename it to e.g. "griffon-scripts-<version>.jar.off". Otherwise, you'll waste half an hour trying to work out why your edits to RunApp.groovy have no effect.... I think the section: // setup the vm if (!binding.variables.javaVM) { javaVM = [System.properties['java.home'], 'bin', 'java'].join(File.separator) } should take into account the settings of JAVA_HOME. "java.home" always finds the jre for the default java install - which may not be what you set up with JAVA_HOME. (In my case I have JAVA_HOME pointing at a jdk, not a jre). I cannot work out how "binding.variables" is set up - I assume it is possible to set "binding.variables.javaVM" somehow, and if so, there is probably something that could be done from startGriffon.bat to set javaVM...
          Hide
          Richard Bradford added a comment -

          Just to clarify: I applied the fix for the issue with spaces in the classpath that Andres recommended in GRIFFON-156 to griffon-0.3.1 and it is this code that has the "new String[0]" for the environment passed in the exec call. I don't think "out-of-the-box" 0.3.1 RunApp.groovy has this issue.

          Show
          Richard Bradford added a comment - Just to clarify: I applied the fix for the issue with spaces in the classpath that Andres recommended in GRIFFON-156 to griffon-0.3.1 and it is this code that has the "new String [0] " for the environment passed in the exec call. I don't think "out-of-the-box" 0.3.1 RunApp.groovy has this issue.
          Hide
          Andres Almiray added a comment -

          Awesome! Thank you Richard. This fix might apply to GRIFFON-221 as well, as there is definitely not special setup for Linux nor an explicit call to make the script run in headless mode.

          Just to clarify, can you confirm that this code

          Process p = Runtime.runtime.exec(cmd as String[], null, jardir)
          

          fixes the problem on Windows?

          I'll have a look at the setup of the JAVA_HOME variable too.
          Thank you!

          Show
          Andres Almiray added a comment - Awesome! Thank you Richard. This fix might apply to GRIFFON-221 as well, as there is definitely not special setup for Linux nor an explicit call to make the script run in headless mode. Just to clarify, can you confirm that this code Process p = Runtime .runtime.exec(cmd as String [], null , jardir) fixes the problem on Windows? I'll have a look at the setup of the JAVA_HOME variable too. Thank you!
          Hide
          Richard Bradford added a comment -

          Sorry for delay.
          Yes, I can confirm that the code fixes the problem on Windows.

          Show
          Richard Bradford added a comment - Sorry for delay. Yes, I can confirm that the code fixes the problem on Windows.

            People

            • Assignee:
              Andres Almiray
              Reporter:
              Marc Paquette
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: