简体   繁体   English

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

[英]Grails - trying to deploy a nojars application into glassfish 3.0.1

Because of memory constraint i am trying to build a grails app with smaller memory footprint. 由于内存限制,我试图构建一个具有较小内存占用的grails应用。 I build the war with this argument "--nojars". 我用“ --nojars”这个参数来打架。 I created a war file without all the jar and when i deploy within the glassfish i encounter this error 我创建了一个没有所有jar的war文件,当我在glassfish中部署时遇到此错误

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 加载应用程序时发生异常:java.lang.Exception:java.lang.IllegalStateException:ContainerBase.addChild:开始: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. 似乎应用程序无法找到jar文件的位置。

I had already indicates the path to the library before deploying the application in glassfish. 在将应用程序部署到glassfish之前,我已经指出了该库的路径。

did i miss out somethinng? 我错过了吗?

It is commonly recommended to use GlassFish's Common Classloader . 通常建议使用GlassFish的Common Classloader That means putting the shared JARS into the $domain-dir/lib folder (but not into a subfolder of that). 这意味着将共享的JARS放入$ domain-dir / lib文件夹(但放入该文件夹的子文件夹)。

You're probably trying to use the Application Classloader with the asadmin deploy --libraries command. 您可能正在尝试将应用程序类加载器asadmin deploy --libraries命令一起使用。 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. 如果您不需要具有不同Web应用程序的相同JAR的不同版本,则绝对应该使用上面指定的Common Classloader

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). domain/domain1/lib文件夹肯定可以工作(我已经测试过)。 To validate that, put log4j.jar into that folder and add a test.jsp to domain1/applications/$applicationName , that just contains: 要验证这一点,请将log4j.jar放入该文件夹,然后将test.jsp添加到domain1/applications/$applicationName ,其中仅包含:

<% 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? 如果可以,但是您的其他代码不起作用,则可能需要考虑另一点:您在Logger.getLogger(..)使用Log4J的Logger.getLogger(..)还是Apache Commons的LogFactory.getInstance(..)

See the article Taxonomy of class loader problems encountered when using Jakarta Commons Logging for related issues. 有关相关问题,请参阅使用Jakarta Commons Logging时遇到的类加载器问题分类法 - I'd also like to advise you to post your complete stacktrace. -我也建议您发布完整的堆栈跟踪。

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

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