Griffon
  1. Griffon
  2. GRIFFON-156

Application start fails if java.library.path contains spaces

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 0.9
    • Fix Version/s: 0.9.1
    • Component/s: cli
    • Labels:
      None
    • Environment:
      Windows
    • Number of attachments :
      0

      Description

      Hi,

      Since the addition of native lib support in GRIFFON-117, RunApp.groovy appends the application-specific natives directory to the default value of java.library.path. The resulting string is used as part of the application launch command.

      It is possible (and on Windows, quite likely) that the default value of java.library.path contains spaces. This causes the launch of the Griffon app to fail.

      One solution is to enclose the whole jvm option that sets java.library.path in quotes:

      diff --git a/scripts/RunApp.groovy b/scripts/RunApp.groovy
      old mode 100644
      new mode 100755
      index d5208fc..e62e431
      --- a/scripts/RunApp.groovy
      +++ b/scripts/RunApp.groovy
      @@ -97,7 +97,7 @@ target('default': "Runs the application from the command line") {
           if(nativeLibDir.exists()) {
               String libraryPath = System.getProperty('java.library.path')
               libraryPath = libraryPath + File.pathSeparator + nativeLibDir.absolutePath
      -        javaOpts << "-Djava.library.path=$libraryPath".toString()
      +        javaOpts << "\"-Djava.library.path=$libraryPath\"".toString()
           }
       // XXX -- NATIVE
      

        Issue Links

          Activity

          Hide
          Andres Almiray added a comment -

          The root of the problem were empty/null strings on the Process (mainly proxySettings).

          Show
          Andres Almiray added a comment - The root of the problem were empty/null strings on the Process (mainly proxySettings).
          Hide
          hu added a comment -

          I have do it as you say change the javaOpts << "-Djava.library.path=$libraryPath".toString() ,but the error is still here.Even I delete all the code in RunApp.groovy ,there is still this error:java.lang.NoClassDefFoundError: and

          Show
          hu added a comment - I have do it as you say change the javaOpts << "-Djava.library.path=$libraryPath".toString() ,but the error is still here.Even I delete all the code in RunApp.groovy ,there is still this error:java.lang.NoClassDefFoundError: and
          Hide
          Andres Almiray added a comment -

          As I believe I've said on a previous comment, the real problem is creating the Process, not java.library.path
          The following code will fix the problem

          def cmd = [javaVM]
          // let's make sure no empty/null String is added
          javaOpts.each { s -> if(s) cmd << s }
          [proxySettings, '-classpath', runtimeClasspath, griffonApplicationClass].each { s -> if(s) cmd << s }
          Process p = Runtime.runtime.exec(cmd as String[], new String[0], jardir)
          
          Show
          Andres Almiray added a comment - As I believe I've said on a previous comment, the real problem is creating the Process, not java.library.path The following code will fix the problem def cmd = [javaVM] // let's make sure no empty/ null String is added javaOpts.each { s -> if (s) cmd << s } [proxySettings, '-classpath', runtimeClasspath, griffonApplicationClass].each { s -> if (s) cmd << s } Process p = Runtime .runtime.exec(cmd as String [], new String [0], jardir)
          Hide
          Patrick Zumbuehl added a comment -

          I applied the lines above but it doesn't worked.
          I've added some 'println' in the script file but there was no additional output on the screen. Then I modified several scripts (Stats.groovy) at directory '.\scripts' but it hasn't any effect.
          So I tried to delete the script cache in 'C:\Documents and Seetings\patrick\.griffon\0.3.1\scriptCache' but the same story --> no effect.
          At the end I found it: the directory '.\dist' contains a JAR file named 'griffon-scripts-0.3.1.jar'. It seems that griffon always takes these (compiled) scripts. After renaming the JAR file from 'griffon-scripts-0.3.1.jar' to 'griffon-scripts-0.3.1.jar.x' it worked with the fix from Andres Almiray.

          Show
          Patrick Zumbuehl added a comment - I applied the lines above but it doesn't worked. I've added some 'println' in the script file but there was no additional output on the screen. Then I modified several scripts (Stats.groovy) at directory '.\scripts' but it hasn't any effect. So I tried to delete the script cache in 'C:\Documents and Seetings\patrick\.griffon\0.3.1\scriptCache' but the same story --> no effect. At the end I found it: the directory '.\dist' contains a JAR file named 'griffon-scripts-0.3.1.jar'. It seems that griffon always takes these (compiled) scripts. After renaming the JAR file from 'griffon-scripts-0.3.1.jar' to 'griffon-scripts-0.3.1.jar.x' it worked with the fix from Andres Almiray.
          Hide
          Andres Almiray added a comment -

          The fix for this issue causes GRIFFON-207. Reopening this one as the other bug is more critical.

          Show
          Andres Almiray added a comment - The fix for this issue causes GRIFFON-207 . Reopening this one as the other bug is more critical.

            People

            • Assignee:
              Andres Almiray
              Reporter:
              Robin Fernandes
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: