2006/03/28

Simplify XML processing with VTD-XML

Summary
As the enabling technology for next-generation Web-based applications, XML is both easy and straightforward to learn and use. Unfortunately, the same thing cannot be said about the current state of XML processing: the Document Object Model and the Simple API for XML are both too slow, inefficient, and difficult to use. Providing a broadly useful and advanced option that goes beyond DOM and SAX, VTD-XML is the next-generation XML processing model that simplifies both XML programming and selection of an XML processing model. By highlighting some of the key technical strengths of VTD-XML using the latest performance benchmark numbers and code examples, this article demonstrates that VTD-XML has the potential to finally take the "monkey" off the back of enterprise architects constantly struggling with the decision of whether to use DOM or SAX.

http://www.javaworld.com/javaworld/jw-03-2006/jw-0327-simplify.html

2006/03/24

Log4j example

**here has four examples about how to utilize log4j.

the core of log4j is log4j.properties, we can do some configuration in this property files, including log message format, output file name, appender

setting and so on.

1. com.ptc.demo.log4j.module1.Module1Test: write log information to console
2. com.ptc.demo.log4j.module2.Module2Test: write log information to log files and rotate the log file by day
3. com.ptc.demo.log4j.module3.Module3Test: write log information to log files and rotate the log file by file size
4. com.ptc.demo.log4j.module4.Module4Test: write log information to log file (in HTML format)


---------------------
output message
---------------------
2006-03-24 13:50:03,015 DEBUG com.ptc.demo.log4j.module1.Module1Test.sortByAsc(Module1Test.java:26) - [ant, cat, dog, dophin, tiger, zebra]
2006-03-24 13:50:03,015 DEBUG com.ptc.demo.log4j.module1.Module1Test.sortByDesc(Module1Test.java:41) - [zebra, tiger, dophin, dog, cat, ant]



log4j.properties
=========================================================================
#module1 -- output to console
log4j.category.com.ptc.demo.log4j.module1=DEBUG,module1
log4j.appender.module1=org.apache.log4j.ConsoleAppender
log4j.appender.module1.layout=org.apache.log4j.PatternLayout
log4j.appender.module1.layout.ConversionPattern=%d %5p %l - %m%n


#module2 -- output to log and rotate by day
log4j.category.com.ptc.demo.log4j.module2=DEBUG,module2
log4j.appender.module2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.module2.threshold=debug
log4j.appender.module2.File=C:\module2.log
log4j.appender.module2.DatePattern='.'yyyyMMdd
log4j.appender.module2.Append=true
log4j.appender.module2.layout=org.apache.log4j.PatternLayout
log4j.appender.module2.layout.ConversionPattern=%d %5p %l - %m%n


#module3 -- output to log and rotate by file size
log4j.category.com.ptc.demo.log4j.module3=DEBUG,module3
log4j.appender.module3=org.apache.log4j.RollingFileAppender
log4j.appender.module3.threshold=debug
log4j.appender.module3.File=C:\module3.log
#rotate size = 500 KB
log4j.appender.module3.MaxFileSize=500KB
#keep three backup files
log4j.appender.module3.MaxBackupIndex=3
log4j.appender.module3.layout=org.apache.log4j.PatternLayout
log4j.appender.module3.layout.ConversionPattern=%d %5p %l - %m%n


#module4 -- output to log and by HTML format
log4j.category.com.ptc.demo.log4j.module4=DEBUG,module4
log4j.appender.module4=org.apache.log4j.FileAppender
log4j.appender.module4.File=C:\module4.html
log4j.appender.module4.Append=true
log4j.appender.module4.layout=org.apache.log4j.HTMLLayout
=========================================================================


class file (each class file has the same content and only has different class name)
=========================================================================
package com.ptc.demo.log4j.module1;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Collections;

import org.apache.log4j.Logger;

/**
*
* @author Albert
*
*/
public class Module1Test {

private static Logger logger = Logger.getLogger(Module1Test.class.getName());

/**
* sorting by ascending
* @param str
*/
public void sortByAsc(String str[]){
List list = Arrays.asList(str);
Collections.sort(list);
logger.debug(list);
}

/**
* sorting by descending
* @param str
*/
public void sortByDesc(String str[]){
List list = Arrays.asList(str);
Collections.sort(list, new Comparator(){
public int compare(Object obj1, Object obj2){
return ((String)obj2).compareTo((String)obj1);
}
}
);
logger.debug(list);
}

/**
* @param args
*/
public static void main(String[] args) {
Module1Test module1Test = new Module1Test();

String str[] = new String[]{"dog","ant","zebra","cat","tiger","dophin"};
module1Test.sortByAsc(str);
module1Test.sortByDesc(str);
}

}
=========================================================================

2006/03/23

Exception Handling

The following are some of the generally accepted principles of exception handling:

1. If you can’t handle an exception, don’t catch it.
2. If you catch an exception, don’t swallow it.
3. Catch an exception as close as possible to its source.
4. Log an exception where you catch it, unless you plan to rethrow it.
5. Structure your methods according to how fine-grained your exception handling must be.
6. Use as many typed exceptions as you need, particularly for application exceptions.


"Best Practices in EJB Exception Handling"
http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html

"Best Practices for Exception Handling"
http://www.onjava.com/pub/a/onjava/2003/11/19/exceptions.html

"Designing with Exceptions"
http://www.javaworld.com/jw-07-1998/jw-07-techniques.html

"Exceptions in Java"
http://www.javaworld.com/jw-07-1998/jw-07-exceptions.html

"Exceptional Practices, Part 1"
http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-exceptions.html

"Exceptional Practices, Part 2"
http://www.javaworld.com/javaworld/jw-09-2001/jw-0914-exceptions.html

"When catching exceptions, don't cast your net too wide"
http://www.javaworld.com/javaworld/javatips/jw-javatip134.html

"Use nested exceptions"
http://www.javaworld.com/javaworld/javatips/jw-javatip91.html

"Beware the dangers of generic exceptions"
http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-generics.html

[Info] Abator: code generator for iBATIS

Abator is a code generator for iBATIS. Abator will introspect a database table (or many tables) and will generate iBATIS artifacts that can be used to access the table(s). This lessens the initial nuisance of setting up objects and configuration files to interact with database tables. Abator seeks to make a major impact on the large percentage of database operations that are simple CRUD (Create, Retrieve, Update, Delete). You will still need to hand code SQL and objects for custom queries, or stored procedures.


http://ibatis.apache.org/abator.html

2006/03/14

Plug memory leaks in enterprise Java applications

Strategies for detecting and fixing enterprise memory leaks

Summary
Because Java uses automatic garbage collection, developers think Java programs are free from possible memory leaks. Although automatic garbage collection solves the main cause of memory leaks, they can remain in a Java program. Specifically, such memory leaks in complex multitiered applications can be extremely daunting to detect and plug. This article analyzes the main causes of memory leaks in Java Enterprise Edition (Java EE) applications, and suggests strategies for detecting them. (3,200 words; March 13, 2006)

By Ambily Pankajakshan

http://www.javaworld.com/javaworld/jw-03-2006/jw-0313-leak.html

2006/01/13

[Troubleshooting] The deployment framework was unable to register with the Data Replication Service

Description
Deployer:149204]The deployment framework was unable to register with the Data Replication Service.


Resolution
確認一下,在/etc/hosts裡頭是否有127.0.0.1 localhost
若無,請加上127.0.0.1 localhost
並且需重開機才能生效

2005/12/28

[Troubleshooting] MailSendException: Could not send mails: 501 illegal character(s) in domain string

[Scenario]
As I wrote a Java code, and used JavaMail to send email. But it threw this kind of exception message:
org.springframework.mail.MailSendException: Could not send mails: 501 : illegal character(s) in domain string

[Solution]
Because the computer's host name is Big5, so it will throw this kind of exception. This problem had been resolved, as I change my host name to English, and restart my computer.

2005/12/22

[Info] MaxPermSize and how it relates to the overall heap

MaxPermSize and how it relates to the overall heap

Many people have asked if the MaxPermSize value is a part of the overall -Xmx heap setting or additional to it. There is a GC document on the Sun website which is causing some confusion due to a somewhat vague explanation and an errant diagram. The more I look at this document, the more I think the original author has made a subtle mistake in describing -Xmx as it relates to the PermSize and MaxPermSize.

First, a quick definition of the "permanent generation".

"The permanent generation is used to hold reflective data of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations." [ref]



Yes, PermSize is additional to the -Xmx value set by the user on the JVM options. But MaxPermSize allows for the JVM to be able to grow the PermSize to the amount specified. Initially when the VM is loaded, the MaxPermSize will still be the default value (32mb for -client and 64mb for -server) but will not actually take up that amount until it is needed. On the other hand, if you were to set BOTH PermSize and MaxPermSize to 256mb, you would notice that the overall heap has increased by 256mb additional to the -Xmx setting.

So for example, if you set your -Xmx to 256m and your -MaxPermSize to 256m, you could check with the Solaris 'pmap' command how much memory the resulting process is taking up.

i.e.,

$ uname -a
SunOS devnull 5.8 Generic_108528-27 sun4u sparc
SUNW,UltraSPARC-IIi-cEngine

$ java -version
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)

---------------------------------------------
$ java -Xms256m -Xmx256m -XX:MaxPermSize=256m Hello &
$ pmap 6432
6432: /usr/java1.3.1/bin/../bin/sparc/native_threads/java -Xms256m -Xmx256m

total 288416K
---------------------------------------------
Notice above that the overall heap is not 256m+256m yet? Why? We did not specify PermSize yet, only MaxPermSize.


---------------------------------------------
$ java -Xms256m -Xmx256m -XX:PermSize=256m -XX:MaxPermSize=256m Hello &
$ pmap 6472
6472: /usr/java1.3.1/bin/../bin/sparc/native_threads/java -Xms256m -Xmx256m

total 550544K
---------------------------------------------

Now we see the overall heap grow, -Xmx+PermSize. This shows conclusive proof that PermSize and MaxPermSize are additional to the -Xmx setting.


Link

2005/12/13

[Troubleshooting] Managed Server cannot boot after password of admin user has been changed from admin console

DESCRIPTION:
If you change the password of the admin user from the admin console without running managed servers, the managed servers cannnot boot because of an authentication error of the admin user.

Resolution:
Security data e.g., password) is stored in the Embedded LDAP by default and it is replicated from the admin server to the managed servers. If there is an inconsistency of the security data between the admin and managed servers, the error will occur.
In order to refresh all replicated data at boot time, you need to set 'Refresh Replica At Startup' from the Admin Console. You can set this property by following the following steps in the Admin console:
Domain --> Security --> Embedded LDAP Server.

2005/12/04

[Info] Spring PropertyPlaceholderConfigurer

How many times have you been on a project, and people are talking about where to share configuration data?

Do I use some constants? What about a config file (XML, properties, etc)?

Sometimes it isn't easy to know what to do, and you sometimes end up with duplicate information.

For example, what if you want to share database information between your code, your ant build, and anything else?

With Spring, you can use their really nice PropertyPlaceholderConfigurer, and easily share a properties file. You can simply share one properties file for all of your build info as well as Spring sharing, or you can of course seperate things out, and have multiple 's in your build script.

So, the steps for sharing the data:......

http://www.almaer.com/blog/archives/000449.html

2005/11/29

[novelty] lipstick indicator & Lipstick Theory

lipstick indicator
An indicator based on the theory that a consumer turns to less-expensive indulgences, such as lipstick, when she (or he) feels less than confident about the future. Therefore, lipstick sales tend to increase during times of economic uncertainty or a recession.


Lipstick Theory

This theory is also applied in medical industry.
"The Lipstick Theory: When a woman who is battling cancer starts to put on lipstick, she is on the road to recovery."
- William Cahan, M.D., Memorial Sloan Kettering Cancer Center

2005/11/23

Is Ajax gonna kill the web frameworks?

The Java eco system has zillions of web frameworks from JSF, Tapestry, Struts, WebWork, Spring WebFlow to things like JSP/JSTL/Velocity etc. There's probably a new web framework born every day in Java some place.

However if the world really does go Ajax or some kinda client technology very Ajax like - will that cause these traditional HTML/HTTP web frameworks to become legacy?

Web frameworks spend most of their time doing things like, dealing with HTTP and HTML, maintaining client side state on the server - handing intermediate form submissions & validation, templating/rendering issues and binding business objects to HTML form controls etc.

These days Ajax has template engines, XPath/XSLT engines, SOAP stacks, XForms implementations and so forth all done on the client side. You can do clever things like hide the JavaScript from your HTML page and use CSS to bind the JavaScript to the markup.

There's even a JavaScript version of Ruby on Rails that runs in the browser! :)

So is the web application of the future going to be static HTML & JavaScript, served up by Apache with Ajax interacting with a bunch of XML based web services (maybe using SOAP, maybe just REST etc)? If so, do we really need a web framework thats focussed on HTTP and HTML, or are we just gonna end up developing a bunch of XML based web services and letting Ajax do all the templating, editing and viewing?

Is this the end of web frameworks as we know it?

http://radio.weblogs.com/0112098/2005/11/16.html

2005/11/12

[Info] Linux 常用指令

殺光folder下所有檔案
rm -rf

解開tar檔到特定folder下
tar xvf project.tar -C

看目前的process
ps -ef

重開機
init 6

檢視Log
tail -f

解開gz檔
tar -zxvf jrockit-70sp5-j2se131-linux32.tar.gz

[Troubleshooting] java.lang.SecurityException: Unable to locate a login configuration

Environment
RedHet Enterprise Linux 2.1
WLS 6.1
Service Pack 7
JRocket 1.4

Problem
As I would like to startup weblogic, it will show this kind of error message
java.lang.SecurityException: Unable to locate a login configuration
at com.ibm.security.auth.login.ConfigFile.getAppConfigurationEntry(ConfigFile.java:221)
at javax.security.auth.login.LoginContext.init(LoginContext.java:171)
at javax.security.auth.login.LoginContext.(LoginContext.java:318)
at weblogic.security.internal.ServerAuthenticate.main(ServerAuthenticate.java:81)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:200)
at weblogic.Server.main(Server.java:35)

Solution
You can check this file http://www.genuitec.com/products/JDK14_WLS61.pdf
Owing to the certified JDK version in WLS 6.1 is 1.3, the JDK version is 1.4

2005/11/11

[Info] Java Performance Tuning

http://www.javaperformancetuning.com/

[Info] WebLogic Server End-of-Life Calendar

You can check this link to ensure your product's status:
WebLogic Server End-of-Life Calendar


If it was retired, BEA do not provide technical support any more.

[Info] Hardware Capacity Management How-To

When you examine performance, a number of factors influence how much capacity a given hardware configuration will need in order to support WebLogic Server and a given application. The hardware capacity required to support your application depends on the specifics of the application and configuration. You should consider how each factor applies to your configuration and application.

Before continuing with this section, you may want to review the Standard Performance Evaluation Corporation which provides a set of standardized benchmarks and metrics for evaluating computer system performance.

2005/11/07

[Troubleshooting] Apache HTTP Server cannot start

[Scenario]
有些時候,可能因為改了某些設定,如修改httpd.conf之後無法正常啟動

[Solution]
此時你可以執行Test Configuration來看錯誤訊息
開始→程式集→Apache HTTP Server→Configure Apache Server→Test Configuration

2005/11/01

[Info] Comparing Web Frameworks Struts, Spring MVC, WebWork, Tapestry & JSF

File Type:PDF
Comparing Web Frameworks Struts, Spring MVC, WebWork, Tapestry & JSF

[Info] Two Approaches to Open New Window

按icon與用File/New/Window的動作不一樣, 按Icon的話, 是起一個新的session, 後者的話, 是share同一個session
這裡有一個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

Scenario
用Server-U架起一個FTP Server,建立username=ftp, password=ftptest
此時用其他的ftp連線工具連線的時候,會出現此錯誤訊息: 530 Sorry, no ANONYMOUS access allowed

原因
因為ftp是保留字,不可以將其當成username,要將username改成其他名字即可

2005/10/28

[Info] JavaMail

Spring Framework also provide an abstract layer for 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/20

[Troubleshoot] JDBC Connection Leak

資料庫連線洩漏原因

在JSP中設定ErrorPage時,發生跳轉,來不及關閉連線
程式的錯誤處理非在finally區塊關閉連線



緩解方式

設定InactiveConnectionTimeoutSeconds時間
最終一定要修復程式中的問題

2005/10/07

[Info] 如何在IE中直接打開WORD等文件

Q.
如何在一个WEB APPLICATION中打開WORD,EXCEL等類型的文件?

ans.

為了讓能在IE流覽器中自動打開的設置:需要在WEB.XML中進行如下的設置:在WEB.XML中添加<mime-mapping>,其中:


<extension>:
文件的副檔名

<mime-type>:
除了該類型檔的可執行檔,WINDOW註冊表中的

/HKEY_CLASSES_ROOT下該類檔的Content
Type
的值一樣.

如能在IE中自動打開DOCXLSPDF檔的配置如下:

<?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

Q.

<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

Q.為什麼我在佈署我的程式的時候,一直出現無法找到com.bea.wlw.runtime.core.servlet.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其實是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

[Info] 檢查有無安裝JVM

http://java.com/zh_tw/download/windows_automatic.jsp

[Troubleshooing] BEA-101083

exception message
####<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/07

[troubleshooting] [EJB:010207]License validation not passed for 2.0

exception msg
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

關於memory allocation,你要加在此行(位於script file的下半部):
%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的量

[How-To] Capacity Estination

http://www.spec.org/

http://e-docs.bea.com/wls/docs81/capplan/capbase.html#1055436

[info] Linux Tuning Parameters Tuning

http://e-docs.bea.com/wls/docs81/perform/HWTuning.html#1121228

Java2005專業技術大會 Slide

http://www.javatwo.net/Event/j2/2005/download/index.html

[troubleshooting] admin console密碼更改的問題

關於admin console的帳號密碼更改的問題,在admin console所變更的密碼,其不會同步更新到boot.properties這個file,所以,如果有變更密碼,就需要重新編輯此檔案(boot.properties)。

[troubleshooting] how to retrieve client's IP if WLS had plugin apache

For non-clustered servers that will receive proxied requests, this attribute may be set at the server level, on the Server -->Configuration-->General tab-->Advanced Options
把server instance的這個值enable起來,然後server要restart

reference: domain_cluster_config_general.html

[troubleshooting] Connection has already been created in this tx context for pool

scenario:
database:mysql
They had two mysql database connections. The first one is used to read data, and the second one is used to write data into another database. And they also check "Emulate Two-Phase Commit for non-XA driver" this option, but it still does not work.

Exception in context_onAcquire
java.sql.SQLException: Connection has already been created in this tx context for pool named dbsvr1_mysql. Illegal attempt to create connection from another pool: wssvr1_wsclub


According to the exception message, it means you can't use more than one non-XA connection pool in distributed transaction.
If you want to implement one user control calling two DB controls, you will have one transaction using two connections at the same time.
Only an XA transaction with 2PC support can do the job. You need to use XA driver.

I searched for the doc MYSQL, and find MYSQL 5.1 will support XA. But unfortunately, now the latest version of MYSQL is 5.0.
I think there's no good method on weblogic side which can handle the two connection pools with two non-xa drivers condition.

http://e-docs.bea.com/wls/docs81/faq/JTA.html#738373

2005/08/25

[troubleshooting] Resolve Too Many Open Files

Resolve Too Many Open Files

Troubleshooting Guidance Support Diagnostic Patterns

之前一直發現rlim_fd_max這個值始終都是預設的1024這個值,並不是user設定後的值,原來是在啟動的時候,他會去跑commEvn.sh裡頭的resetFd()這個function,裡頭會把值還原成1024,把它comment掉就好了。

[troubleshooting] WLS 8.1 亂碼解決方法

http://www.ddvip.net/program/java/index6/281.htm

in web.xml add:
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>BIG5</param-value>
</context-param>


in weblogic.xml add:
<jsp-descriptor>
<jsp-param>
<param-name>compileCommand</param-name>
<param-value>javac</param-value>
</jsp-param>
<jsp-param>
<param-name>compilerSupportsEncoding</param-name>
<param-value>true</param-value>
</jsp-param>
<jsp-param>
<param-name>encoding</param-name>
<param-value>BIG5</param-value>
</jsp-param>
</jsp-descriptor>

2005/08/15

Smartly load your properties

Link

Example
Assume I have a property file which named config, and this file locate at src/albert.
This file contains two values:
name=albert
email=junyuo@gmail.com

Then you can utilize this approach to read this property file

InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("albert/config.properties");
PropertyResourceBundle rb = new PropertyResourceBundle(is);
System.out.println("name="+rb.getString("name"));
System.out.println("email="+rb.getString("email"));

2005/07/02

0B0-104(BEA 8.1 Certified Administrator)考試心得

0B0-104考試簡介
 
此項考試的全名是:BEA 8.1 Certified Administrator : System Administration,考試代號是0B0-104。考試題數共69題,時間120分鐘,通過比率66%,報名費5000元。考試的詳細資訊請參考此網址:http://www.bea.com.tw/07services/techdoc/07services_03_04.htm
 
 

0B0-104考試報名

如果你之前參加透過Prometric舉辦的考試,考試ID仍舊可以沿用,無須重新申請。報名的話,可以打電話去報名(08001611141),告訴對方你的考試ID、要報名的考試科目名稱、考試時間、考試地點即可。

 
0B0-104 Study Guide

http://certification.bea.com/certification/study_guide
/System_Administration_11_12_04.htm,此link有告訴你此考試的準備方向,參考書籍以及模擬考題。JavaRanch此論壇的此thread也有針對此考試有一些在準備上的討論:http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=61&t=001195
 

0B0-104考試心得

考試的題型只有兩種:單選題與拖拉題。就整個考試內容來說,著重於幾個部份:Cluster, Performance Tuning, JMS, LDAP與Security, Application Deployment, JMS, Node Manager及Network Channel。拖拉題只有三題:Sever Life-Cycle、Heuristic Transaction、JMS File Store Synchronization Write Policy解釋 : Disabled, Cache-Flush, Direct-Write

2005/03/18

java.util.MissingResourceException

Scenario:
I have a config.properties file. In this property file, it provides some information, such as jdbc driver url, user name, password, and so forth.
But as I wanna read this property file, it always throws this kind of exception message: java.util.MissingResourceException: Can't find bundle for base name config

How to resolve:
This root cause is not cannot find this property file. It does find this file, but the content in this file has something wrong.

This line is the snippet of the property file
ftp.type4.path=D:\batch\FTP_FILES\user_group
the problem is the slash direction, it should be
ftp.type4.path=D:/batch/FTP_FILES/user_group
or
ftp.type4.path=D:\\batch\\FTP_FILES\\user_group

Introduction to the Maverick Web Framework [by TSS]

TheServerSide.com - Introduction to Maverick

2005/03/15

Example for Struts+DisplayTag+Spring Framework

Example for Struts+DisplayTag+Spring Framework
Environment:Win XP Pro
App Server: Oracle 9i AS
DataBase: Oracle 9i
IDE Tool: JDeveloper 10g

