zoukankan      html  css  js  c++  java
  • tomcat 自定义classpath(亲自测试)

    因为一直以来使用tomcat和weblogic作为应用服务器为主,最近在升级新中间件的过程中遇到一个问题,我们的web前端应用现在升级是进行全量包升级的,因为现在的系统架构为前端和后端通过rpc框架交互的,后端使用java service wrapper进行管理,其组织架构允许我们在配置文件中随意设置lib目录(其实,早在三个月之前,笔者是非常不想使用它的),我们将三方类库和公司的框架类库以及应用类库分别放在不同的目录中进行管理,这样就可以仅仅升级应用jar包,框架和应用可以独立解耦的管理。

    因为前端要提供视图层,所以还是用tomcat,但是在tomcat 6以及之后的版本中,和5.5以及之前的版本中,其类加载器架构发生了变化,去掉了原来的shared加载器,如下所示:

    5.5架构

     https://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

    6.0以后架构:

    https://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

    注:https://www.mulesoft.com/tcat/tomcat-classpath和http://blog.csdn.net/andyelvis/article/details/6719996,有提及5.5以及之前的版本,6.0开始并无更新提及。

    可见,已经没有了shared类加载器。虽然在catalina.properties中还有shares.folder参数,但该参数经测试并无作用。

    #
    #
    # List of comma-separated paths defining the contents of the "common"
    # classloader. Prefixes should be used to define what is the repository type.
    # Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
    # If left as blank,the JVM system loader will be used as Catalina's "common"
    # loader.
    # Examples:
    # "foo": Add this folder as a class repository
    # "foo/*.jar": Add all the JARs of the specified folder as class
    # repositories
    # "foo/bar.jar": Add bar.jar as a class repository
    common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar

    # List of comma-separated paths defining the contents of the "shared"
    # classloader. Prefixes should be used to define what is the repository type.
    # Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
    # the "common" loader will be used as Catalina's "shared" loader.
    # Examples:
    # "foo": Add this folder as a class repository
    # "foo/*.jar": Add all the JARs of the specified folder as class
    # repositories
    # "foo/bar.jar": Add bar.jar as a class repository
    # Please note that for single jars, e.g. bar.jar, you need the URL form
    # starting with file:.
    shared.loader=${catalina.home}/shared/lib,${catalina.home}/shared/lib/*.jar,${catalina.base}/shared/lib,${catalina.base}/shared/lib/*.jar

    上述jar并没有被加载到应用中。

    现在看来,如果一定要引用非标目录中的jar,只能加到tomcat/lib中的方式来解决。

    PS:也测试过直接修改catalina.sh中的classpath,仍然不能正常的启动和运行应用。

  • 相关阅读:
    Form组件
    LAMP+Varnish的实现
    缓存反向代理-Varnish
    CDN初识
    HTTP缓存初探
    Keepalived搭建主从架构、主主架构实例
    实现高可用-Keepalived
    nginx负载均衡实例
    lvs集群实现lvs-dr模型和lvs-nat模型
    LVS介绍
  • 原文地址:https://www.cnblogs.com/zhjh256/p/6220311.html
Copyright © 2011-2022 走看看