断点

每天进步一点点!
posts - 174, comments - 56, trackbacks - 0, articles - 21

一:WebLogic配置问题:
由于WebLogic的配置问题,我们的系统运行出现了失败情况。原因是为WebLogic分配的内存太少了。通过修改commom\bin\commEnv.cmd文件来增加内存分配。
修改的部分如下:
:bea
if "%PRODUCTION_MODE%" == "true" goto bea_prod_mode
set JAVA_VM=-jrockit
set MEM_ARGS=-Xms768m -Xmx1024m
set JAVA_OPTIONS=%JAVA_OPTIONS% -Xverify:none
goto continue
:bea_prod_mode
set JAVA_VM=-jrockit
set MEM_ARGS=-Xms768m -Xmx1024m   //原来是128M~256M,太小了,数据太大
goto continue
结果修改后,没有效果。还是有失败的情况。
发现,原来,在:bea下面还有一段配置信息如下:
:
sun
if "%PRODUCTION_MODE%" == "true" goto sun_prod_mode
set JAVA_VM=-client
set MEM_ARGS=-Xms768m -Xmx1024m -XX:MaxPermSize=256m
set JAVA_OPTIONS=%JAVA_OPTIONS% -Xverify:none
goto continue
:sun_prod_mode
set JAVA_VM=-
server
set MEM_ARGS=-Xms768m -Xmx1024m -XX:MaxPermSize=256m
goto continue


将这里的内存分配修改后见效。
原因是,上面对第一段代码是为bea自己的JVM设置的,下面的是为Sun的设置的。而WebLogic默认的是Sun的,所以出了毛病。

,domain中的相关配置:
  1,
修改bea\user_projects\domains\base_domain\bin\setDomainEnv.cmd文件.
  2,
修改如下几个位置:以下蓝色部分是需修改的内存大小

     set MEM_ARGS=-Xms256m -Xmx512m   @
最主要将这两个值改大,这是此域启动后,虚拟机可使用的内存

     if "%JAVA_VENDOR%"=="Sun" (           @
使用sun服务器开发模式下的JVM配置
         if "%PRODUCTION_MODE%"=="" (
              set MEM_DEV_ARGS=-XX:CompileThreshold=8000 -XX ermSize=48m
          )
      )

    if "%JAVA_VENDOR%"=="Sun" (            @
使用sun服务器生产模式下的JVM配置
           set MEM_ARGS=%MEM_ARGS% %MEM_DEV_ARGS% -XX:MaxPermSize=128m
    )
   if "%JAVA_VENDOR%"=="HP" (               @
使用hp服务器生产模式下的JVM配置
        set MEM_ARGS=%MEM_ARGS% -XX:MaxPermSize=128m
   )

posted @ 2010-05-30 15:45 断点 阅读(1383) | 评论 (0)编辑 收藏

weblogic在运行一段时间后,出现以下的错误:
<2010-5-28 上午11时46分17秒 CST> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@
1b0d235 - appName: 'rules', name: 'rules', context-path: '/rules'] Root cause of ServletException.
java.lang.OutOfMemoryError: PermGen space
>


解决方法:
重新启动weblogic,系统恢复正常。


这里以tomcat环境为例,其它WEB服务器如jboss,weblogic等是同一个道理。

 一、java.lang.OutOfMemoryError: PermGen space PermGen space的全称是Permanent Generation space,是指内存的永久保存区域, 这块内存主要是被JVM存放Class和Meta信息的,Class在被Loader时就会被放到PermGen space中, 它和存放类实例(Instance)的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对 PermGen space进行清理,所以如果你的应用中有很多CLASS的话,就很可能出现PermGen space错误, 这种错误常见在web服务器对JSP进行pre compile的时候。如果你的WEB APP下都用了大量的第三方jar, 其大小超过了jvm默认的大小(4M)那么就会产生此错误信息了。

 解决方法: 手动设置MaxPermSize大小修改TOMCAT_HOME/bin/catalina.sh 在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行: JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m

 建议:将相同的第三方jar文件移置到tomcat/shared/lib目录下,这样可以达到减少jar 文档重复占用内存的目的。


 二、java.lang.OutOfMemoryError: Java heap space Heap size 设置 JVM堆的设置是指java程序运行过程中JVM可以调配使用的内存空间的设置.JVM在启动的时候会自动设置Heap size的值,其初始空间(即-Xms)是物理内存的1/64,最大空间(-Xmx)是物理内存的1/4。可以利用JVM提供的-Xmn -Xms -Xmx等选项可进行设置。Heap size 的大小是Young Generation 和Tenured Generaion 之和。提示:在JVM中如果98%的时间是用于GC且可用的Heap size 不足2%的时候将抛出此异常信息。提示:Heap Size 最大不要超过可用物理内存的80%,一般的要将-Xms和-Xmx选项设置为相同,而-Xmn为1/4的-Xmx值。

 解决方法:手动设置Heap size 修改TOMCAT_HOME/bin/catalina.sh 在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行: JAVA_OPTS="-server -Xms800m -Xmx800m -XX:MaxNewSize=256m"


 三、实例,以下给出1G内存环境下java jvm 的参数设置参考:
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "


 四、 可以配置下Tomcat。
