我们正在维护使用Grails 1.3.9开发的webapp。
为了监控性能,该应用程序安装了grails-melody 1.21插件。
似乎该插件在grails 1.3.x中不再可用于存储库。我按照google-code中的建议从documentation下载了它。
stackoverflow中的Another post表明压缩插件可以放在lib中,然后从BuildConfig.groovy中引用。
plugins {
runtime ":hibernate:1.3.9"
build ":tomcat:1.3.9"
compile ":dojo:1.6.1.17"
// Downloaded from
// https://code.google.com/p/javamelody/downloads/list?can=1&q=grails
// Installed from lib
// https://stackoverflow.com/questions/15751285/whats-the-correct-way-to-install-a-grails-plugin-from-a-zip-file
compile ":grails-melody:1.21"
}
我这样做了,当使用Oracle JDK 7(在Ubuntu 14.04上)构建war文件时,此过程运行正常。我不得不将grails-grails-melody-1.21.zip重命名为grails-melody-1.21.zip,以便找到它。
$ java -version
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
在构建过程中,在构建过程开始时加载了旋律的依赖项,此时grails文件也是副本:
...
Downloading: /home/matejk/devel/grails/grails-1.3.9/lib/servlet-api-2.5.jar ...
Download complete.
Downloading: /home/matejk/devel/grails/grails-1.3.9/lib/jsp-api-2.1.jar ...
Download complete.
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.pom ...
Download complete.
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.pom.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.pom ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.pom.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.pom ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.pom.sha1 ...
Download complete.
Downloading: /home/matejk/devel/grails/grails-1.3.9/lib/groovy-all-1.7.8.jar ...
Download complete.
Downloading: /home/matejk/devel/grails/grails-1.3.9/lib/commons-beanutils-1.8.0.jar ...
Download complete.
...
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.jar ...
Download complete.
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.jar.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.jar ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.jar.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar.sha1 ...
Download complete.
Downloading: /home/matejk/devel/grails/grails-1.3.9/lib/aspectjweaver-1.6.8.jar ...
...
生成的war文件在WEB-INF / lib中有javamelody,jrobin和itext jar。
但是,要求是在另一台机器(Jenkins)上使用JDK 1.6构建应用程序,在每台机器上都会对源进行干净的检查。
java -version
java version "1.6.0_31"
OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1ubuntu1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
在构建过程的后期发生了下载jar:
Executing hibernate-1.3.9 plugin post-install script ...
Plugin hibernate-1.3.9 installed
Installing zip /var/lib/jenkins/.ivy2/cache/org.grails.plugins/grails-melody/zips/grails-melody-1.21.0.zip... ...
[mkdir] Created dir: /var/lib/jenkins/workspace/etermin-2.4/target/projects/etermin-2.4/plugins/grails-melody-1.21
[unzip] Expanding: /var/lib/jenkins/.ivy2/cache/org.grails.plugins/grails-melody/zips/grails-melody-1.21.0.zip into /var/lib/jenkins/workspace/etermin-2.4/target/projects/etermin-2.4/plugins/grails-melody-1.21
Installed plugin grails-melody-1.21 to location /var/lib/jenkins/workspace/etermin-2.4/target/projects/etermin-2.4/plugins/grails-melody-1.21. ...
Resolving plugin JAR dependencies ...
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.pom ...
Download complete.
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.pom.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.pom ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.pom.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.pom ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.pom.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.jar ...
Download complete.
Downloading: http://repo1.maven.org/maven2/net/bull/javamelody/javamelody-core/1.44.0/javamelody-core-1.44.0.jar.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.jar ...
Download complete.
Downloading: http://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.jar.sha1 ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar ...
Download complete.
Downloading: http://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar.sha1 ...
Download complete.
但是,在使用JDK创建war时,javamelody,jrobin和itext jar都没有打包。
因此,webapp的部署和启动失败。
SEVERE: Error configuring application listener of class net.bull.javamelody.SessionListener
java.lang.ClassNotFoundException: net.bull.javamelody.SessionListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4153)
谢谢,
马捷
编辑:删除〜/ .grails / 1.3.9 /中的grails文件后,JDK 6和JDK 7的行为是相同的:
jar文件未打包,部署失败。
答案 0 :(得分:0)
我在使用Grails 1.3.7
中集成另一个插件时遇到了同样的问题我知道我所说的并不是最佳做法,但是我已经解决了这个问题。
将插件的.zip放在项目中想要的文件夹中,并提交到svn repo中。
在本地环境中,您可以使用grails installPlugin脚本指定要安装的插件。
当您需要在其他计算机上构建应用程序时,您还可以在项目中添加用户可以调用的脚本。 该脚本将包含第一个grails installPlugin和之后的grails war命令。
另一种方法是,如果您已经检查了插件的所有源代码,例如在名为myPlugin的文件夹(名为my-plugin)中,并且您的项目位于文件夹myProgect中,并且每个文件夹都在同一目录中,您可以在BuildConfig.groovy中添加一行代码:
grails.plugin.location.'my-plugin' = "../myPlugin"
如果插件文件夹不在同一路径中,则可以放置正确的路径:
grails.plugin.location.'my-plugin' = "../path/to/plugin/myPlugin"
这种方式不需要调用install plugin方法,grails知道依赖并打包插件。
希望我帮助你, 最好的问候。
答案 1 :(得分:0)
您可以设置本地存储库管理器,例如Artifactory,并从此存储库下载Grails插件。
您可以为Grails插件创建一个local Artifactory存储库,这在Grails插件存储库中不可用,并部署1.21版本的JavaMelody Grails插件。
接下来,您需要将此本地存储库添加到Grails正在解析的存储库列表中(BuildConfig.Groovy):
groovy grails.project.dependency.resolution = {
...
repositories {
grailsPlugins()
grailsHome()
mavenRepo "http://localhost:8081/artifactory/grails-plugins-local/"
grailsCentral()
}
plugins {
build ":grails-melody:1.21"
}
...
}
请访问spring.io博客中的Managing plugins with Grails 1.3,了解有关此类解决方案的更多详细信息。
答案 2 :(得分:0)
我设法解决这个问题的方法是明确地将melody的deps包含在BuildConfig.groovy中(从插件的依赖项中复制):
dependencies {
// Deps for grails-melody (copied from plugin deps) that are *not* included automatically with plugin.
compile "net.bull.javamelody:javamelody-core:1.44.0"
compile ("com.lowagie:itext:2.1.7") {
excludes "bcmail-jdk14", "bcprov-jdk14", "bctsp-jdk14"
}
compile "org.jrobin:jrobin:1.5.9"
}
plugins {
compile ":grails-melody:1.21"
}
我在Grails JIRA中看到了一些可能与我遇到的问题有关并在2.x中解决的错误