2005/11/07
[Troubleshooting] Apache HTTP Server cannot start
有些時候,可能因為改了某些設定,如修改httpd.conf之後無法正常啟動
[Solution]
此時你可以執行Test Configuration來看錯誤訊息
開始→程式集→Apache HTTP Server→Configure Apache Server→Test Configuration
2005/11/03
2005/11/01
[Info] Two Approaches to Open New Window
這裡有一個link: from JavaWorld
除此之外, 用icon, 與用File/New/Window, 後者可能會有一些問題, 可參考此link:experts-exchange
2005/10/31
[Troubleshooting] SQLException: IO 異常: The Network Adapter could not establish the connection
SQLException: IO 異常: The Network Adapter could not establish the connection
成因
1. 資料庫沒有開啟, 所以無法連接上
2. 因為防火牆的原因, 該台連不上DBMS Server, 可先ping看看可否ping的到, ex. ping xxx.xxx.xxx.xxx 1521
2005/10/30
[Troubleshooting] 530 Sorry, no ANONYMOUS access allowed
用Server-U架起一個FTP Server,建立username=ftp, password=ftptest
此時用其他的ftp連線工具連線的時候,會出現此錯誤訊息: 530 Sorry, no ANONYMOUS access allowed
原因
因為ftp是保留字,不可以將其當成username,要將username改成其他名字即可
2005/10/28
[Info] JavaMail
Here has a reference link:
Sending Email with Spring mail abstraction layer
Here has sample code which write by me:
package albert.guo.util;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
/**
*
* @author Albert
*
*/
public class MailUtil {
private String addr[];
private String subject;
private String text;
private String host;
private String filepath;
private String filename;
private ArrayList fileList;
public MailUtil(String iAddr[], String iSubject, String iText, String iHost){
this.addr = iAddr;
this.subject = iSubject;
this.text = iText;
this.host = iHost;
}
public MailUtil(String iAddr[], String iSubject, String iText, String iHost,
ArrayList iFileList){
this.addr = iAddr;
this.subject = iSubject;
this.text = iText;
this.host = iHost;
this.fileList = iFileList;
}
/*
* 發送mail(不含附加檔案)
*/
public void sendMsg(){
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(this.addr);
msg.setSubject(this.subject);
msg.setText(this.text);
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(this.host);
mailSender.send(msg);
}
/*
* 發送mail(含附加檔案)
*/
public void sendMsgAndAttachment(){
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost(this.host);
MimeMessage message = sender.createMimeMessage();
try {
//use the true flag to indicate you need a multipart message
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setTo(this.addr);
helper.setSubject(this.subject);
helper.setText(this.text);
for(int i=0; i<this.fileList.size(); i++){
HashMap attachment = (HashMap)fileList.get(i);
String filepath = (String)attachment.get("filepath");
String filename = (String)attachment.get("filename");
helper.addAttachment(filename, new File(filepath+filename));
}
sender.send(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String addr[] = new String [] {"albertg@systex.com.tw"};
//MailUtil mailUtil = new MailUtil(addr, "標題", "內容\n啦啦啦", "mail.systex.com.tw");
//mailUtil.sendMsg();
ArrayList list = new ArrayList();
HashMap hm1 = new HashMap();
hm1.put("filepath", "C:/");
hm1.put("filename","test.doc");
HashMap hm2 = new HashMap();
hm2.put("filepath", "C:/");
hm2.put("filename", "LiveABC.Log");
list.add(hm1);
list.add(hm2);
MailUtil mailUtil = new MailUtil(addr, "標題", "內容\n啦啦啦", "mail.systex.com.tw",
list);
mailUtil.sendMsgAndAttachment();
}
}
2005/10/24
2005/10/20
[Troubleshoot] JDBC Connection Leak
在JSP中設定ErrorPage時,發生跳轉,來不及關閉連線
程式的錯誤處理非在finally區塊關閉連線
緩解方式
設定InactiveConnectionTimeoutSeconds時間
最終一定要修復程式中的問題
2005/10/07
[Info] 如何在IE中直接打開WORD等文件
如何在一个WEB APPLICATION中打開WORD,EXCEL等類型的文件?
ans.
為了讓能在IE流覽器中自動打開的設置:需要在WEB.XML中進行如下的設置:在WEB.XML中添加<mime-mapping>,其中:
<extension>:
文件的副檔名
<mime-type>:
除了該類型檔的可執行檔,同WINDOW註冊表中的
/HKEY_CLASSES_ROOT下該類檔的Content
Type 的值一樣.
如能在IE中自動打開DOC,XLS,PDF檔的配置如下:
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun
Microsystems, Inc.//DTD Web Application 1.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<mime-mapping>
<extension>doc</extension>
<mime-type>application/msword</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xls</extension>
<mime-type>application/msexcel</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
</web-app>
2005/09/28
[Troubleshooting] Too many open files
<2005/9/27 上午09時32分13秒 GMT+08:00> <Critical> <WebLogicServer> <BEA-000204>
<Failed to listen on port 7001, failure count: 2,204, failing for 31,398
seconds, java.net.SocketException: Too many open files>
A.
大致上來說,這個問題有可能導因於OS的設定、應用程式在處理IO的時候,沒有正確關閉stream,以致於這些讀取檔案系統的stream一直處於開啟的狀態,最後就把系統所允許的file數給耗盡了。另外,如果在應用程式中開啟了一些socket,沒有正確關閉,也會發生相同的狀況 。這些關閉IO、socket的指令,一定要放在finally的區塊裡面,以確保即使發生exception,還是會被執行到。
We may increase the rlimit for a process by increasing the rlim_fd_max value (e.g. set rlim_fd_max = 4096) on /etc/system and enlarge the default open file number with ulimit -n 4096.
However, if we still find the open file limit for the java process that hosts WebLogic Server cannot excceed 1024,
please edit '${WL_HOME}/common/bin/commEnv.sh'.
COMMENT OUT the last line and add an ulimit statement (e.g. ulimit -n 8192)in the startup scripts.//resetFd
[Troubleshooting] Cannot Find WebappContextListener
Ans.此成因在於工程師可能採用workshop IDE tool來進行ap的開發,然後要部署到basic weblogic server此template,所以會有找不到此class的情形
此時,你只要把web.xml裡頭的此段拿掉即可,此為Workshop IDE Tool自行加上的
<listener>
<listener-class>
com.bea.wlw.runtime.core.servlet.WebappContextListener
</listener-class>
</listener>
2005/09/23
[Info] JDK vs. J2SDK
JDK 1.0 版於 1996 年初release,JDK 1.1 版於 1997 年初release,JDK 1.2 版於 1998 年底release。基於市場行銷的考量,Sun 在 JDK 1.2 版release後將 Java 改名為「Java 2」,將 JDK 改名為「Java 2 Software Development Kit(以下簡稱 J2SDK)」。
然而,雖然改了名字,但是其內在還是沒有變化,其仍舊包含了Java Development kit(JDK)、Java Runtime Environment(JRE),這兩者的差異是:JDK是for programmer所使用,JRE則是提供Java程式運行的環境。
2005/09/13
[Troubleshooing] BEA-101083
####<2005/9/12 下午07時52分46秒 GMT+08:00> <Error> <HTTP> <rx2620e1> <uat01>
<ExecuteThread: '1' for queue: 'weblogic.socket.Muxer'> <<WLS Kernel>> <> <BEA-101083> <Connection failure.
java.lang.Throwable: Error in poll for fd=328, revents=8
at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:128)
at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
>
reference link
DESCRIPTION:
Enhancement Request.
Running WLS 8.1 SP2 on HPUX11i.
Customer has requested an enhancement.
The customer wants to suppress (not print) the following error:
<May 25, 2004 10:05:11 PM GMT> <Error> <HTTP> <BEA-101083>
<Connection failure.java.net.SocketException: Error in poll for fd=81, revents=8
at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:128)
at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
This message unnecessarily fills up their log.
This exception can be thrown if their client / browser initiated multiple requests (sockets were opened) and the client connections were closed before WLS could process the requests (and could not write to the stream any more).
This is a harmless message (unnecessary message).
2005/09/08
2005/09/07
[troubleshooting] [EJB:010207]License validation not passed for 2.0
Module Name: QueueTransportEJB, Error: Exception preparing module: EJBModule(QueueTransportEJB,status=NEW)
Unable to deploy EJB: /bea/weblogic81/server/lib/QueueTransportEJB.jar from QueueTransportEJB.jar:
java.lang.Exception: [EJB:010207]License validation not passed for 2.0.'
因為客戶的版本是express的版本(不含EJB Container),但是其在create domain的時候,使用sample此template(有EJB的code),改採server此temaplte來create即可
[How-To] memory allocation for WLS
%JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -ms512m -mx512m -Dweblogic.Name=%SERVER_NAME% -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" weblogic.Server
512的地方可以replace成你想要的memory的量