Grails - 尝试将 nojars 应用程序部署到 glassfish 3.0.1 中
由于内存限制,我正在尝试构建一个内存占用较小的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常建议使用 GlassFish 的通用类加载器 。这意味着将共享 JARS 放入 $domain-dir/lib 文件夹中(但不放入该文件夹的子文件夹中)。
您可能尝试将应用程序类加载器与
asadmin deploy --libraries
命令结合使用。这个比较复杂,也容易出错。如果您不需要相同 JAR 的不同版本用于不同的 Web 应用程序,那么您绝对应该使用上面指定的通用类加载器。另请参阅类加载器层次结构以获取参考。
编辑根据提问者的评论进行更新:
domain/domain1/lib
文件夹绝对有效(我已经测试过)。要验证这一点,请将log4j.jar
放入该文件夹,并将test.jsp
添加到domain1/applications/$applicationName
,其中仅包含:如果这有效,但您的其他代码不起作用,则可能还需要考虑另一点:您是否使用 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, putlog4j.jar
into that folder and add atest.jsp
todomain1/applications/$applicationName
, that just contains: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.