Grails - 尝试将 nojars 应用程序部署到 glassfish 3.0.1 中

发布于 2024-10-02 21:08:58 字数 470 浏览 1 评论 0原文

由于内存限制,我正在尝试构建一个内存占用较小的 grails 应用程序。我用“--nojars”这个论点来发动战争。我创建了一个没有所有 jar 的 war 文件,当我在 glassfish 中部署时,我

在加载应用程序时遇到此错误异常:java.lang.Exception:java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina。 LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.web.util.Log4jConfigListener

应用程序似乎无法找到 jar 文件在哪里。

在 glassfish 中部署应用程序之前,我已经指出了库的路径。

我错过了什么吗?

Because of memory constraint i am trying to build a grails app with smaller memory footprint. I build the war with this argument "--nojars". I created a war file without all the jar and when i deploy within the glassfish i encounter this error

Exception while loading the app : java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.web.util.Log4jConfigListener

It seems like the application fail to find where is the jar file.

I had already indicates the path to the library before deploying the application in glassfish.

did i miss out somethinng?

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

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

发布评论

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

评论(1

缱倦旧时光 2024-10-09 21:09:02

通常建议使用 GlassFish 的通用类加载器 。这意味着将共享 JARS 放入 $domain-dir/lib 文件夹中(但放入该文件夹的子文件夹中)。

您可能尝试将应用程序类加载器asadmin deploy --libraries 命令结合使用。这个比较复杂,也容易出错。如果您不需要相同 JAR 的不同版本用于不同的 Web 应用程序,那么您绝对应该使用上面指定的通用类加载器

另请参阅类加载器层次结构以获取参考。


编辑根据提问者的评论进行更新:

domain/domain1/lib文件夹绝对有效(我已经测试过)。要验证这一点,请将 log4j.jar 放入该文件夹,并将 test.jsp 添加到 domain1/applications/$applicationName,其中仅包含:

<% out.println(
    org.apache.log4j.Logger.getLogger(this.getClass())); %>

如果这有效,但您的其他代码不起作用,则可能还需要考虑另一点:您是否使用 Log4J 的 Logger.getLogger(..) 或 Apache Commons 的 LogFactory.getInstance(..) 在你的代码中?

有关相关问题,请参阅文章使用 Jakarta Commons Logging 时遇到的类加载器问题的分类。 - 我还想建议您发布完整的堆栈跟踪。

It is commonly recommended to use GlassFish's Common Classloader. That means putting the shared JARS into the $domain-dir/lib folder (but not into a subfolder of that).

You're probably trying to use the Application Classloader with the asadmin deploy --libraries command. This is more complicated and error-prone. If you don't need different versions of the same JARs with different web applications, you should definitely go for the Common Classloader as specified above.

Also see The Classloader Hierarchy for a reference.


EDIT Updated as per the questioner's comment:

The domain/domain1/lib folder definitely works (I've tested that). To validate that, put log4j.jar into that folder and add a test.jsp to domain1/applications/$applicationName, that just contains:

<% out.println(
    org.apache.log4j.Logger.getLogger(this.getClass())); %>

If that works but your other code does not, there may be another point to consider: Are you using Log4J's Logger.getLogger(..) or Apache Commons' LogFactory.getInstance(..) in your code?

See the article Taxonomy of class loader problems encountered when using Jakarta Commons Logging for related issues. - I'd also like to advise you to post your complete stacktrace.

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