導航

          <2007年12月>
          2526272829301
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          統(tǒng)計

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          Websphere Classes沖突診斷

          作者:tacy lee

          由于大量開源框架的采用,Classes沖突的問題在我們的項目中越來越常見,下面寫了一個簡單的jsp,用來查找當前使用類的位置:

          <%@page contentType="text/html; charset=gb2312" %>
          
          <html>
            <head>
              <title>Class conflict</title>
            </head>
            
            <body>
                Example input: com.primeton.tp.web.driver.webdriver.PageDriver<br>
              <form action="<%=request.getRequestURI()%> " method="post">
                <input type="text" name="className" size="50" ><br>
                <input type="submit" value="submit">
              </form>
              <%
                      String classLocation = null;
                      String className =request.getParameter("className");
          
                      if ((className != null) && ((className = className.trim()).length() != 0)) {
                        try{
                          classLocation = Class.forName(className).getProtectionDomain().getCodeSource().toString();
                          }catch(Throwable e){
                              log("error=" + e, e);
                          }
          
                          if (classLocation != null) {
                              out.println("Class " + className + " found in <br>" + classLocation );
                          }
                        else {
                            out.println("Class '" + className + "' not found" );
                          }
                      }
              %>
            </body>
          <html>
          
          

           

          通過這個jsp頁面可以輸入需要查詢的類

          -----------------------------------------------------------------------------------------------------------------------------------------------------

          另外,websphere可以通過下面兩個方法來改變類的加載:

          1、在"Applications" >"Enterprise Applications" >" yourear ">" Class Loading and File Update Detection"

          修改:"Class loader mode" 為 "Parent Last",這樣應用類可以覆蓋父裝載器的類

          當然但如果你混合使用了被覆蓋的類和沒有被覆蓋的類,則此操作有可能會導致 ClassCastException 或 LinkageErrors

          2、在"Servers" > "Application servers" > "yourserver" > "Process Definition" > "Java Virtual Machine"

          添加CLASSPATH,讓你的類先加載

          posted on 2007-12-21 18:05 tacy lee 閱讀(1346) 評論(0)  編輯  收藏 所屬分類: 測試相關

          主站蜘蛛池模板: 濉溪县| 长宁县| 青海省| 岑巩县| 察雅县| 岗巴县| 佳木斯市| 莲花县| 尖扎县| 潮安县| 昔阳县| 招远市| 沙湾县| 赤城县| 上蔡县| 潮安县| 旬邑县| 外汇| 铁岭市| 泰顺县| 汝州市| 锦屏县| 洪雅县| 高安市| 泰兴市| 乌兰浩特市| 内江市| 永顺县| 青阳县| 新建县| 奈曼旗| 巴南区| 利津县| 丘北县| 蛟河市| 郓城县| 香格里拉县| 伊金霍洛旗| 越西县| 都匀市| 耿马|