修改TOMCAT_HOME/bin/tomcat6w.exe 双击打开,在“Java "下设置如下:
Initial memory pool:768 MB
Maximum memory pool:1024 MB
Thread stack size:64KB


Java 堆 - 这是 JVM 用来分配 java 对象的内存。
如果JVM不能在java堆中获得更多内存来分配更多java对象,将会抛出java内存不足(java.lang.OutOfMemoryError)错误。默认情况下,应用程序崩溃。
本地内存 - 这是 JVM 用于其内部操作的内存。
如果 JVM 无法获得更多本地内存,它将抛出本地内存不足(本地 OutOfMemoryError)错误。当进程到达操作系统的进程大小限值,或者当计算机用完 RAM 和交换空间时,通常会发生这种情况。
进程大小 - 进程大小将是 java 堆、本地内存与加载的可执行文件和库所占用内存的总和。在 32 位操作系统上,进程的虚拟地址空间最大可达到 4 GB。从这 4 GB 内存中,操作系统内核为自己保留一部分内存(通常为 1 - 2 GB)。剩余内存可用于应用程序。

posted @ 2010-05-30 15:34 断点 阅读(642) | 评论 (0)编辑 收藏

--项目中的用法。
1、StringUtils.join
List dwVoListInTab = this.prodService.getPicTabVOList(picId);
List dwNameListInTab = new ArrayList();
        for (PrdTabVO dwVo : dwVoListInTab) {
          String dwName = this.prodService.cvtTabNo2DWName(useProdNo, picId,
            dwVo.getCTabNo());
          dwNameListInTab.add(dwName);
          dwNameMap.put(dwVo.getCNmeEn(), dwName);
        }
        ((List)plyDwNameList).addAll(dwNameListInTab);

String dwNameListStr = "['" + StringUtils.join(dwNameListInTab.toArray(), "','") + "']";
其它:
StringUtils.join(new String[]{"cat","dog","carrot","leaf","door"}, ":")
// cat:dog:carrot:leaf:door

2、StringUtils.isNotEmpty    //Checks if a String is not empty ("") and not null.

if (StringUtils.isNotEmpty(onload)) 
          onload = sub.replace(onload);
        else {
          onload = "";
        }

public String replace(char oldChar,char newChar)返回一个新的字符串,它是通过用 newChar 替换此字符串中出现的所有 oldChar 得到的。
如果 oldChar 在此 String 对象表示的字符序列中没有出现,则返回对此 String 对象的引用。

3、StringUtils.equals    //StringUtils.equals(null, null)   = true
 if (!StringUtils.equals(prodKindNo, "00")) {
}

4、StringUtils.isBlank     //Checks if a String is whitespace, empty ("") or null.
if (StringUtils.isBlank(taskId))
        jsBuffer.append("var taskId='';\n");
      else {
        jsBuffer.append("var taskId='" + taskId + "';\n");
      }

 
5、StringUtils.leftPad(String str, int size,String padStr) --左填充
//投保年度【保险起期 - 初登年月】 单位:年
String ply_year = StringUtils.leftPad(String.valueOf(DateUtils.compareYear(regDate,base.getTInsrncBgnTm())), 2, '0'); 
 
/**
4260         * <p>Left pad a String with a specified String.</p>
4261         *
4262         * <p>Pad to a size of <code>size</code>.</p>
4263         *
4264         * <pre>
4265         * StringUtils.leftPad(null, *, *)      = null
4266         * StringUtils.leftPad("", 3, "z")      = "zzz"
4267         * StringUtils.leftPad("bat", 3, "yz")  = "bat"
4268         * StringUtils.leftPad("bat", 5, "yz")  = "yzbat"
4269         * StringUtils.leftPad("bat", 8, "yz")  = "yzyzybat"
4270         * StringUtils.leftPad("bat", 1, "yz")  = "bat"
4271         * StringUtils.leftPad("bat", -1, "yz") = "bat"
4272         * StringUtils.leftPad("bat", 5, null)  = "  bat"
4273         * StringUtils.leftPad("bat", 5, "")    = "  bat"
4274         * </pre>
4275         *
4276         * @param str  the String to pad out, may be null
4277         * @param size  the size to pad to
4278         * @param padStr  the String to pad with, null or empty treated as single space
4279         * @return left padded String or original String if no padding is necessary,
4280         *  <code>null</code> if null String input
4281         */
4282        public static String leftPad(String str, int size, String padStr) {
4283            if (str == null) {
4284                return null;
4285            }
4286            if (isEmpty(padStr)) {
4287                padStr = " ";
4288            }
4289            int padLen = padStr.length();
4290            int strLen = str.length();
4291            int pads = size - strLen;
4292            if (pads <= 0) {
4293                return str; // returns original String when possible
4294            }
4295            if (padLen == 1 && pads <= PAD_LIMIT) {
4296                return leftPad(str, size, padStr.charAt(0));
4297            }
4298   
4299            if (pads == padLen) {
4300                return padStr.concat(str);
4301            } else if (pads < padLen) {
4302                return padStr.substring(0, pads).concat(str);
4303            } else {
4304                char[] padding = new char[pads];
4305                char[] padChars = padStr.toCharArray();
4306                for (int i = 0; i < pads; i++) {
4307                    padding[i] = padChars[i % padLen];
4308                }
4309                return new String(padding).concat(str);
4310            }
4311        }


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


