如何解析外部配置文件中的类引用以进行 grails war 部署?

发布于 2024-12-07 14:34:09 字数 1360 浏览 0 评论 0原文

我正在使用 Grails 1.3.7。我建立了一个战争文件&将其部署到tomcat中。我有一个外部 groovy 配置文件,用于设置日志记录。我在声明中添加了一些 perf4j 日志附加程序,但现在配置文件无法编译,因为它无法解析完全限定的类名。

代码如下所示:

log4j = {
    ...
    // file appender that writes out the URLs of the Google Chart API graphs generated by the performanceGraphAppender
    def performanceGraphFileAppender = new org.apache.log4j.FileAppender(
        fileName: "log/perfGraphs.log",
        layout: pattern(conversionPattern: '%m%n')
    )
    appender name: 'performanceGraphFileAppender', performanceGraphFileAppender

    // this appender creates the Google Chart API graphs
    def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(
        graphType: 'Mean',      // possible options: Mean, Min, Max, StdDev, Count or TPS
        tagNamesToGraph: 'tag1,tag2,tag3',
        dataPointsPerGraph: 5
    )
    performanceGraphAppender.addAppender(performanceGraphFileAppender)
    appender name: 'performanceGraph', performanceGraphAppender

    ...
}

写入日志的错误消息如下:

script1317679813518843914255.groovy: 38: unable to resolve class org.perf4j.log4j.GraphingStatisticsAppender 
@ line 38, column 34.
    def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(

我正在构建的 war 文件包含所有必需的 JAR。关于如何让它解决参考文献有什么想法吗?

谢谢,

吉恩

I am using Grails 1.3.7. I build a war file & deploy it in tomcat. I have an external groovy configuration file that I use to set up logging. I added some perf4j logging appenders to the declaration, but now the configuration file fails to compile because it cannot resolve the fully-qualified class names.

The code looks like this:

log4j = {
    ...
    // file appender that writes out the URLs of the Google Chart API graphs generated by the performanceGraphAppender
    def performanceGraphFileAppender = new org.apache.log4j.FileAppender(
        fileName: "log/perfGraphs.log",
        layout: pattern(conversionPattern: '%m%n')
    )
    appender name: 'performanceGraphFileAppender', performanceGraphFileAppender

    // this appender creates the Google Chart API graphs
    def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(
        graphType: 'Mean',      // possible options: Mean, Min, Max, StdDev, Count or TPS
        tagNamesToGraph: 'tag1,tag2,tag3',
        dataPointsPerGraph: 5
    )
    performanceGraphAppender.addAppender(performanceGraphFileAppender)
    appender name: 'performanceGraph', performanceGraphAppender

    ...
}

and the error message that's written out into the log is this:

script1317679813518843914255.groovy: 38: unable to resolve class org.perf4j.log4j.GraphingStatisticsAppender 
@ line 38, column 34.
    def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(

The war file I am building contains all the required JARs. Any thoughts on how to get it to resolve the references?

Thanks,

Gene

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

活雷疯 2024-12-14 14:34:09

部署后有可能开始使用 tomcat 中的 log4j。看一下 lib 文件夹,也许它包含 log4j jar。如果这是真的 - 它使用不同的类加载器,则看不到您的 perf4j 类。

您可以尝试将 perf4j jar 放入 tomcat 的 lib 中,也许可以解决此问题

There is a possibility that after deployment, it starts using log4j from tomcat. Take a look at lib folder, maybe it's contains log4j jars. If that's true - the it uses different classloader, that can't see your perf4j classes.

You can try to put your perf4j jars into tomcat's lib, probably it can fix this issue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文