Struts: http://jakarta.apache.org/struts
DisplayTag: http://displaytag.sourceforge.net
Spring Framework: http://www.springframework.org

Page Flow:

Sample Code: download

2005/01/24

An example to modify xml file by DOM

description: Assume we have a xml file, TaiwanTopTen20050121074140.xml, and we wanna do a little modification.

input file: TaiwanTopTen20050121074140.xml

source code:
1. ModifyXMLByDOM.htm
2. XMLUtil.htm

2005/01/23

An example to append a node to xml file by DOM

Description: Assume we have a xml file, TaiwanTopTen20050121073726.xml, and we would like to append a time elemnt at the end of the xml file.

Input:
1. TaiwanTopTen20050121073726.xml

Source Code:
1. AppendTimeToXMLByDom.htm
2. XMLUtil.htm

2005/01/21

An example to write xml file by JDOM

description: read an input file, TopTen.csv, from local machine, and write into a xml file which named TopTen.xml by JDOM

input file: TopTen.csv

source code:
1. WriteXMLByJDOM.htm
2. TimeUtil.htm
3. IOUtil.htm

2005/01/20

An example to write xml file by DOM

description: read an input file, TopTen.csv, from local machine, and write into a xml file which named TopTen.xml.

input file: TopTen.csv

source code:
1.WriteXMLByDOM.htm
2.IOUtil.htm

2005/01/09

IBM WebSphere and XML Certification Free Testing Promotion (January - June 2005)

The following criteria applies to this offer:

1. There are 2000 vouchers, each valued up to $175 USD, and applicable to the appended WebSphere and XML certification tests. Each voucher is valid worldwide and can be used as payment for an applicable test.

Each participating candidate can qualify up to 3 vouchers, each voucher applicable to a different test.


2. To qualify for a voucher, a candidate is required to be one of the first people to pass the aligning Pre-assessment/Sample Test between January 1, 2005 (12:00 a.m. Eastern Time) and April 30, 2005 (11:59 p.m. Eastern Time).

http://www-03.ibm.com/certify/news/20041220g.shtml

Spring+Hibernate培训ppt

http://www.gpowersoft.com/document/Framework.ppt

2004/12/29

Oracle JDeveloper 10g (10.1.3) Developer Preview now available

acle JDeveloper 10g is a world-class development environment for Java, Web services, XML, and SQL. The Oracle JDeveloper 10g (10.1.3) release adds many new features, including a new look and feel, a greatly improved coding environment, extensive refactoring options, J2EE 1.4/J2SE 5.0 support, and visual JSF development.

This is the most substantial and ground-breaking JDeveloper release in years. Some improvements, such as the enhanced user interface and the new Refactor menu, you will note right away. Others, like the new project structure for seamless team development and the way that refactoring integrates with source control, may take more time to discover. These and other improvements will become apparent as you work with this innovative release of JDeveloper.

http://www.oracle.com/technology/products/jdev/101/index.html

2004/12/08

A Java library for reading/writing Excel

http://sourceforge.net/projects/jexcelapi/

JExcelApi is a java library which provides the ability to read, write, and modify Microsoft Excel spreadsheets. This project mirrors the files on http://www.jexcelapi.org, which has been known to go down on occasion.

2004/11/30

c3p0:JDBC DataSources/Resource Pools

c3p0 is an easy-to-use library for augmenting traditional (DriverManager-based) JDBC drivers with JNDI-bindable DataSources, including DataSources that implement Connection and Statement Pooling, as described by the jdbc3 spec and jdbc2 standard extensio

http://sourceforge.net/projects/c3p0

Introducing Spring Framework

Author: Rod Johnson

You may have heard the buzz this summer around the Spring Framework. In this article, I'll try to explain what Spring sets out to achieve, and how I believe it can help you to develop J2EE applications.

Introducing Spring Framework

2004/11/28

What Management Is: How It Works and Why It's Everyone's Business

What Management Is: How It Works and Why It's Everyone's Business

Whether you're new to the field or a seasoned executive, this book will give you a firm grasp on what it takes to make an organization perform. It presents the basic principles of management simply, but not simplistically. Why did an eBay succeed where a Webvan did not? Why do you need both a business model and a strategy? Why is it impossible to manage without the right performance measures, and do yours pass the test?

What Management Is is both a beginner's guide and a bible for one of the greatest social innovations of modern times: the discipline of management. Joan Magretta, a former top editor at the Harvard Business Review, distills the wisdom of a bewildering sea of books and articles into one simple, clear volume, explaining both the logic of successful organizations and how that logic is embodied in practice.

Magretta makes rich use of examples -- contemporary and historical -- to bring to life management's High Concepts: value creation, business models, competitive strategy, and organizational design. She devotes equal attention to the often unwritten rules of execution that characterize the best-performing organizations. Throughout she shows how the principles of management that work in for-profit businesses can -- and must -- be applied to nonprofits as well.

Most management books preach a single formula or a single fad. This one roams knowledgeably over the best that has been thought and written with a practical eye for what matters in real organizations. Not since Peter Drucker's great work of the 1950s and 1960s has there been a comparable effort to present the work of management as a coherent whole, to take stock of the current state of play, and to write about it thoughtfully for readers of all backgrounds. Newcomers will find the basics demystified. More experienced readers will recognize a store of useful wisdom and a framework for improving their own performance.

This is the big-picture management book for our times. It defines a common standard of managerial literacy that will help all of us lead more productive lives, whether we aspire to be managers or not.

Confronting Reality : Doing What Matters to Get Things Right

Editorial Reviews

Amazon.com
In their 2002 bestseller, Execution: The Discipline of Getting Things Done Larry Bossidy and Ram Charan identify why people don’t get results: they don’t execute. Bossidy and Charan are back with another stellar study on organizational behavior that shows how companies can succeed if they return to reality and examine every part of their business. Confronting Reality is based on a simple concept, but many companies approach strategy and execution in a surprisingly unreal manner and even the simplest of measurement methods, like the business model, are not applied correctly.
Cisco, 3M, KLM, Home Depot, and the Thomson Corporation are just a few of the companies that Bossidy and Charan examine. To demonstrate how to examine a business using the business model, Bossidy and Charan map out external variables, financial targets, internal activities, and an iteration stage (defined as a time to "make tradeoffs, apply and develop business savvy") to prove how a dynamically evolving business model will help improve performance.


"The version of the business model we have developed is a robust, reality-based process for thinking about the specifics of your business in a holistic way. It shows you how to tie together the financial targets you must meet, the external realities of your business and internal activities such as strategy development, operating tactics, and selection and development of people."
Larry Bossidy, retired chairman and CEO of Honeywell International and Ram Charan, author of What the CEO Wants You to Know and Profitable Growth Is Everyone's Business, have once again shed industrial-strength light on how to run a successful business. --E. Brooke Gilbert


link

Struts vs. JavaServer Faces

Author: Craig McClanahan


Introduction

It should come as no surprise that the most frequent questions I get asked center around the issue of which of these two web tier technologies an organization or individual developer should consider using. It makes sense to ask me, because I was the original creator of the Struts Framework, and was the co-specification lead for JavaServer Faces 1.0 (JSF).

Usually, the question is framed as an or issue, based on an understanding that the two technologies are mutually exclusive. That turns out not to be the case, but it can still be difficult to determine what to do. This blog entry provides my current advice on the subject -- but, to understand it better, it's worth briefly reviewing the development and focus of the two technologies.

The story is a little long compared to typical blog entries; if you want to cut to the chase and see my advice, scroll down to the section entitled The Bottom Line, below.


http://blogs.sun.com/roller/page/craigmcc/20040927

2004/11/24

display tag library

The display tag library is an open source suite of custom tags that provide high-level web presentation patterns which will work in an MVC model. The library provides a significant amount of functionality while still being easy to use.


http://displaytag.sourceforge.net/



You can directly study the displaytag.war, it must can shorten your learning curve.

Making Java Objects Comparable

by Budi Kurniawan
03/12/2003

In real life, objects are often comparable. For example, Dad's car is more expensive than Mom's, this dictionary is thicker than those books, Granny is older than Auntie Mollie (well, yeah, living objects, too, are comparable), and so forth. In writing object-oriented programs, there are often needs to compare instances of the same class. And once instances are comparable, they can be sorted. As an example, given two Employees, you may want to know which one has stayed in the organization longer. Or, in a search method for Person instances with a first name of Larry, you may want to display search results sorted by age. This article teaches you how to design your class to make its instances comparable by using the java.lang.Comparable and java.util.Comparator interfaces and presents three examples that illustrate both interfaces.

http://www.onjava.com/lpt/a/3286

2004/11/11

Book Recommendation: Profitable Growth Is Everyone's Business : 10 Tools You Can Use Monday Morning

Profitable Growth Is Everyone's Business : 10 Tools You Can Use Monday Morning

Book Description
The coauthor of the international bestseller Execution has created the how-to guide for solving today’s toughest business challenge: creating profitable growth that is organic, differentiated, and sustainable.

For many, growth is about “home runs”—the big bold idea, the next new thing, the product that will revolutionize the marketplace. While obviously attractive and lucrative, home runs don’t happen every day and frequently come in cycles.

Products like Kevlar, Teflon, and the Dell business model for selling personal computers may be once-in-a-decade phenomena. A surer and more consistent path to pro?table revenue growth is through “singles and doubles”—small day-to-day wins and adaptation to changes in the marketplace that build the foundation for substantially increasing revenues. The impact of singles and doubles can be huge. They are not only the basis for sustained revenue growth but, in fact, the foundation for home runs. Singles and doubles provide the discipline of execution, an absolute necessity for successfully bringing a breakthrough technology to market or implementing a new business model.

Inherent in this way of thinking is the revolutionary idea that growth is everyone’s business—not solely the concern of the sales force or top management. Just as everyone participates in cost reduction, so must everyone be engaged in the growth agenda of the business. Every contact of each employee with a customer is an opportunity for revenue growth. That includes everyone from the people working in a company’s call center handling customer inquiries and complaints to the CEO.

In this trailblazing book, Ram Charan provides the building blocks and tools that can put a business on the path to sustained, pro?table growth. For more than twenty-?ve years, Ram Charan has been working day in and day out with companies around the world. The ideas he has developed for solving the profitable revenue growth dilemma facing many businesses are based on personally seeing what works in real time. These are ideas that have been tested across industries and that deliver results, and they can be put to use starting Monday morning.

Book Recommendation: The Wal-Mart Decade: How a New Generation of Leaders Turned Sam Walton's Legacy into the World's #1 Company

The Wal-Mart Decade: How a New Generation of Leaders Turned Sam Walton's Legacy into the World's #1 Company

Book Description

Inside one of America's most remarkable success stories, from the bestselling author of Jack Welch and the G.E. Way.

Two of the toughest challenges for any company are leadership transitions and rapid growth. How do you replace an enormously popular and beloved CEO-especially one who started from scratch to create a national icon? And how do you maintain a rapid growth rate without losing the culture and focus of a small company?

Over the past ten years, since the death of the legendary Sam Walton, Wal-Mart has passed both challenges with flying colors. In 1992, it had revenues of $43.9 billion; now it's number one on the Fortune 500 list of America's largest companies, with revenues of $218 billion. Sam Walton's successors have taken the company into far-flung new markets and new directions yet without losing the down-to-earth retailing culture that made Wal-Mart thrive in its early years, when its business model was truly revolutionary.

Robert Slater, a highly respected business journalist and author, was granted unprecedented access to the company while writing The Wal-Mart Decade. He takes readers deep into the inner circle, where the big decisions are made about strategy and operations. And he weaves a fascinating, accessible story about the many challenges of the past decade and how Wal-Mart built on its founder's legacy to overcome them.

2004/10/17

[Book Recommendation] Game Theory and Economic Modelling

Game Theory and Economic Modelling (Clarendon Lectures in Economics S.)
by David M. Kreps


Product Description:
This book examines why game theory has become such a popular tool of analysis. It investigates the deficiencies in this methodology and goes on to consider whether its popularity will fade or remain an important tool for economists. The book provides the reader with some basic concepts from noncooperative theory, and then goes on to explore the strengths, weaknesses, and future of the theory as a tool of economic modelling and analysis. All those interested in the applications of game theory to economics, from undergraduates to academics will find this study of particular value.

2004/10/10

[Book Recommendation] Reengineering the Corporation: A Manifesto for Business Revolution

Reengineering the Corporation: A Manifesto for Business Revolution
by Michael Hammer (Author), James Champy (Author)


Book Description

No business concept was more important to America's economic revival in the 1990s than reengineering -- introduced to the world in Michael Hammer and James Champy's Reengineering the Corporation. Already a classic, this international bestseller describes how the radical redesign of a company's processes, organization, and culture can achieve a quantum leap in performance.

But if you think that reengineering once was enough, think again. More changes, more challenges are coming in the twenty-first century. Now Hammer and Champy have updated and revised their milestone work for the New Economy they helped to create -- promising to help corporations save hundreds of millions of dollars more, raise their customer satisfaction still higher, and grow ever more nimble in the years to come.

2004/10/06

[Book Recommendation] When Economics Mean Business

When Economics Mean Business: The New Economics of the Information Age
by Sultan Kermally



Editorial Reviews

The core of traditional management thinking is based on the foundations of traditional economic thinking. As economies shift from the industrial age to the informative age, the rules of economic engagement are undergoing radical change.


2004/09/28

An example to transfer object

Assume we have one value object which named "User".
It has two attributes, including userName and password.


public class User implements java.io.Serializable{
private String userName;
private String password;

public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

And we have one requirement to transfr this object to the specific receiver. Here has one picture to describe.

picture source: http://www.churchillobjects.com/c/11009.html


Then here has one sample to demo how to do this.

import java.io.ObjectOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class ObjectTransferExample {

//sender's method
public void send() throws SecurityException, IOException {
//declare one User object, and set data to userName and password attribute
User user = new User();
user.setUserName("Albert");
user.setPassword("123456789");

FileOutputStream out = new FileOutputStream("User");
ObjectOutputStream s = new ObjectOutputStream(out);
//write object name ans user object to ObjectOutputStream
s.writeObject("User");
s.writeObject(user);
s.flush();

}

//receiever's method
public void receieve() throws FileNotFoundException, IOException,
ClassNotFoundException, IOException {
FileInputStream in = new FileInputStream("User");
ObjectInputStream s = new ObjectInputStream(in);
//read the object name
String objectName = (String) s.readObject();
//retrieve the User object
User user = (User) s.readObject();
//print the object name and the User object's content
System.out.println("---------------------------------");
System.out.println("objectName="+objectName);
System.out.println("user name=" + user.getUserName());
System.out.println("password=" + user.getPassword());
System.out.println("---------------------------------");
}

public static void main(String[] args) throws IOException, SecurityException,
ClassNotFoundException, FileNotFoundException, IOException {
ObjectTransferExample example = new ObjectTransferExample();
example.send();
example.receieve();
}
}

An example to parse a xml file

the xml file content:download



abstract:
1. We need to parse the values which enclose in "username", "password", and "url" tags. And the three tags enclose in "application_server_setup"
2. We need to retireve the "name" attribute in "Form" tag
3. In each "Form" tag, it has some "Role" tags, we need to get the "name", and "sequence" atrribute in each "Role" tag



Sample code: ParseXML.java

2004/09/21

TOEIC Exam Information

I'm preparing for this certificat, if you'are interested about this exam,you can go to here, http://www.toeic.com.tw/, to gain the further information

2004/09/16

E-Mailing Through Java

This link has many useful example about JavaMail
--Sample Code to Send E-Mail
--Sample Code to Send Multipart E-Mail, HTML E-Mail and File Attachments
--Sample Code to Fetch E-Mail
--Useful Classes and Interfaces
--Steps to Use JavaMail
--Utility Classes
--Message Flags, and so forth

link: http://www.vipan.com/htdocs/javamail.html

2004/09/15

JavaMail quick start

http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-javamail_p.html

Spend some time to study this piece of information for a while, you can pick up the JavaMail API quickly.

Author
Tony Loton

Summary
In this article, Tony Loton shows the first steps on the road to building Java-based email applications. If you fancy building your own email client to replace Microsoft Outlook, or a Web-based email system to rival Hotmail, this is the place to start. And for a different perspective on JavaMail's possibilities, Tony presents a novel talking-email client application



[Sample Code]

import javax.mail.*;
import javax.mail.internet.*;

import java.util.*;

/**
* A simple email sender class.
*/
public class SimpleSender {

/**
* Main method to send a message given on the command line.
*/
public static void main(String args[]) {
try {
String smtpServer = "so-net.net.tw";
String to = "email address1, email address2";
String from = "email address";
String subject = "test";
String body = "JavaMail Test";

send(smtpServer, to, from, subject, body);
}
catch (Exception ex) {
System.err.println("Usage: java com.lotontech.mail.SimpleSender"
+
" smtpServer toAddress fromAddress subjectText bodyText");
}

System.exit(0);
}

/**
* "send" method to send the message.
*/
public static void send(String smtpServer, String to, String from
, String subject, String body) {
try {

Properties props = System.getProperties();

// -- Attaching to default Session, or we could start a new one --
props.put("mail.smtp.host", smtpServer);
Session session = Session.getDefaultInstance(props, null);

//create new mail
Message msg = new MimeMessage(session);
//sender
msg.setFrom(new InternetAddress(from));
//receiver
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
//email subject
msg.setSubject(subject);
//email content
msg.setText(body);
// -- Set some other header information --
msg.setHeader("X-Mailer", "LOTONtechEmail");
//send date
msg.setSentDate(new Date());

//send it
Transport.send(msg);

System.out.println("Message sent OK.");
}
catch (Exception ex) {
ex.printStackTrace();
}
}

}

2004/09/14

Write a Simple Program to Upload a File to FTP Server

download jar from here: http://www.jibble.org/simpleftp/
which named simpleftp.jar

Sample Code:

import org.jibble.simpleftp.SimpleFTP;
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;

public class SimpleFTPTest {
//connection information, including ip, port,
//user name and password
String ip = "10.64.203.69";
int port = 21;
String userName = "test";
String password = "fet";


public void upload() throws FileNotFoundException, IOException {

try {
SimpleFTP ftp = new SimpleFTP();
ftp.connect(ip, port, userName, password);
ftp.ascii();
ftp.cwd(remoteFile);
ftp.stor(new File("C:/odd.dat"));
ftp.disconnect();

}catch (IOException ioe) {
ioe.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) throws IOException {
SimpleFTPTest simpleFTP = new SimpleFTPTest();
simpleFTP.upload();
}
}

2004/09/09

軟體業沒希望! 台灣亟待痛定思痛

施振榮:40年來產值還非常小 一堆軟體公司賺不到錢

宏碁董事長施振榮19日罕見地對台灣軟體產業說了重話,施振榮表示,台灣硬體製造業發展至今22年,累積相當豐碩的國際成就,反觀軟體產業,40年下來產值還非常小,一堆軟體公司賺不到錢,這等於軟體產業沒有希望。

 施振榮19日應高科技產業資訊長協進會(CIO協進會)之邀,在台北以「深談微笑曲線」專題發表演講,施振榮表示,1992年當他提出「微笑曲線」時,製造本身附加價值不高,只能靠薄利多銷勉強維持,然而現階段對軟體而言,系統整合(SI)根本就是薄利少銷,爭取政府採購標案還被殺價,台灣有一堆軟體公司都賺不到錢,原因就在於軟體業的business model有很大的問題。

 針對施振榮對台灣軟體產業的看法,中華民國軟體協會秘書長張國鴻表示,施振榮說的是事實,台灣軟體業界應該要痛定思痛,早日走出國際市場。不過,張國鴻亦強調,台灣不能沒有軟體產業,尤其是硬體製造業毛利愈來愈低之後,就是軟體產業的機會。

 Linux產業促進會副會長劉龍龍則表示,如果認為台灣軟體產業未來沒有希望,就放棄軟體產業的投資與發展,非常可惜,因為現在做不好,並不表示未來也會做不好。劉龍龍認為,硬體業的成就,台灣軟體業也是與有榮焉,產業大老以成敗論英雄固然沒錯,但也應該多給軟體業成長的空間。

 至於台灣軟體產業未來該怎麼走?施振榮認為,做軟體或資訊服務業有兩條路可走,其一是垂直分工、水平整合,垂直分工就像IBM做的軟體元件、模組一樣,至於水平整合就如同1976年微軟(Microsoft)的水平式做法一樣;其二就是要走Utility(公用化)的IT 服務模式,像宏碁做的巨架構、微服務,就是一例。

