简体   繁体   中英

How to make changes to Tomcat 7 plugin source for Grails 2

I'm using Grails 2.3.11 with the Tomcat 7.0.54 plugin. My Java version is 1.8.0_181.
When I try to start the grails app with https enabled by running

grails run-app --https

I get the following exception:

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

I found an answer on how to fix the faulty code in the Tomcat plugin: https://stackoverflow.com/a/44673672/1037864
However I don't know how to get my changes to apply. When I edit the code in Tomcatserver.groovy nothing happens. My altered code is never executed.

Then I found that the Tomcat plugin is a jar-file (located at "C:\\Dev\\myproject\\webapp\\target\\work\\plugins\\tomcat-7.0.54\\grails-plugin-tomcat-7.0.54.jar") and that jar file is not updated when i build my project.
In my BuildConfig.groovy it says:

build ":tomcat:7.0.54"

... so I tried to change that to:

compile ":tomcat:7.0.54"

But when I try to run the project I get another error:

java.lang.NoClassDefFoundError: org/apache/catalina/startup/Tomcat at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.startup.Tomcat at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more
Error: A JNI error has occurred, please check your installation and try again

I guess I'm missing some dependencies.
What is the correct way to make the changes to Tomcatserver.groovy and then get it to compile (and replace the jar-file)?

I don't know if there is another way, but I got it working by:

  • Downloading the Tomcat-plugin source code from Github .
  • Made the changes to the source code.
  • Ran grails upgrade .
  • Ran grails package-plugin --binary .
  • Copied the new jar-file ( target\\grails-plugin-tomcat-7.0.54.jar ) to my main project's tomcat-directory ( C:\\Dev\\myproject\\webapp\\target\\work\\plugins\\tomcat-7.0.54\\) .
  • Started my main project with grails run-app --https

I was now able to browse to my site using https on port 8443.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM