2007年11月19日

          在IBM的JDK環境下進行JVM內存監控的問題

          錯誤信息如下:
          java.lang.NoClassDefFoundError: sun.management.ManagementFactory

          處理:

          sun.management.ManagementFactory替換成java.lang.management.ManagementFactory  

          因為ibmjdk沒有sun.management.ManagementFactory這個對象

          posted @ 2010-11-25 12:01 JGAO編程隨筆 閱讀(565) | 評論 (0)編輯 收藏

          oracel PreparedStatement的setString問題

          錯誤信息如下:

          超過最大長度限制

          處理:

          只能插入666個中文字符。


          或者更新到最新的
          oracle驅動包

          posted @ 2010-11-25 12:00 JGAO編程隨筆 閱讀(271) | 評論 (0)編輯 收藏

          servicemix部署到websphere中,需注意的問題

          1derby.jar包可能沖突,需刪除項目中的該包

          2MBean調用問題

             Websphere的MBean注冊路徑包括cell,nodeName和processName,具體可以銅鼓jconsole連接來查看MBean注冊的全路徑。這三個值可以通過Websphere的com.ibm.websphere.management.AdminServiceFactory這個對象來獲取,spring中的配置如下:
          <!-- 用于獲取websphereMBean名稱的cell,node,process -->

          <bean id="adminService" class="com.ibm.websphere.management.AdminServiceFactory" factory-method="getAdminService"/>

          <bean id="adminService.cellName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>

          <bean id="adminService.nodeName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>

          <bean id="adminService.processName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>

          <bean id="websphereNamingStrategy" class="com.des.engine.mbean.WebsphereNamingStrategy">

          <property name="cellName" ref="adminService.cellName"/>

          <property name="nodeName" ref="adminService.nodeName"/>

          <property name="processName" ref="adminService.processName"/>

          </bean>

          WebsphereNamingStrategy為自己創建的對象就包括那三個屬性

          3:安全問題

          出現如下錯誤,Caused by: javax.management.JMRuntimeException: ADMN0022E: 由于憑證不足或憑證為空,無法對 org.apache.servicemix:Name=ServiceMgtImpl,cell=dvpbNode02Cell,Type=SystemService,ContainerName=ServiceMix,node=dvpbNode02,process=server1 MBean  retrieveServiceList 操作進行訪問。

              該問題是因為設置了安全控制,把控制臺的【安全性->安全管理、應用程序和基礎結構】里面的所以安全配置都去掉,然后重新啟動服務器主機(注意是重啟主機,不然安全設置不起作用),再啟動websphere服務應該就可以了,還有就是servicemix的應用要跟websphere一起啟動,不要等websphere啟動后再到控制臺啟動

          posted @ 2010-11-25 11:58 JGAO編程隨筆 閱讀(892) | 評論 (2)編輯 收藏

          ResultSet內存溢出OutOfMemory問題

          錯誤信息如下:

          jdbc在操作oracle海量數據的時候用ResultSet獲取所有的返回數據出現內存溢出

          處理:
          出錯的原因是ResultSet用的是可滾動結果集,正常情況下ResultSet是指針指向數據庫的數據,本身是不存儲數據庫的數據的,默認情況下就算是提交的sql能查詢處上億條的數據也是不消耗內存的,但是如果用的是可滾動結果集的ResultSet情況就不一樣了,ORACLE 是不支持可滾動結果集的,那么我們用JDBC得到一個可滾動的結果集就是由JDBC自己支持的,也就是說結果集是要存放在內存中的,所以在海量數據的情況下也就是要消耗大量內存的,因此造成內存溢出也就是正常的了,所以如果是海量數據的話就不要用可滾動結果集就可以了。

          posted @ 2009-06-23 21:19 JGAO編程隨筆 閱讀(2114) | 評論 (0)編輯 收藏

          com.ibm.websphere.ce.cm.StaleConnectionException: [ibm][db2][jcc][t4][2030][11211] 檢測到了通信錯誤

          錯誤信息如下:

          com.ibm.websphere.ce.cm.StaleConnectionException: [ibm][db2][jcc][t4][2030][11211]

          檢測到了通信錯誤。所使用的通信協議:TCP/IP"n所使用的通信 APISOCKETS

          檢測到錯誤的位置:Reply.fill()"n用于檢測錯誤的通信功能:InputStream.read()

          特定于協議的錯誤代碼數據不足、 0。消息:null"n   

          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)"n     

          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)"n    at

          sun.reflect.DelegatingConstructorAccessorImpl.newInstance

          (DelegatingConstructorAccessorImpl.java:45)"n

          at java.lang.reflect.Constructor.newInstance(Constructor.java:522)"n  

          at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapExceptionHelper

          (GenericDataStoreHelper.java:523)"n   

          at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapException(GenericDataStoreHelper.java:578)"n      

          at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:909)"n 

          at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeQuery(WSJdbcStatement.java:898)"n   

          at com.newland.bi.util.db.DBUtil.executeQuery(Unknown Source)"n

          at com.newland.bi.util.db.DBUtil.executeSql(Unknown Source)"n     

          at com.newland.bi.dao.jdbc.DaoImpl.executeQuery(DaoImpl.java:64)"n   

          at com.newland.bi.service.report.exp.dao.ReportExpDao.getExpList(ReportExpDao.java:72)"n 

          at com.newland.bi.service.report.exp.manage.ReportExpMgt.runExport(ReportExpMgt.java:91)"n   

          at com.newland.bi.service.report.exp.servlet.ReportExp1Servlet$1.run(ReportExp1Servlet.java:97)"n      

          at java.util.TimerThread.mainLoop(Timer.java:537)"n       at java.util.TimerThread.run(Timer.java:487)"n

          處理:

          出錯的原因可能是防火墻問題,websphere應用服務器和數據庫服務器之間是否存在防火墻

          防火墻是否會設置多久沒活動的連接就自動斷開掉,如果是這樣的話就會有問題,因為websphere上面的數據庫連接池可能有一段時間沒連接而被防火墻斷掉了

          但對于連接池本身根本就不知道該連接是否還可用,所以web應用從連接池獲取的連接可能就是已經斷開的了,所以就可能會出現日記中的錯誤問題


           

          posted @ 2009-06-23 21:14 JGAO編程隨筆 閱讀(7429) | 評論 (1)編輯 收藏

          Timer.schedule和Timer.scheduleAtFixedRate的區別

          schedulescheduleAtFixedRate的區別在于,如果指定開始執行的時間在當前系統運行時間之前,scheduleAtFixedRate會把已經過去的時間也作為周期執行,而schedule不會把過去的時間算上。

          posted @ 2009-06-23 21:13 JGAO編程隨筆 閱讀(1003) | 評論 (0)編輯 收藏

          cxf找不到類org.apache.axis.soap.MessageFactoryImpl出錯

           

          錯誤信息如下:

          Caused by: java.lang.ClassNotFoundException: org.apache.axis.soap.MessageFactoryImpl

              at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

              at java.security.AccessController.doPrivileged(Native Method)

              at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

              at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

              at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:50)

              ... 10 more

          處理:

          原因是調用了axis soap.MessageFactoryImpl,cxf應該用的是sun
               在注冊安全攔截器之前執行下面代碼就可以了

          System.setProperty("javax.xml.soap.MessageFactory", "com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl");

          posted @ 2009-06-23 21:10 JGAO編程隨筆 閱讀(1282) | 評論 (0)編輯 收藏

          瀏覽器下載txt文件問題

          我們寫程序的時候可能會想用open或者<a>來下載一個txt文件,但我們會發現我們用瀏覽器下載這個txt文件的時候老是在瀏覽器里面直接打開了,而不是提示下載,這樣的話如果txt文件的內容非常多的話肯定是不行的,可能就會導致瀏覽器掛掉,客戶機器死機的問題
          現整理了個解決辦法,代碼如下:

          1.下載頁面
          open(action執行頁面,'iframeName','');
          2.action執行頁面
          <id="tempB" style="display:none" href="#" onclick="">&nbsp;</a>
          <iframe width=0 height=0 id="hideIframe" name="hideIframe"></iframe>
          <script>
              
          var n=0;
              
          function go(url){
                  
                  n
          ==0?new function()
                  
          {
                      frames(
          "hideIframe").location=url,n=1
                  }
          :null;
                  
                  document.all(
          "hideIframe").readyState!="complete"?setTimeout(go,10):so();
                  
                  
          function so()
                  
          {
                      frames(
          "hideIframe").document.execCommand("SaveAs"),n=0
                  }
          ;
              }

              
              
          var tempB = document.getElementById("tempB");
              
          <%
                  
          if(path.toLowerCase().indexOf(".txt")>=0){
              
          %>
              tempB.attachEvent('onclick',
          function(){go('<%=request.getContextPath()+"/tempfile/1.txt">');});
              
          <%
                  }
          else{
              
          %>
              tempB.attachEvent('onclick',
          function(){open('<%=request.getContextPath()+"/tempfile/1.xls">','','');});
              
          <%
                  }

              
          %>
              tempB.click();
          </script>


          posted @ 2008-11-23 19:28 JGAO編程隨筆 閱讀(760) | 評論 (0)編輯 收藏

          websphere部署war應用失敗

          websphere部署war應用失敗正常原因是web.xml的節點定義循序問題,或者一些空格,字符原因造成的
          可能先定義完所有的servlet后再定義所有的servlet mapping就沒問題了

          posted @ 2008-08-23 15:27 JGAO編程隨筆 閱讀(643) | 評論 (0)編輯 收藏

          通過jsf事件轉向后的頁面中文亂碼

          那個轉向后的頁面已經有用gb2312的編碼了
          可能原因是在java類里面調用了((HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse()).getWriter().write("");
          然后再轉向某個頁面,這樣可能導致編碼格式沖突,導致亂碼
          可以先給resonse設置下編碼格式,然后在write
          HttpServletResponse httpServletResponse = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
          httpServletResponse.setContentType("text/html; charset=gb2312");
          httpServletResponse.setCharacterEncoding("gb2312");
          httpServletResponse.getWriter().write("");
          這樣應該就可以解決了

          posted @ 2008-06-26 23:46 JGAO編程隨筆 閱讀(595) | 評論 (0)編輯 收藏

          websphere的servlet配置無效問題

          C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\app-bi2Node01Cell\applications\appname.ear\deployments\appname\appname.war\WEB-INF\web.xml 該目錄下的web.xml的修改才是有效

          應用程序發布的目錄下的那個web.xml添加的servlet配置是無效的

          posted @ 2008-04-28 18:06 JGAO編程隨筆 閱讀(1492) | 評論 (3)編輯 收藏

          jsp的request.getParameter獲取不到表單參數

          可能原因:

          1: form表單中的控件沒有定義name屬性

          2: form表單中的控件被設置成disabled

          3: form表單的enctype="multipart/form-data"是一種用于上傳文件的表單

          解決方法:

          對于第三種情況我們直接request.getParameter來取參數值是取不到的

          我們可以借用apache的上傳組件來解決

          用到jarcommons-fileupload-1.1.1.jar

          import org.apache.commons.fileupload.FileItem;

          import org.apache.commons.fileupload.FileItemFactory;

          import org.apache.commons.fileupload.FileUploadException;

          import org.apache.commons.fileupload.disk.DiskFileItemFactory;

          import org.apache.commons.fileupload.servlet.ServletFileUpload;

              /**

               *獲取各種類型表單的表單參數

               *@paramrequest HttpServletRequest請求對像

               * @paramparamName 參數名

               *@return

               *@throwsFileUploadException

               */

              publicstatic String getParameterValue(HttpServletRequest request,String paramName) throws FileUploadException{

              boolean isMultipart = ServletFileUpload.isMultipartContent(request);

              if(isMultipart==true){

                  FileItemFactory factory = new DiskFileItemFactory();

                  ServletFileUpload upload = new ServletFileUpload(factory);

                  List fileItemList = upload.parseRequest(request);

                  if(fileItemList!=null){

                     for(Iterator itr=fileItemList.iterator();itr.hasNext();){

                         FileItem fileItem = (FileItem)itr.next();

                         if(fileItem.getFieldName().equalsIgnoreCase(paramName)){

                             return new String(fileItem.getString().getBytes("ISO8859-1"))//中文轉碼

                         }

                     }

                  }

              }else{

                  return new String(request.getParameter(paramName).getBytes("ISO8859-1"))//中文轉碼

              }

              return"";

              }

          posted @ 2007-12-14 19:07 JGAO編程隨筆 閱讀(14905) | 評論 (6)編輯 收藏

          初學jsf自定義標簽時遇到的問題總結

          1.定義一個標簽要用到兩個java類,這個跟jsp的自定義標簽有點不一樣
            第一個類繼承UIComponentTag, 用于定義標簽的屬性和設置標簽的所有屬性值到控件的map屬性attributes或valueBinding中
            第二個類繼承UIInput或者UIOutput,用于渲染標簽的內容,真正打印標簽內容的地方就在這里
             
          2.這兩個類是怎么聯系的
           我們需要像定義jsf的bean的影射文件一樣,在faces-config.xml或者自己定義的xml文件里面定義第二個類
           如:
           
          <faces-config>
            
          <!--分頁標簽-->
            
          <component>
              
          <component-type>pageTag</component-type>
              
          <component-class>com.jsf.PageComponent</component-class>
            
          </component>
            
            
          </faces-config>
            然后第一個類要實現父類的一個方法 public String getComponentType();從這里返回一個字符串pageTag,這樣就跟第二個類聯系起來了

          3.標簽屬性的定義
            標簽屬性的定義一般都是可轉化為字符串的類型的,除非你還是用
          <%=rowList%>這種jsp賦值的方式
            別以為你定義的一個List類型的屬性可以用jsf的EL表達式可以直接賦值進來,EL表達式傳進來以后屬性接收的就是這一串EL表達式
            所以就是說你的屬性就是要字符串類型的

          4.那么jsf自定義標簽是怎么接收EL表達式綁定的列表的
           先通過父類的isValueReference(屬性值),來判斷該屬性的值是否是一個EL的表達式
           如果是則通過獲取綁定值得方式把真正的屬性的值設置到標簽父類的valueBinding對像中
           否則直接把屬性的值添加到標簽父類的attributes對像中
            if (isValueReference(屬性值)) {
              javax.faces.el.ValueBinding vb = Util.getValueBinding(value.toString());
              component.setValueBinding(name, vb); //component就是標簽對像,name就是標簽的屬性名稱
           } else {
              component.getAttributes().put(name, 屬性值);
           }

           這就是個設置屬性值的過程,可以在第1點說的第一個類里面的protected void setProperties(UIComponent component)方法
          5.現在知道標簽屬性值的作用了嗎
           是的標簽屬性值只不過是起個作用而已,而不是我們真正所要的值
           也就是說我們是不能從這些屬性中直接取值的
           
          6.那么我們怎么取屬性的真正的值呢
           可以先從第4點說的標簽父類的attributes對像中取值
           如果取不到值那就到標簽父類的valueBinding對像中取值
           說白了就是,通過第4步我們屬性的真正的值不是放在attributes就是在valueBinding中
           Object obj = component.getAttributes().get(name); //component就是標簽對像,name就是標簽的屬性名稱
           if (obj == null) {
             ValueBinding vb = component.getValueBinding(name);
             if (vb != null) {
              return vb.getValue(context);
             } else {
              return null;
             }
           }
           這個過程就是取屬性值的過程,在第1點說的第二個類里面進行
           
          7.現在屬性值也可以取到了,那么我們要怎么打印標簽的內容呢
            我們可以在第二個類的encodeBegin或者encodeEnd中進行
            public void encodeBegin(FacesContext context) throws IOException
            public void encodeEnd(FacesContext context) throws IOException
           
            取屬性值的過程也可以在這里進行,取完值后就是把值組裝到標簽內容的相應位置中就完了
            
            基本上就是這幾點

          posted @ 2007-11-21 19:21 JGAO編程隨筆 閱讀(2153) | 評論 (4)編輯 收藏

          ajax4jsf跟outputStream.write沖突?

          我在項目中引入ajax4jsf框架
          web.xml中加入

           <filter>
                  
          <display-name>Ajax4jsf Filter</display-name>
                  
          <filter-name>ajax4jsf</filter-name>
                  
          <filter-class>org.ajax4jsf.Filter</filter-class>
            
          </filter>
            
          <filter-mapping> 
                
          <filter-name>ajax4jsf</filter-name>
                
          <servlet-name>Faces Servlet</servlet-name>
                
          <dispatcher>REQUEST</dispatcher>
                
          <dispatcher>FORWARD</dispatcher>
                
          <dispatcher>INCLUDE</dispatcher>
           
          </filter-mapping>


          結果以前的輸出文件到客戶端的代碼就出問題了

                          InputStream fileInputStream = mgt.downloadToStream(result_pathEl.getTextTrim());
                          mgt.deleteFile(result_pathEl.getTextTrim());
          //刪除臨時的報表文件
                          JSFUtil.setSessionAttribute(sessionId, "true");
                          
          if( fileInputStream == null ){
                            System.out.println(
          "==========get inputstream is null========");
                          }


                          OutputStream o 
          = response.getOutputStream();
                          response.reset();
                          response.setContentType( 
          "APPLICATION/OCTET-STREAM" );
                          response.setHeader( 
          "Content-Disposition""attachment;filename=\"" + "exportExcel.xls""\"" );

                          
          int length;
                          
          byte buf[] = new byte[1024];

                          
          while ( ( length = fileInputStream.read( buf, 01024 ) ) != -1 ) {
                              o.write( buf, 
          0, length );
                          }

                          o.flush();
                          o.close();
                          fileInputStream.close();


          提示錯誤如下:主要是o.write出問題

          java.lang.NullPointerException
                  at org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper$By
          teArrayServletOutputStream.write(FilterServletResponseWrapper.java:290)


          把web.xml中的ajax4jsf的filter給去掉后,一切又恢復正常

          有那位仁兄遇到同樣情況的嗎?

          posted @ 2007-11-19 20:16 JGAO編程隨筆 閱讀(451) | 評論 (1)編輯 收藏

          <2007年11月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 安国市| 北京市| 九龙县| 从化市| 崇信县| 横山县| 双鸭山市| 孝感市| 辽阳市| 平南县| 鸡西市| 昭平县| 鄂温| 托克托县| 达日县| 锡林浩特市| 股票| 成安县| 金乡县| 望谟县| 炉霍县| 怀化市| 婺源县| 南召县| 海口市| 武鸣县| 田阳县| 泰来县| 广南县| 射阳县| 西贡区| 三亚市| 左权县| 青铜峡市| 雅安市| 河北省| 嘉祥县| 兴仁县| 张北县| 蛟河市| 德保县|