详见:http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html

isEmpty
public static boolean isEmpty(CharSequence str)
Checks if a String is empty ("") or null.

 StringUtils.isEmpty(null)      = true
StringUtils.isEmpty("")        = true
StringUtils.isEmpty(" ")       = false
StringUtils.isEmpty("bob")     = false
StringUtils.isEmpty("  bob  ") = false

NOTE: This method changed in Lang version 2.0. It no longer trims the String. That

functionality is available in isBlank().

 

Parameters:
str - the String to check, may be null
Returns:
true if the String is empty or null


isNotEmpty
public static boolean isNotEmpty(CharSequence str)
Checks if a String is not empty ("") and not null.

 StringUtils.isNotEmpty(null)      = false
StringUtils.isNotEmpty("")        = false
StringUtils.isNotEmpty(" ")       = true
StringUtils.isNotEmpty("bob")     = true
StringUtils.isNotEmpty("  bob  ") = true

 

Parameters:
str - the String to check, may be null
Returns:
true if the String is not empty and not null


isBlank
public static boolean isBlank(CharSequence str)
Checks if a String is whitespace, empty ("") or null.

 StringUtils.isBlank(null)      = true
StringUtils.isBlank("")        = true
StringUtils.isBlank(" ")       = true
StringUtils.isBlank("bob")     = false
StringUtils.isBlank("  bob  ") = false

 

Parameters:
str - the String to check, may be null
Returns:
true if the String is null, empty or whitespace
Since:
2.0


isNotBlank
public static boolean isNotBlank(CharSequence str)
Checks if a String is not empty (""), not null and not whitespace only.

 StringUtils.isNotBlank(null)      = false
StringUtils.isNotBlank("")        = false
StringUtils.isNotBlank(" ")       = false
StringUtils.isNotBlank("bob")     = true
StringUtils.isNotBlank("  bob  ") = true

 

Parameters:
str - the String to check, may be null
Returns:
true if the String is not empty and not null and not whitespace
Since:
2.0


trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null by

returning null.

The String is trimmed using String.trim(). Trim removes start and end characters <= 32.

To strip whitespace use strip(String).

To trim your choice of characters, use the strip(String, String) methods.

 StringUtils.trim(null)          = null
StringUtils.trim("")            = ""
StringUtils.trim("     ")       = ""
StringUtils.trim("abc")         = "abc"
StringUtils.trim("    abc    ") = "abc"

 

Parameters:
str - the String to be trimmed, may be null
Returns:
the trimmed string, null if null String input


trimToNull
public static String trimToNull(String str)
Removes control characters (char <= 32) from both ends of this String returning null if

the String is empty ("") after the trim or if it is null.

The String is trimmed using String.trim(). Trim removes start and end characters <= 32.

To strip whitespace use stripToNull(String).

 StringUtils.trimToNull(null)          = null
StringUtils.trimToNull("")            = null
StringUtils.trimToNull("     ")       = null
StringUtils.trimToNull("abc")         = "abc"
StringUtils.trimToNull("    abc    ") = "abc"

 

Parameters:
str - the String to be trimmed, may be null
Returns:
the trimmed String, null if only chars <= 32, empty or null String input
Since:
2.0


trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty

String ("") if the String is empty ("") after the trim or if it is null.

The String is trimmed using String.trim(). Trim removes start and end characters <= 32.

To strip whitespace use stripToEmpty(String).

 StringUtils.trimToEmpty(null)          = ""
StringUtils.trimToEmpty("")            = ""
StringUtils.trimToEmpty("     ")       = ""
StringUtils.trimToEmpty("abc")         = "abc"
StringUtils.trimToEmpty("    abc    ") = "abc"

 

Parameters:
str - the String to be trimmed, may be null
Returns:
the trimmed String, or an empty String if null input
Since:
2.0
equals
public static boolean equals(String str1,
String str2)
Compares two Strings, returning true if they are equal.

nulls are handled without exceptions. Two null references are considered to be equal. The

comparison is case sensitive.

 StringUtils.equals(null, null)   = true
StringUtils.equals(null, "abc")  = false
StringUtils.equals("abc", null)  = false
StringUtils.equals("abc", "abc") = true
StringUtils.equals("abc", "ABC") = false

 

Parameters:
str1 - the first String, may be null
str2 - the second String, may be null
Returns:
true if the Strings are equal, case sensitive, or both null
See Also:
String.equals(Object) 
 
startsWith
public static boolean startsWith(String str,
String prefix)
Check if a String starts with a specified prefix.

nulls are handled without exceptions. Two null references are considered to be equal. The

comparison is case sensitive.

 StringUtils.startsWith(null, null)      = true
