WEB-INF\lib和.classpath中需要存在哪些jar [英] Which jars needs to be present in WEB-INF\lib and in .classpath

查看:380
本文介绍了WEB-INF\lib和.classpath中需要存在哪些jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在转换常规J2EE应用程序以使用Maven。我能够成功转换为Maven,并且我获得了成功的mvn deploy。在将资源部署到WAS后面临的问题。我得到
SRVE0203E:Servlet [action] org.apache.struts.action.ActionServlet缺少另一个必需的类。



我对不同的应用程序有类似的问题在尝试了几个排除罐子之后,我能够在WAS中成功部署应用程序。我有以下问题。


  1. 我们如何确定WEB-inf\lib文件夹中所有罐子需要出现的内容?


  2. 我们如何确定战争meta-inf的.class-path中需要出现的所有罐子。


  3. 我们怎样才能确定即使在.classpath中提到了jar这个战争也行不通,但是不强制它必须存在于web-inf\lib中(即类加载器将从而不是战争)


仅供参考我使用的是j2ee 1.4

解决方案

在Container中执行的Java EE应用程序具有由多个级别组成的类路径:


  1. Web应用程序类路径,由WEB-INF / lib中包含的JAR和类文件表示

  2. 企业应用程序类路径,包括在EAR级别声明的JAR文件

  3. 容器类路径,包含Websphere Runtime和共享库



  4. 这些级别之间存在复杂的依赖关系规则,但主要思想是所有应用程序库必须包含在此级别之间,以避免任何可能破坏类路径的冲突。



    考虑到这一点,一种简单的方法是将所有应用程序JAR放在WEB-INF / lib中。这可行,但如果您的EAR有两个Web模块,则每个模块都需要它自己的一组JARS。一种更强大的方法是在EAR级别包含通用JAR,以避免JAR的两面性。



    如果情况是贵公司有一个所有应用程序都使用的专有框架,将相同的JARS包含在公司的每个EAR应用程序中都是愚蠢的。更好的方法是将公司框架配置为Container中的共享库,以便所有应用程序都可以重用它。



    总之,有决定Java EE应用程序类路径的几个因素。您应该记住始终避免重复和版本冲突,因此您的应用可以顺利解决它的依赖关系。


    I am converting a regular J2EE application to use Maven. I was able to successfully convert to Maven and I am getting successful "mvn deploy". The issue is facing after deploying the ear to WAS. I am getting SRVE0203E :Servlet [action] org.apache.struts.action.ActionServlet is missing another required class.

    I had similar problems for different application and after trying couple of "exclusion" of jars I was able to deploy the application successfully in WAS. I have following question.

    1. How can we identify what all jars needs to be present in WEB-inf\lib folder?

    2. How can we determine, what all jars needs to be present in the .class-path of wars meta-inf.

    3. How can we determine that the war will work even if the jar is mentioned in .classpath but not mandatory that it needs to be present in web-inf\lib (ie classloader will pull from ear instead of war)

    FYI I am using j2ee 1.4

    解决方案

    A Java EE application executing in a Container has a classpath composed of several levels:

    1. Web application classpath, represented by the JAR and Class files included in WEB-INF/lib
    2. Enterprise application classpath, that includes JAR files declared at EAR level
    3. Container classpath, that contains the Websphere Runtime and Shared Libraries

    There are complex dependency rules between these levels, but the main idea is that all your application libraries must be included between this levels avoiding any conflict that can corrupt the classpath.

    With that in mind, a simplistic approach would be to put all your application JAR's in WEB-INF/lib. That would work but if your EAR has two Web Modules each Module would require it own set of JARS. A more robust approach would be to include common JARs at EAR level so JAR duplicity would be avoided.

    If the case is that your company has a propietary framework that all applications use, it would be silly to include the same JARS in every EAR application of the company. A better way to do this would be to configure the company framework as a shared library in the Container so it can be reused by all the applications.

    In conclusion, there are several factors that determine your Java EE application classpath. You should keep in mind to always avoid duplicity and version conflict, so your app can resolve it dependencies smoothly.

    这篇关于WEB-INF\lib和.classpath中需要存在哪些jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