Grails 2.4 java 8 and tomcat 7.0.55.2

I am trying to run an https site using grails 2.4.4 with the tomcat plugin:

build ':tomcat:7.0.55.2'

The first time I tried to run the application, I got into the following problem: issue 648

java.lang.ClassNotFoundException: com.ibm.crypto.tools.KeyTool

When I change the tomcat dependency for tomcat to tomcat 8.0.22 and run the application again, it succeeds and goes beyond ie createSSLCertificate (File keystoreDir) works, and although the application does not start. If I change it to tomcat 7.0.55.2 now, the keys will be generated and the application will work.

I guess the question is, I'm not sure if this is a fix that Graham pointed out that exists only in tomcat 8, or is there a later version of tomcat 7 that I could use to fix this problem.

Although this hack is fine for the development machine, I really need something more specific when the application is created through jenkins, etc.

To recreate it locally if I do

grails clean-all 

and try

grails run-app -https 

I first got into a problem until I repeat the above steps.

Thinking about it, Jenkins producing the WAR file might be fine, although from a development perspective it would still be nice to find a more convenient way to make it all work.

+4
source share
1 answer

I myself ran into this problem. I tried some other solutions that I found on the Internet until I came across https://github.com/grails/grails-profile-repository/pull/14/files This helped me solve this problem and launch my application using - https

TomcatServer.groovy :

protected getKeyToolClass() {
    try {
        Class.forName 'sun.security.tools.KeyTool'
    }
    catch (ClassNotFoundException e) {
        // no try/catch for this one, if neither is foun\d let it fail
        Class.forName 'com.ibm.crypto.tools.KeyTool'
    }
}

:

protected Class getKeyToolClass() {
    try {
        try {
            // Sun JDK 8
            return Class.forName('sun.security.tools.keytool.Main')
        }
        catch (ClassNotFoundException e1) {
            try {
                // Sun pre-JDK 8
                return Class.forName('sun.security.tools.KeyTool')
            }
            catch (ClassNotFoundException e2) {
                 // no try/catch for this one, if neither is found let it fail
                 return Class.forName('com.ibm.crypto.tools.KeyTool')
            }
        }
    }
    catch (Throwable e) {
        return null
    }
}
+2

Source: https://habr.com/ru/post/1619007/


All Articles