 另外,據資策會市場情報中心的統計,目前台灣資訊軟體業者共有1,200家,2003年產值為新台幣1,584億元,儘管平均每年皆有2位數成長,並預估到2010年時產值可達新台幣5,000億元,然由於廠商家數過多,絕大多數規模都不大,公司員工在100人以下的比例高達79.6%,營收規模在新台幣500萬元以下的比例也高達85.9%,因此,很難在國際舞台與國際大廠競逐,成為台灣軟體產業發展一大隱憂。

2004/09/08

從30萬到24億的軟體金童傳奇

工讀生總裁

從30萬到24億的軟體金童傳奇

文 /郭奕伶、鄭呈皇

五年前,他只是一個麥肯錫的工讀生;五年後,他變成跨國企業總裁,身價兩億元。他,只有26歲,曜碩科技創辦人,郭榮昌。這是他步步為營,追求成功的故事。

這一幕情景張力十足。二十三日下午,台北國泰醫院手術房,一個二十六歲、臉色蒼白、身形消瘦的青年,躺在手術台上準備進行急性腹膜炎手術。就在醫生拿起手術刀,在他腹部劃下長達十公分傷口的同時,一筆從日本電匯過來的資金,卻也讓這名年輕人在剎那間,變成身價兩億元的少年富翁。

手術畢,年輕人被護士推入病房。除了床前掛滿的各式各樣點滴瓶、導管,以及他隨身攜帶的筆記型電腦、PDA、和手機以外,身旁沒有親人。

清醒後的第一分鐘,年輕人接到一疊文件,當他虛弱的握著筆簽完最後一個名字後,他即將成為一家日本上市公司的總裁。這家名叫Aplix的公司,是全球手機JAVA技術第一大廠商,市值折合新台幣約二百四十億元。該公司以一股一百三十元的代價,買下台灣的曜碩科技。曜碩的創辦人就是二十六歲的郭榮昌。

在動手術的三個禮拜前,也就是七月三十日,郭榮昌風塵僕僕的趕到東京證交所,向來自花旗、日本野村、等二十位國際券商分析師,報告Aplix買下他所創立的曜碩科技。緊接著,八月二十日,Aplix在日本池袋地區的東武百貨公司頂樓,邀請諾基亞、索尼愛立信、明基等全球手機客戶,舉行啤酒晚宴,並介紹即將出任總裁的郭榮昌。

過度透支體力的郭榮昌回到台灣後病倒了。人生實在很奇妙,二十六歲的他接受生平第一個手術的同時,也嘗到第一次創業就成功的滋味。

郭榮昌,一個市場陌生的六十七年次小將,如何在四年之內,把當初向母親借來的三十萬元,變成一家價值二十四億元的軟體公司?在二○○○年網路泡沫後,軟體金童已銷聲匿跡多時,郭榮昌的出線,帶出什麼新的啟示?

從建中、台大資工系、交大資工研究所的學歷來看,郭榮昌無疑是個聰明小子;再從曜碩科技的創業團隊,結合台大、清大、交大與麥肯錫企管顧問公司高手的背景看來,這個團隊的成功似乎也不令人意外。

然而,故事的過程卻不如想像中順理成章。

‧ 堅持:被排擠也要硬幹

郭榮昌奮力攫取機會的性格,在同儕中很少見。譬如,在台大時,當他覺得國際經濟商管學生會(AIESEC),是一個很有價值的跨國社團,即便社方以「AIESEC向來只收商學院學生」的理由拒絕郭榮昌加入。但郭榮昌不放棄,不但主動為其募款,還自願擔任活動跑腿,向該組織人力資源部部長劉毓雯表達出強烈的參與意願。

後來,劉毓雯獨排眾議讓他入社。她回憶,雖然當時很多人對郭榮昌的過度積極產生反感,甚至排斥,但是,劉毓雯當時就有預感,郭榮昌未來一定會成功。

也因為在AIESEC結識到的人脈,讓他有機會在大三下學期,硬擠入麥肯錫企管顧問。

雖然麥肯錫從不收取大學在校生,但郭榮昌不放棄一絲可能。他極力央求在麥肯錫上班、同為AIESEC成員的學姐,幫他想辦法,並表達即使不支薪,都願意到麥肯錫當工讀生的強烈意願。苦等一個月後,郭榮昌終於爭取到與麥肯錫香港主管面試的機會,如願進入麥肯錫的研究中心擔任研究工讀生。

進入麥肯錫,是他人生重要的轉折。那一段日子,郭榮昌雖然名義上是台大資工系三年級學生,但他早已修完系上課程,還積極選修商學院課程,同時,也在麥肯錫展開創業探索之旅。

在這個國際知名的企管顧問公司,看著一個個英文流利、身著亞曼尼套裝的專業顧問們,忙碌的洽談著各式各樣的跨國商業案件,出身平凡的郭榮昌心中,燃起「有為者亦若是」的心情。

就像由奧利佛史東執導的經典名片「華爾街」一片中,出身貧寒的年輕股市交易員畢德(Bud Fox),看到股市大戶戈登季柯(Gordon Gekko)的上流生活,心裡所燃起熱切追求成功的動力,郭榮昌感受到自己的轉變。

雖然穿的只是兩、三千元西裝,但郭榮昌與正職人員一樣,每天不熬到午夜十一、二點不下班。每週五,麥肯錫內部都有一個自助餐聚會,他告訴自己:「這是一般人無法切入的金字塔人脈庫與知識寶庫。」於是,他向旁人打聽每個顧問的背景與專長,每週都擇定一位顧問當目標,鼓起勇氣向其請教,從生涯規畫、市場趨勢,到人生經驗各式各樣的問題。對郭榮昌來說,麥肯錫就像個挖不盡的寶庫,他則像八爪章魚一樣,緊緊的抓住每一個學習的機會。

在麥肯錫時期,他可以接觸到成堆的研究報告,讓他能像獵人般尋找可以創業的商機。當時,WAP(無線應用協定)是許多手機大廠看好的技術,許多新創公司前仆後繼投入研發。但他反問自己:「等我真正出來創業,競爭者不就很多?」再者,WAP技術門檻不是很難,因此他認為既然要創業,就要往有高技術含量、還沒被挖掘的市場切入。

這時,建中死黨房達章、現任曜碩技術總監向他提起手機JAVA軟體技術。郭榮昌在成堆的研究報告中,也發現了這個新的機會。一九九九年的聖誕節前夕,兩人在台大側門外的星巴克咖啡館徹夜談出了創業計畫。

‧ 野心:做大不做小,拉高門檻

房達章手裡拿著黑白手機,裡面有「俄羅斯方塊」和「小蜜蜂」遊戲。他們盤算著,要如何切入高成長的手機軟體市場。切入遊戲軟體市場,錢,可以賺得快,但賺得短。但此時,郭榮昌「要大不要小」的個性顯露無遺。他說,與其選擇技術障礙低、已有先行者的手機遊戲軟體,還不如做讓小蜜蜂遊戲會在上面動的平台。因為,「這個技N門檻高,全世界競爭者不到五家。」就像全世界做作業系統的只有微軟一家稱霸,但做視窗上跑的軟體有無數家,郭榮昌想做的就是手機上的微軟。

當時,郭榮昌只是一名麥肯錫的工讀生,但他選擇加入「不是零就是一百」的高挑戰性賭盤。

那個讓小蜜蜂能動的軟體平台,稱為J2ME,是JAVA程式語言的一種,昇陽電腦三年前針對越來越多手持式裝置所發展的軟體技術。

想像一下,如果在各種不同系統的手機或者PDA上,都有這種軟體技術能夠大一統,只要有支援就能打破規格的限制彼此分享,下載遊戲與其他應用程式,這個「大一統的軟體」,市場會有多大呢?「光明年手機將有一億五千萬隻內建J2ME,你說這個市場大不大?」郭榮昌彷彿從一株剛迸出大地的小豆苗,興奮地嗅到春天即將到來。

隔天,郭榮昌與房達章,分頭回台大、交大、清大找創業團隊。

二○○○年五月份,郭榮昌向母親借了三十萬元,與其他六位創業夥伴,在台北辛亥路旁的小公寓開始了曜碩科技的第一年。每個人不支薪,埋頭開發技術,支付每個月兩萬塊的房租。就這樣,過了兩年毫無收入的苦日子。然而,最大的敵人並不是開發這個技術,反而是「必須耐得住寂寞」,房達章說。

因為前兩年都沒有收入,工程師流動率很高,十幾個研發人員,一度走到剩個位數。「我也曾經想要放棄」,房達章回憶,過程中,看不到未來在哪裡的痛苦糾纏著。

‧ 人脈:爭取金主,吃飯也要用心機

然而,在郭榮昌的堅持下,隨著市場商機越來越成熟,他們的技術也獲得突破,曜碩的爆發力一點一滴的累積著。隨身都帶著筆記型電腦、幾支手機,郭榮昌逢人就簡介公司的產品,為了爭取生意、爭取金主,他使出硬拗的精神,即使花費半年、一年的時間,他都不放棄,常常工作到凌晨三、四點。

這時,郭榮昌以過去的人脈為基礎,透過五層關係,爭取到科技界大老——穩懋副董事長林燕津的入股。林燕津並以最大股東身分,成為曜碩科技前三年的董事長。

有一次,林燕津與科技界好友餐敘,他隨口告訴郭榮昌說:「有空可以過來一起吃飯。」郭榮昌發現,這次餐敘名單中有一位廣達的資深主管,於是,他那一天特別將全部行程空出來,希望可以在晚上餐敘場合中完美演出,爭取訂單。他騎著一部舊摩托車,提早半小時到餐敘地點福華飯店附近等待,一圈圈的繞著台北仁愛路圓環。

眼看著時間已經過了半小時,林燕津都沒有來電通知,「每一秒鐘都很難熬,我的心怦怦得快跳出來了,」郭榮昌回憶那一刻。後來,他忍不住撥了電話,「我們已經開始吃了啊,你可以過來,」聽到林燕津這句話,滿頭大汗的郭榮昌,立刻衝進飯店。

那場聚會後,郭榮昌找到了廣達手機部門的窗口,半年後,第一張訂單終於下來了。郭榮昌永遠記得,這個技術是研發團隊們,過去一年來打地舖睡在公司的心血結晶。

‧ 學習:累積學習曲線,與大廠頻互動

當時,他們拿到廣達的手機規格,拆開裡面硬體,CPU晶片、音效卡以及作業系統等,每個零件都有相對應的開發程序,很多都是以前沒做過的。因此,為了把手機上的射擊遊戲流暢度表現最好,他們把零件一個個拆開來研究,企圖在占用記憶體最小的情況下,能使遊戲表現最好。

過程中,只要遊戲畫面中有一個子彈或飛機停一下,或者音效不見,就得放棄重新再來。還有好幾次是拿到廣達後,發現還是不行,半夜又立刻派人去拿,一路做到早上。
當曜碩幫廣達做出第一隻J2ME手機後,明基、華碩等大公司紛紛打聽這個名不見經傳的小老弟有何能耐,能夠做出不讓遊戲出現遲緩的軟體。就這樣,曜碩累積學習曲線,和大廠的互動越來越快。

大廠的保證,給了曜碩很大的信心,財務窘困也碰到解題。二○○二年時,他們手上的現金只夠再燒半年,郭榮昌到處找錢,但是創投們都問:「憑什麼要投資你?」當他把這些大廠的合約攤在桌上後,曜碩陸續取得了日本軟體銀行、漢鼎創投、三菱等創投的資金入股。

當時,來自麥肯錫、現任曜碩副總的詹兆源對著內部員工說:「我不知道有沒有一家J2ME公司會成功,但是如果有,一定是我們。」在這樣的堅持下,不到三年的時間,曜碩攻下韓國的Maxon、中國的TCL、夏新、聯想等客戶,成為全球五千六百萬隻J2ME手機的技術廠商,也成為大中華區最大的手機軟體技術廠商。

市場的發展越來越證明,曜碩的選擇正確。Strategies Unlimited公司統計,也顯示相同的發展趨勢。市場上J2ME手機的數量,二○○六年將從現在的一億隻成長到五‧五三億隻,占全部手機出貨量的八三%。

曜碩的成功故事背後,竟是,一個嗅到趨勢的麥肯錫工讀生,所展現出的創業者膽識。
三年前,前資迅人創辦人賀元在經營事業失敗後,還是激勵他的後起者:「相信你所做的事,就堅持下去,歷史會證明一切。現在看很多事也許是錯的,但三年之後可能就變成對的,就是go for it!」他最怕台灣因為資迅人倒了,就認為Internet沒前途。「我相信當Internet第二波來臨時,對社會的影響會比現在大很多,也會產生很多成功的創業家,但不一定是我。」

資迅人倒閉時,也正是曜碩處於大環境的低潮期,郭榮昌與房達章在黑暗中苦撐著。工研院電通所經理陳進松就說,「JAVA手機也是最近兩年才開始流行,但是曜碩早在四年前就開始起跑」。起跑早的曜碩,在技術與人才優勢上卡到關鍵性的位置。這個技術需要的是硬、軟體都了解的工程師,「在台灣絕對不超過一百個」。

布局很早的曜碩後來是掌握這類人才的最大基地,房達章主導下,他們現在兩岸有四十位研發人員。

再者,此技術特別的地方在於手機每款都不一樣,因此客製化的能力也要強;換言之,光懂技術沒有練兵的經驗也沒用,因此和各大手機廠的整合能力顯得重要。這部分由於只有曜碩有機會和大廠切磋,相對就脫穎而出。目前全世界十大手機廠中,一半以上已經是曜碩的客戶。

今年五月,日本Aplix公司創辦人暨執行長郡山龍,發現曜碩在大中華區的實力,希望能購併曜碩。但是,第一眼看到郭榮昌後,郡山龍沉默了許久,他說:「我不知道要怎麼下手?」同樣是二十出頭就創業的郡山龍很清楚,對這麼年輕的小伙子,既沒結婚也沒負擔,什麼都不缺,如果要談合作,錢根本不是重點,因為,他們唯一有的就是澆不熄的熱情。

「我不知道他們要什麼?也不知道要怎麼出價?」郡山龍深怕一個不小心,郭榮昌就停止談判。因為,十年前,郡山龍也曾斷然拒絕美國網景(Netscape)公司,以兩千萬美元收購Aplix。十年後,Aplix的市值已經是當初收購價格的三十五倍。事實上,郭榮昌心裡也想:「如果他想用錢來砸我們,我們就馬上拉回來,大不了對幹嘛,反正我們也沒什麼好怕的!」

以尊重的態度,郡山龍與郭榮昌見了三次面,取得郭榮昌的信任後,雙方決定展開磋商。這時,曜碩董事長吳廣義(編按:宏碁集團創始人之一,去年九月以法人股東受邀出掌曜碩)發揮了重要的功能,他給了郭榮昌兩個談判錦囊:第一,要快;第二,不能讓Aplix有放棄的機會。吳廣義說,因為一旦開始談,對方就會對曜碩的相關客戶、技術資料進行估價、調查,如果時間拖久了,「曜碩都給人看光了」。因此,雙方簽下一紙有條件的合作意向書,聲明如果談判破裂,對方必須支付曜碩一筆不小的賠償金。

在收購談判的三個月裡,對方派出大股東、同時也是董事之一的高盛證券日本分公司主管主談,郭榮昌則一個人單槍匹馬上陣。二十六歲、毫無投資銀行實務經驗的郭榮昌,對上四十出頭歲的一流投資銀行高手;雙方從一億美元賣價對四千萬美元買價的拉鋸戰開始,進行一波波的攻防、心戰喊話。

這九十天裡,郭榮昌的情緒持續處於亢奮狀態,不管多晚睡覺,每天早上六點鐘一定自動驚醒,其壓力不言可喻。到最後,雙方以七千萬美元成交;也就是說,Aplix以一股一百三十元的高價,收購資本額曜碩科技,總收購金額高達二十四億元。

這場談判,郭榮昌其實有兩個選擇,一種是合併後,郭榮昌繼續留在公司擔任總裁;另一種則是拿一筆錢,然後走人。對多數人來說,即便是一個四、五十歲的創業者,後者的選擇毋寧是容易的,郭榮昌大可以拿個幾億元走人,再創一家新公司,或者從此閒雲野鶴。但是,他沒有,他要的更大。他說:「錢向來不是我的重點,我要的是跨國企業的經歷。」與華爾街片中,那位年輕交易員畢德不同,郭榮昌要的是創造事業的成就感,而不只是享受財富的快感。

二十六歲的年輕人,心境卻如入定的老僧。

酒酣耳熱之際,四十一歲的郡山龍對郭榮昌說:「我現在什麼都有了,也什麼都經歷過了,我希望可以早點退休,培養你當Aplix未來的接班人選」。此刻的郭榮昌,距離他夢想的國際舞台只有咫尺之遙。

檢視郭榮昌的創業歷程,是極度濃縮式的。也不過兩年前,他還苦苦的過著毫無收入、每個月淨現金流出的日子,甚至在法人出資入股後,還得隻身面對董事會的無情批判、裁員的困境。當時,他的許多同學們進了聯發科等大公司,身價早已上千萬,甚至買了三百多萬元的賓士三二○名車。

但是,他仍然堅持走自己的路:「我不要順理成章、一帆風順的成功,我要享受創造的樂趣最好能遇到一些挫折」。回頭看郭榮昌的歷練,他步步布局走向成功,沒有絲毫僥倖。

隨著公司規模擴大,郭榮昌未來的路還很長。工研院經理陳進松說,由於這個市場最近才開始興起,錯過第一波市場的廠商,當然也不會放過,未來手機大廠如諾基亞都會考慮自己養人才,因此,未來郭榮昌所面對的競爭態勢將更加詭譎。

不僅如此,從創業家到經營者,郭榮昌未來面臨的跨國管理,挑戰更大。畢竟,他仍是年少得志的CEO,更高的山峰還在後頭。

◇更多內容-- http://www.businessweekly.com.tw/