StringUtils.startsWith(null, "abc")     = false
StringUtils.startsWith("abcdef", null)  = false
StringUtils.startsWith("abcdef", "abc") = true
StringUtils.startsWith("ABCDEF", "abc") = false

 

Parameters:
str - the String to check, may be null
prefix - the prefix to find, may be null
Returns:
true if the String starts with the prefix, case sensitive, or both null
Since:
2.4
See Also:
String.startsWith(String)


1.去除尾部换行符,使用函数:StringUtils.chomp(testString)
函数介绍:去除testString尾部的换行符
例程:
String input = "Hello\n";  
System.out.println( StringUtils.chomp( input ));  
String input2 = "Another test\r\n";  
System.out.println( StringUtils.chomp( input2 )); 

输出如下:
    Hello
    Another test


2.判断字符串内容的类型,函数介绍:
StringUtils.isNumeric( testString ) :如果testString全由数字组成返回True
StringUtils.isAlpha( testString ) :如果testString全由字母组成返回True
StringUtils.isAlphanumeric( testString ) :如果testString全由数字或数字组成返回True
StringUtils.isAlphaspace( testString ) :如果testString全由字母或空格组成返回True

例程:
String state = "Virginia";  
System.out.println( "Is state number? " + StringUtils.isNumeric(state ) );  
System.out.println( "Is state alpha? " + StringUtils.isAlpha( state ));  
System.out.println( "Is state alphanumeric? " +StringUtils.isAlphanumeric( state ) );  
System.out.println( "Is state alphaspace? " + StringUtils.isAlphaSpace( state ) ); 

输出如下:
    Is state number? false
    Is state alpha? true
    Is state alphanumeric? true
    Is state alphaspace? true


3.查找嵌套字符串,使用函数:
StringUtils.substringBetween(testString,header,tail)
函数介绍:在testString中取得header和tail之间的字符串。不存在则返回空
例程:
String htmlContent = "ABC1234ABC4567";  
System.out.println(StringUtils.substringBetween(htmlContent, "1234", "4567"));  
System.out.println(StringUtils.substringBetween(htmlContent, "12345", "4567")); 

输出如下:
    ABC
    null


4.颠倒字符串,使用函数:StringUtils.reverse(testString)
函数介绍:得到testString中字符颠倒后的字符串
例程:
System.out.println( StringUtils.reverse("ABCDE")); 

输出如下:
    EDCBA


5.部分截取字符串,使用函数:
StringUtils.substringBetween(testString,fromString,toString ):取得两字符之间的字符串
StringUtils.substringAfter( ):取得指定字符串后的字符串
StringUtils.substringBefore( ):取得指定字符串之前的字符串
StringUtils.substringBeforeLast( ):取得最后一个指定字符串之前的字符串
StringUtils.substringAfterLast( ):取得最后一个指定字符串之后的字符串

函数介绍:上面应该都讲明白了吧。
例程:
String formatted = " 25 * (30,40) [50,60] | 30";  
System.out.print("N0: " + StringUtils.substringBeforeLast( formatted, "*" ) );  
System.out.print(", N1: " + StringUtils.substringBetween( formatted, "(", "," ) );  
System.out.print(", N2: " + StringUtils.substringBetween( formatted, ",", ")" ) );  
System.out.print(", N3: " + StringUtils.substringBetween( formatted, "[", "," ) );  
System.out.print(", N4: " + StringUtils.substringBetween( formatted, ",", "]" ) );  
System.out.print(", N5: " + StringUtils.substringAfterLast( formatted, "|" ) ); 

