简体   繁体   English

如何对Grails 2的Tomcat 7插件源进行更改

[英]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. 我正在将Grails 2.3.11与Tomcat 7.0.54插件一起使用。 My Java version is 1.8.0_181. 我的Java版本是1.8.0_181。
When I try to start the grails app with https enabled by running 当我尝试通过运行启动启用https的grails应用程序时

grails run-app --https

I get the following exception: 我得到以下异常:

java.lang.ClassNotFoundException: com.ibm.crypto.tools.KeyTool 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 我找到了有关如何解决Tomcat插件中错误代码的答案: 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. 当我在Tomcatserver.groovy中编辑代码时,什么也没发生。 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. 然后我发现Tomcat插件是一个jar文件(位于“ C:\\ Dev \\ myproject \\ webapp \\ target \\ work \\ plugins \\ tomcat-7.0.54 \\ grails-plugin-tomcat-7.0.54.jar”)并且当我构建项目时,该jar文件不会更新。
In my BuildConfig.groovy it says: 在我的BuildConfig.groovy中,它说:

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) java.lang.NoClassDefFoundError:org / apache / catalina / startup / Tomcat at java.lang.Class.getDeclaredMethods0(本地方法)at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)at java.lang.Class.privateGetMethodRecursive (java.lang.Class.getMethod0(Class.java:3018)处的java.lang.Class.getMethod(Class.java:1784)处的java.lang.Class.getMethod0(Class.java:1784)处的sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java: 544)在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 由以下原因导致:java.lang.ClassNotFoundException:org.apache.catalina.startup.Tomcat at java.net.URLClassLoader.findClass(URLClassLoader.java:381)at java.lang.ClassLoader.loadClass(ClassLoader.java:424) .misc.Launcher $ AppClassLoader.loadClass(Launcher.java:349)at java.lang.ClassLoader.loadClass(ClassLoader.java:357)...还有7个
Error: A JNI error has occurred, please check your installation and try again 错误:发生了JNI错误,请检查您的安装并重试

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)? 对Tomcatserver.groovy进行更改然后进行编译(并替换jar文件)的正确方法是什么?

I don't know if there is another way, but I got it working by: 我不知道是否还有另一种方法,但是我通过以下方法使它起作用:

  • Downloading the Tomcat-plugin source code from Github . Github下载Tomcat插件源代码。
  • Made the changes to the source code. 对源代码进行了更改
  • Ran grails upgrade . grails upgrade
  • Ran grails package-plugin --binary . 跑了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\\) . 将新的jar文件( target\\grails-plugin-tomcat-7.0.54.jartarget\\grails-plugin-tomcat-7.0.54.jar到主项目的tomcat目录中( C:\\Dev\\myproject\\webapp\\target\\work\\plugins\\tomcat-7.0.54\\)
  • Started my main project with grails run-app --https grails run-app --https开始我的主要项目

I was now able to browse to my site using https on port 8443. 现在,我可以在端口8443上使用https浏览到我的站点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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