0

i am using grails 2.2.

I am running the grails app using the following command

run-app -noreloading -https -Dgrails.server.port.https=8443 -Dgrails.server.port.http=8080

I am getting the following error on starting the app

"C:\Program Files\Zulu\zulu-7\bin\java.exe" -Dgrails.home=C:\Users\user\Desktop\grails-2.2.0 "-Dtools.jar=C:\Program Files\Zulu\zulu-7\lib\tools.jar" -Dgroovy.starter.conf=C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -Djline.WindowsTerminal.directConsole=false -Dbase.dir=C:\Users\user\IdeaProjects\RCRoadRaceWeb -Dfile.encoding=UTF-8 -classpath C:\Users\user\Desktop\grails-2.2.0\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.0.5.jar;C:\Users\user\Desktop\grails-2.2.0\dist\grails-bootstrap-2.2.0.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf "run-app -noreloading -https -Dgrails.server.port.https=8443 -Dgrails.server.port.http=8080 -Duser.timezone=US/Mountain -plain-output"

|Loading Grails 2.2.0
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
......
|Compiling 1 source files
...........
|Running Grails application
|Creating SSL Certificate...
Error |
Server failed to start: com.ibm.crypto.tools.KeyTool (Use --stacktrace to see the full trace)

Process finished with exit code 1

If i run it normally without the https flag then it works but when i use https it fails on creating ssl certificate.

I am using java 1.7.

I appreciate any help as to how to overcome this error. Thanks for the help!

UPDATE:

After adding --stacktrace i am getting the following error

"C:\Program Files\Zulu\zulu-7\bin\java.exe" -Dgrails.home=C:\Users\user\Desktop\grails-2.2.0 "-Dtools.jar=C:\Program Files\Zulu\zulu-7\lib\tools.jar" -Dgroovy.starter.conf=C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -Djline.WindowsTerminal.directConsole=false -Dbase.dir=C:\Users\user\IdeaProjects\RCRoadRaceWeb -Dfile.encoding=UTF-8 -classpath C:\Users\user\Desktop\grails-2.2.0\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.0.5.jar;C:\Users\user\Desktop\grails-2.2.0\dist\grails-bootstrap-2.2.0.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf "run-app -noreloading -https --stacktrace -Dgrails.server.port.https=8443 -Dgrails.server.port.http=8080 -Duser.timezone=US/Mountain -plain-output"

|Loading Grails 2.2.0
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
......
|Compiling 1 source files
...........
|Running Grails application
|Creating SSL Certificate...
Error |
Server failed to start: com.ibm.crypto.tools.KeyTool (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: com.ibm.crypto.tools.KeyTool
    at java_lang_Class$forName.call(Unknown Source)
    at org.grails.plugins.tomcat.TomcatServer.getKeyToolClass(TomcatServer.groovy:186)
    at org.grails.plugins.tomcat.TomcatServer.this$2$getKeyToolClass(TomcatServer.groovy)
    at org.grails.plugins.tomcat.TomcatServer$this$2$getKeyToolClass.callCurrent(Unknown Source)
    at org.grails.plugins.tomcat.TomcatServer.createSSLCertificate(TomcatServer.groovy:167)
    at org.grails.plugins.tomcat.TomcatServer.startSecure(TomcatServer.groovy:140)
    at grails.web.container.EmbeddableServer$startSecure.call(Unknown Source)
    at _GrailsRun_groovy$_run_closure2.doCall(_GrailsRun_groovy:72)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at RunApp$_run_closure1.doCall(RunApp.groovy:32)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)

Error |
Server failed to start: com.ibm.crypto.tools.KeyTool
kofhearts
  • 3,607
  • 8
  • 46
  • 79
  • sure. i ll add the error – kofhearts Apr 16 '21 at 08:13
  • Have you tried to run with `--stacktrace` to see the full stackstrace? – Scratte Apr 16 '21 at 08:14
  • It looks similar to this issue [gradle-tomcat-plugin - Java 8 support #95](https://github.com/bmuschko/gradle-tomcat-plugin/issues/95) and also [grails-core issue #9018](https://github.com/grails/grails-core/issues/9018). Have you installed the JDK, and not just the JRE? – Scratte Apr 16 '21 at 08:28
  • yup both javac and java available. i used zulu jdk since they only seem to maintain jdk 1.7 – kofhearts Apr 16 '21 at 08:31
  • thank you. https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-configure-ssl seems to be for newer version. i am using grails 2.2. it has config.groovy. – kofhearts Apr 16 '21 at 08:36
  • The conversation in issue #9018 seems to be focused on different version as well. Grails 3 with Oracle JDK 1.7.0_79 seems to create it. Not sure I deserve a "thank you". – Scratte Apr 16 '21 at 08:38
  • 1
    guess i am trying to find the right question on google. configure ssl in grails 2.2 – kofhearts Apr 16 '21 at 08:39
  • grails 3 seem to have a way to use the ssl certificate manually created using keytool https://grails.org/blog/2017-06-28.html but i am not sure if grails 2 has it – kofhearts Apr 16 '21 at 08:42
  • Yes. I noticed. I'm afraid I can't be more helpful though. I don't have either on my own system. Perhaps someone else with more experience in the matter will come along :) – Scratte Apr 16 '21 at 08:51
  • 1
    finally found the solution. hope this is helpful to others as well. i am posting the answer. – kofhearts Apr 16 '21 at 08:57

1 Answers1

0

So i first manually generated the ssl certificate as guided here

https://community.pivotal.io/s/article/Generating-a-self-signed-SSL-certificate-using-the-Java-keytool-command?language=en_US

after that as pointed here

http://grails.1312388.n4.nabble.com/Specifying-the-SSL-certificate-in-Grails-2-x-td4629128.html

I pasted the following two lines in BuildConfig.groovy

grails.tomcat.keystorePath = "c:/Users/user/selfsigned.jks"
grails.tomcat.keystorePassword = "secret"

I was little puzzled locating the keystore path

since i used this command

keytool -genkey -keyalg RSA -alias tomcat -keystore selfsigned.jks -validity <days> -keysize 2048

and i was in C:\Users\user>

so i just did dir there and noticed selfsigned.jks

so i realized the path would be

c:/Users/user/selfsigned.jks

after this change the app ran happily. Seems like if there is self signed certifiacte configured using buildconfig then it will not create ssl certificate which would fail.

thank you ;op from

http://grails.1312388.n4.nabble.com/Specifying-the-SSL-certificate-in-Grails-2-x-td4629128.html

the solution was yours.

kofhearts
  • 3,607
  • 8
  • 46
  • 79