输出如下:
    N0: 25 , N1: 30, N2: 40, N3: 50, N4: 40) [50,60, N5: 30

posted @ 2010-05-30 10:46 断点 阅读(613) | 评论 (0)编辑 收藏

MethodUtils的简单用法。

package com.ztf;

import java.util.Map;

import org.apache.commons.beanutils.MethodUtils;
import org.apache.commons.beanutils.PropertyUtils;

public class TestMethodUtils {  
        
public static void main(String[] args) throws Exception{  
              
            Entity entity 
= new Entity();  
            entity.setId(
1) ;
            entity.setName(
"断点");
            
           
// 通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(无参的情况)
            MethodUtils.invokeMethod(entity, "sayHello"null);  
              
            
// 通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(1参的情况)
            MethodUtils.invokeMethod(entity, "sayHello""断点");  
              
            
// 通过MethodUtils的invokeMethod方法,执行指定的entity中的方法(多参的情况)
            Object[] params = new Object[]{new Integer(10),new Integer(12)};  
            MethodUtils.invokeMethod(entity, 
"sayHello", params);  
        }
  
}
  

实体:
package com.ztf;

public class Entity {
    
private Integer id;
    
private String name;
    
    
public void sayHello(){
        System.out.println(
"sayHello()---> 无参");
    }

    
    
public void sayHello(String s){
        System.out.println(
"sayHello()---> 有1个参数" );
    }

    
    
public void sayHello(Integer a,Integer b){
        System.out.println(
"sayHello()---> 有2个参数");
    }

  
    
public String getName() {
        
return name;
    }

    
public void setName(String name) {
        
this.name = name;
    }

    
public Integer getId() {
        
return id;
    }

    
public void setId(Integer id) {
        
this.id = id;
    }

}


输出:
sayHello()---> 无参
sayHello()---> 有1个参数
sayHello()---> 有2个参数

posted @ 2010-05-30 10:01 断点 阅读(415) | 评论 (0)编辑 收藏

实体bean。
package com.ztf;

public class Entity {
    
private Integer id;
    
private String name;
    
    
public void sayHello(){
        System.out.println(
"sayHello()---> 无参");
    }

    
    
public void sayHello(String s){
        System.out.println(
"sayHello()---> 有1个参数" );
    }

    
    
public void sayHello(Integer a,Integer b){
        System.out.println(
"sayHello()---> 有2个参数");
    }

  
    
public String getName() {
        
return name;
    }

    
public void setName(String name) {
        
this.name = name;
    }

    
public Integer getId() {
        
return id;
    }

    
public void setId(Integer id) {
        
this.id = id;
    }

}


package com.ztf;
import java.util.Map;

import org.apache.commons.beanutils.MethodUtils;
import org.apache.commons.beanutils.PropertyUtils;

public class TestPropertyUtils {  
        
public static void main(String[] args) throws Exception{  
              
            Entity entity 
= new Entity();  
            entity.setId(
1) ;
            entity.setName(
"断点");
            
            
// 通过PropertyUtils的getProperty方法获取指定属性的值
            Integer id = (Integer)PropertyUtils.getProperty(entity, "id");  
            String name 
= (String)PropertyUtils.getProperty(entity, "name");  
            System.out.println(
"id = " + id + "  name = " + name);  
              
            
// 调用PropertyUtils的setProperty方法设置entity的指定属性
            PropertyUtils.setProperty(entity, "name""每天进步一点");  
            System.out.println(
"name = " + entity.getName());  
              
            
// 通过PropertyUtils的describe方法把entity的所有属性与属性值封装进Map中
            Map map = PropertyUtils.describe(entity);  
            System.out.println(
"id = " + map.get("id"+ "  name = " + map.get("name"));  
              
                  }
  
}
  

输出:
id = 1  name = 断点
name = 每天进步一点
id = 1  name = 每天进步一点


其它例子:
import org.apache.commons.beanutils.PropertyUtils;
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
for(BaseGrpMemberVO member : MemberVO){
          Map m = new HashMap();
          for(Map.Entry<String, String> entry: fieldMap.entrySet()){
                    String key = entry.getKey();
                    fieldList.add(key); //记录字段名
                    String[] keyArray = key.split("\\.");
                    if(keyArray.length == 2){//成员信息
                        Object o =PropertyUtils.getProperty(member, keyArray[1]);
                        m.put(key, o==null?"":o.toString());
                    }else if(keyArray.length == 3){//险别信息
                        List<BaseGrpCvrgVO> cvrgVoList = mgr.getRelCvrgById(member.getCPkId());
                        String cvrgNo = keyArray[0];
                        for(BaseGrpCvrgVO cvrgVo : cvrgVoList){
                            if(cvrgNo.equals(cvrgVo.getCCvrgNo())){
                                Object o =PropertyUtils.getProperty(cvrgVo, keyArray[2]);
                                m.put(key, o==null?"":o.toString());
                            }
                        }   
                    }
                }
          data.add(m);
       }

posted @ 2010-05-30 09:51 断点 阅读(533) | 评论 (0)编辑 收藏

apache.commons.beanutils.BeanUtils
该class提供了一系列的静态方法操作已存在的符合JavaBean规范定义的Java Class.这里强调的JavaBean规范,简单来说就是一个Java Class通过一系列getter和setter的方法向外界展示其内在的成员变量(属性)。

通过BeanUtils的静态方法,我们可以:
复制一个JavaBean的实例--BeanUtils.cloneBean();
在一个JavaBean的两个实例之间复制属性--BeanUtils.copyProperties(),BeanUtils.copyProperty();
为一个JavaBean的实例设置成员变量(属性)值--BeanUtils.populate(),BeanUtils.setProperty();
从一个JavaBean的实例中读取成员变量(属性)的值--BeanUtils.getArrayProperty(),BeanUtils.getIndexedProperty(),BeanUtils.getMappedProperty(),BeanUtils.getNestedProperty(),BeanUtils.getSimpleProperty(),BeanUtils.getProperty(),BeanUtils.describe();

1、BeanUtils.cloneBean(java.lang.object bean)
为bean创建一个clone对象,方法返回类型为Object.此方法的实现机制建立在bean提供的一系列的getters和setters的基础之上.此方法的正常使用代码非常简单,故略掉.

 

2、BeanUtils.copyProperties(java.lang.Object dest, java.lang.Object orig)
一个bean class有两个实例:orig和dest,将orig中的成员变量的值复制给dest,即将已经存在的dest变为orig的副本.与BeanUtils.cloneBean(java.lang.object bean)的区别就在于是不是需要创建新的实例了.
原文如下:Copy property values from the origin bean to the destination bean for all cases where the property names are the same.


3、BeanUtils.setProperty(java.lang.Object bean,java.lang.String name,java.lang.Object value)
这个方法简单的说就是将bean中的成员变量name赋值为value.


BeanUtils.populate(java.lang.Object bean, java.util.Map properties)
使用一个map为bean赋值,该map中的key的名称与bean中的成员变量名称相对应.注意:只有在key和成员变量名称完全对应的时候,populate机制才发生作用;但是在数量上没有任何要求,如map中的key如果是成员变量名称的子集,那么成员变量中有的而map中不包含的项将会保留默认值;同样,如果成员变量是map中key的子集,那么多余的key不会对populate的结果产生任何影响.恩,结果就是populate只针对map中key名称集合与bean中成员变量名称集合的交集产生作用。


4、BeanUtils.getArrayProperty(java.lang.Object bean,java.lang.String name)
获取bean中数组成员变量(属性)的值.
如果我们指定的name不是数组类型的成员变量,结果会如何?会不会抛出类型错误的exception呢?回答是不会,仍然会返回一个String的数组,数组的第一项就是name对应的值(如果不

是String类型的话,JVM会自动的调用toString()方法的).


BeanUtils.getIndexedProperty(java.lang.Object bean,java.lang.String name)
BeanUtils.getIndexedProperty(java.lang.Object bean,java.lang.String name,int index)
这两个方法都是获取数组成员变量(属性)中的单一元素值的方法.
比如,我想得到SampleObject中words[1]的值,用法如下:
BeanUtils.getIndexedProperty(sampleOjbectInstance,"words[1]");
BeanUtils.getIndexedProperty(sampleOjbectInstance,"words",1);


BeanUtils.getMappedProperty(java.lang.Object bean,java.lang.String name)
BeanUtils.getMappedProperty(java.lang.Object bean,java.lang.String name,java.lang.String key)


BeanUtils.describe(java.lang.Object bean)
将一个bean以map的形式展示。

来源:http://www.chinaitpower.com/A/2005-07-03/150232.html

posted @ 2010-05-30 09:25 断点 阅读(415) | 评论 (0)编辑 收藏

原因:在这两天的时间里,weblogic92把我很是郁闷了一把,原因是我本地的工程走业务流程没有问题,而到它上面去跑流程就是 处理失败!真正的问题就是2个jar包的有冲突,一样的class文件,名字分别为pcis_reinsure.jar、pcis_reinsure_open.jar 。在我提交svn的时候,把pcis_reinsure.jar删除了,把pcis_reinsure_open.jar 新增了,结果weblogic92的缓存中含有pcis_reinsure.jar、pcis_reinsure_open.jar 。

注:pcis_reinsure.jar 旧包、pcis_reinsure_open.jar 新包,其中一个类IRiskUnitService有方法divideRiskUnit,而另一个没有这个方法,所以老是提示
Caused by: java.lang.NoSuchMethodError: com..pcis.riskunit.service.IRiskUnitService.divideRiskUnit(L
com/isoftstone/pcis/policy/dm/bo/PolicyApplication;)V


解决:
在Tomcat中,我们知道%catalina_home%\work是存放缓存文件的地方,可以通过删除这里面的文件,让它重新编译,以便代码生效。

weblogic92的缓存文件存放在哪里呢? 
weblogic92的发布项目缓存临时文件路径是
D:\bea\user_projects\domains\nonvhl_policy\servers\AdminServer\tmp\_WL_user\nonvhl_policy\4huf50\war\WEB-INF\lib,在此路径下把pcis_reinsure.jar删除就可以了。

注意:
1、要停服务后再删除缓存文件,运行时它已经加载到内存了。

2、缓存只加载新增的文件,对于工程删除的jar文件它不做删除。

posted @ 2010-05-28 13:54 断点 阅读(7408) | 评论 (1)编辑 收藏

 

.
JAVA Memory arguments: -Xms512m -Xmx768m -XX:CompileThreshold=8000 -XX:PermSize=48m  -XX:MaxPermSize=256m
.
WLS Start Mode=Development
.
CLASSPATH=D:\bea\weblogic_crack.jar;;d:\bea\patch_weblogic920\profiles\default\sys_manifest_classpath\weblogic
_patch.jar;d:\bea\JDK150~1\lib\tools.jar;D:\bea\WEBLOG~1\server\lib\weblogic_sp.jar;D:\bea\WEBLOG~1\server\lib
\weblogic.jar;D:\bea\WEBLOG~1\server\lib\webservices.jar;;D:\bea\WEBLOG~1\common\eval\pointbase\lib\pbclient51
.jar;D:\bea\WEBLOG~1\server\lib\xqrl.jar;;
.
PATH=d:\bea\patch_weblogic920\profiles\default\native;D:\bea\WEBLOG~1\server\native\win\32;D:\bea\WEBLOG~1\ser
ver\bin;d:\bea\JDK150~1\jre\bin;d:\bea\JDK150~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;D:
\bea\WEBLOG~1\server\native\win\32\oci920_8
.
***************************************************
*  To start WebLogic Server, use a username and   *
*  password assigned to an admin-level user.  For *
*  server administration, use the WebLogic Server *
*  console at http:\\hostname:port\console        *
***************************************************
starting weblogic with Java version:
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode)
Starting WLS with line:
d:\bea\JDK150~1\bin\java -client   -Xms512m -Xmx768m -XX:CompileThreshold=8000 -XX:PermSize=48m  -XX:MaxPermSi
ze=256m  -Xverify:none  -da -Dplatform.home=D:\bea\WEBLOG~1 -Dwls.home=D:\bea\WEBLOG~1\server -Dwli.home=D:\be
a\WEBLOG~1\integration  -Dweblogic.management.discover=true  -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logE
rrorsToConsole= -Dweblogic.ext.dirs=d:\bea\patch_weblogic920\profiles\default\sysext_manifest_classpath -Dwebl
ogic.Name=AdminServer -Djava.security.policy=D:\bea\WEBLOG~1\server\lib\weblogic.policy   weblogic.Server
<2010-5-24 上午09时42分56秒 CST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory conten
ts added to the end of the classpath:
D:\bea\weblogic92\platform\lib\p13n\p13n-schemas.jar;D:\bea\weblogic92\platform\lib\p13n\p13n_common.jar;D:\be
a\weblogic92\platform\lib\p13n\p13n_system.jar;D:\bea\weblogic92\platform\lib\wlp\netuix_common.jar;D:\bea\web
logic92\platform\lib\wlp\netuix_schemas.jar;D:\bea\weblogic92\platform\lib\wlp\netuix_system.jar;D:\bea\weblog
ic92\platform\lib\wlp\wsrp-common.jar>
<2010-5-24 上午09时42分56秒 CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotS
pot(TM) Client VM Version 1.5.0_04-b05 from Sun Microsystems Inc.>
<2010-5-24 上午09时42分57秒 CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 9.2  Fri Jun 23 20
:47:26 EDT 2006 783464 >
<2010-5-24 上午09时43分00秒 CST> <Info> <WebLogicServer> <BEA-000215> <Loaded License : d:\bea\license.bea>
<2010-5-24 上午09时43分00秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
<2010-5-24 上午09时43分00秒 CST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool>
<2010-5-24 上午09时43分00秒 CST> <Notice> <Log Management> <BEA-170019> <The server log file D:\bea\user_proje
cts\domains\nonvhl_policy\servers\AdminServer\logs\AdminServer.log is opened. All server side log events will
be written to this file.>
<2010-5-24 上午09时43分00秒 CST> <Error> <Socket> <BEA-000438> <Unable to load performance pack. Using Java I/
O instead. Please ensure that wlntio.dll is in: 'd:\bea\JDK150~1\bin;.;C:\WINDOWS\system32;C:\WINDOWS;d:\bea\p
atch_weblogic920\profiles\default\native;D:\bea\WEBLOG~1\server\native\win\32;D:\bea\WEBLOG~1\server\bin;d:\be
a\JDK150~1\jre\bin;d:\bea\JDK150~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;D:\bea\WEBLOG~1
\server\native\win\32\oci920_8'
>
<2010-5-24 上午09时43分02秒 CST> <Notice> <Security> <BEA-090082> <Security initializing using security realm
myrealm.>
<2010-5-24 上午09时43分03秒 CST> <Critical> <Deployer> <BEA-149618> <Unable to deploy an internal management W
eb application - bea_wls_management_internal2. Managed servers may be unable to start.
weblogic.management.DeploymentException: weblogic.management.DeploymentException:
        at weblogic.deploy.internal.InternalAppProcessor.stageFilesAndCreateBeansForInternalApp(InternalAppPro
cessor.java:258)
        at weblogic.deploy.internal.InternalAppProcessor.updateConfiguration(InternalAppProcessor.java:196)
        at weblogic.management.deploy.internal.DeploymentServerService.init(DeploymentServerService.java:144)
        at weblogic.management.deploy.internal.DeploymentPreStandbyServerService.start(DeploymentPreStandbySer
verService.java:32)
        at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
        Truncated. see log file for complete stacktrace
java.util.zip.ZipException: Error opening file - D:\bea\WEBLOG~1\server\lib\bea_wls_management_internal2.war M
essage - 系统找不到指定的文件。
        at weblogic.servlet.utils.WarUtils.existsInWar(WarUtils.java:65)
        at weblogic.servlet.utils.WarUtils.isWar(WarUtils.java:44)
        at weblogic.servlet.internal.WarDeploymentFactory.findOrCreateComponentMBeans(WarDeploymentFactory.jav
a:54)
        at weblogic.application.internal.MBeanFactoryImpl.findOrCreateComponentMBeans(MBeanFactoryImpl.java:48
)
        at weblogic.application.internal.MBeanFactoryImpl.createComponentMBeans(MBeanFactoryImpl.java:110)
        Truncated. see log file for complete stacktrace
>
<2010-5-24 上午09时43分03秒 CST> <Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason:

There are 1 nested errors:

weblogic.management.provider.UpdateException: [Deployer:149616]A critical internal application bea_wls_managem
ent_internal2 was not deployed. Error: weblogic.management.DeploymentException:
        at weblogic.deploy.internal.InternalAppProcessor.handleErr(InternalAppProcessor.java:211)
        at weblogic.deploy.internal.InternalAppProcessor.updateConfiguration(InternalAppProcessor.java:198)
        at weblogic.management.deploy.internal.DeploymentServerService.init(DeploymentServerService.java:144)
        at weblogic.management.deploy.internal.DeploymentPreStandbyServerService.start(DeploymentPreStandbySer
verService.java:32)
        at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: java.util.zip.ZipException: Error opening file - D:\bea\WEBLOG~1\server\lib\bea_wls_management_inte
rnal2.war Message - 系统找不到指定的文件。
        at weblogic.servlet.utils.WarUtils.existsInWar(WarUtils.java:65)
        at weblogic.servlet.utils.WarUtils.isWar(WarUtils.java:44)
        at weblogic.servlet.internal.WarDeploymentFactory.findOrCreateComponentMBeans(WarDeploymentFactory.jav
a:54)
        at weblogic.application.internal.MBeanFactoryImpl.findOrCreateComponentMBeans(MBeanFactoryImpl.java:48
)
        at weblogic.application.internal.MBeanFactoryImpl.createComponentMBeans(MBeanFactoryImpl.java:110)
        at weblogic.application.inter

解决方法:
1、把自己以前安装的bea目录下的
D:\bea\WEBLOG~1\server\lib\bea_wls_management_internal2.war Message 文件重新复制一份放在当前bea下即可。

2、还有一种就是重新装下bea。

posted @ 2010-05-24 14:21 断点 阅读(3924) | 评论 (0)编辑 收藏

ArrayUtils类帮我们完成数组的打印、查找、克隆、倒序、以及值型/对象数组之间的转换等操作。

 1import org.apache.commons.lang.ArrayUtils;
 2
 3public class TestArrayUtils {
 4    
 5    public static void main(String[] args) {   
 6        /**
 7         * 打印数组中的内容
 8         */

 9        int[] intArray = new int[] 23456 };
10        int[][] multiDimension = new int[][] 123 }23 }{567} };
11        
12        System.out.println( "intArray: " + ArrayUtils.toString( intArray ) );
13        System.out.println( "multiDimension: " + ArrayUtils.toString( multiDimension ) );
14    }

15}

输出:
intArray: {2,3,4,5,6}
multiDimension: {{1,2,3},{2,3},{5,6,7}}

posted @ 2010-05-17 23:57 断点 阅读(221) | 评论 (0)编辑 收藏

 CollectionUtils 中四个方法对集合操作: union(),intersection(),disjunction();,subtract()。

 1import java.util.Arrays;     
 2import java.util.Collection;     
 3import java.util.Collections;     
 4import java.util.List;     
 5     
 6import org.apache.commons.collections.CollectionUtils;     
 7import org.apache.commons.lang.ArrayUtils;     
 8     
 9public class TestCollectionUtils {     
10 @SuppressWarnings("unchecked")     
11 public static void main(String[] args) {     
12  String[] arrayA = new String[] "1""2""3""3""4""5" };     
13  String[] arrayB = new String[] "3""4""4""5""6""7" };     
14     
15  List<String> a = Arrays.asList(arrayA);     
16  List<String> b = Arrays.asList(arrayB);     
17  // 并集
18  Collection<String> union = CollectionUtils.union(a, b);     
19  // 交集
20  Collection<String> intersection = CollectionUtils.intersection(a, b);     
21  // 交集的补集
22  Collection<String> disjunction = CollectionUtils.disjunction(a, b);     
23  // 集合相减
24  Collection<String> subtract = CollectionUtils.subtract(a, b);     
25     
26  Collections.sort((List<String>) union);     
27  Collections.sort((List<String>) intersection);     
28  Collections.sort((List<String>) disjunction);     
29  Collections.sort((List<String>) subtract);     
30     
31  System.out.println("A: " + ArrayUtils.toString(a.toArray()));     
32  System.out.println("B: " + ArrayUtils.toString(b.toArray()));     
33  System.out.println("--------------------------------------------");     
34  System.out.println("Union(A, B): " + ArrayUtils.toString(union.toArray()));     
35  System.out.println("Intersection(A, B): " + ArrayUtils.toString(intersection.toArray()));     
36  System.out.println("Disjunction(A, B): " + ArrayUtils.toString(disjunction.toArray()));     
37  System.out.println("Subtract(A, B): " + ArrayUtils.toString(subtract.toArray()));     
38 }
     
39}
   

输出:
A: {1,2,3,3,4,5}
B: {3,4,4,5,6,7}
--------------------------------------------
Union(A, B): {1,2,3,3,4,4,5,6,7}
Intersection(A, B): {3,4,5}
Disjunction(A, B): {1,2,3,4,6,7}
Subtract(A, B): {1,2,3}

转载:http://blog.csdn.net/ofofw/archive/2009/06/26/4300964.aspx

posted @ 2010-05-17 23:29 断点 阅读(616) | 评论 (0)编辑 收藏

仅列出标题
共18页: First 上一页 2 3 4 5 6 7 8 9 10 下一页 Last