May 4, 2009
Welcom The close() method of ClassLoader in JDK7
Therefore, there is no need to kill application to close classloader (Known for App kill).
I am very expecting JDK7 release.
URL url = new URL("file:foo.jar");
URLClassLoader loader = new URLClassLoader (new URL[] {url});
Class cl = Class.forName ("Foo", true, loader);
Runnable foo = (Runnable) cl.newInstance();
foo.run();
loader.close ();
// foo.jar gets updated somehow
loader = new URLClassLoader (new URL[] {url});
cl = Class.forName ("Foo", true, loader);
foo = (Runnable) cl.newInstance();
// run the new implementation of Foo
foo.run();
java sources for ojdbc (odjbc14-10.0.2.zip, ojdbc14-9.2.zip) decompied by jad
Prior to see the source, you have to see the readme of ojdbc14.jar in oracle web site to understand jdbc specification and bug fixes.
Notepad with class java file (Jad Usage Tip)
Download and install jad app, and put intalled jad in the path on your computer to execute on any commnad window.
1. Create jad.bat file
Crate jad.bat file and put your jad.bat into path on your computer.
jad -o -d. %*
notepad %~n1.jad
del %~n1.jad
2. Link class extension file to jad.bat that you made.
3. Unzip jar
Unzip a certain jar to your computer. and run "cmd" on execute window menu.
And, go to the unzipped jar directory and execute below command to decompile your class files.
4. Click class file
After clicking your class file linked jad.bat, you may see this window.
Strength of this bat file
- You may not decompile every class file.
- You may not know every option of jad.
- Autiomatically remove the jad file when you close the decompiled java source note-pad-window.
addShutdownHook() of Runtime class
...
JavaFx Programming Reference
Setting property in svn repository
[auto-props]
*.c = svn:eol-style=native
*.rng = svn:eol-style=native
name | value |
---|---|
svn:eol-style | native |
svn:executable | * |
JavaOne 2008
You may be requested to login by sun.com. If you are sdn's member, you can access and enjoy it.
Also, you can visit this site. "http://java.sun.com/javaone/sf/sessions/general/index.jsp"
No SqlHandler log4j:ERROR problem
Thinking about saving error logs in web application based on web-work(or struts2)
You may meet java errors every day if you are a java developer. Especially if a lot of or critical error logs in web application get to meet, you will be panic. So, there is need to develop error log DB and error-collectiong log module.
I will introduce my idea about developing error log DB.
According to your company policies, methods are applied for error logging system.
Architecture of error logging system consists of
1) Error DB can be stored
2) Admin web application can show errors on error db
3) Java classes and log4j configuration to transfer logs to DB.
<Error DB>
In web application, there are many properties to save such as belows.
project-name, server-name, loginid(userid), access date-time, log level, url, form, cookie, referer, execpetionmessage
You can specify those more concisely. For example, exceptionmessage is divided to head and body according to java.lang.Exception.
I made error log db, table. Specially I made indexing in mysql. And in mysql DB, I made a batch script to rotate log db.
#!/bin/sh
TODAY=`date -d "-1 day" +%Y%m%d`
TO_DELETE_DAY=`date -d "-30 day" +%Y%m%d`
mysql -u userid -p password mysql db-schema-name << !
# rotate log table
alter table lgt_logdata rename logdata_${TODAY};
drop table if exists logdata_${TO_DELETE_DAY};
create table logdata (
logid int(11) NOT NULL auto_increment,
projectname varchar(30) ,
servername varchar(20) ,
....
KEY lgt_logdata_ix1 (projectname,loglevel)
)
<Error-collectiong>
Error-collecting log module is implemented by log4j in simple. You can change the properites to save several log-level like error, warning. So, you can make warning log DB as well.
Let us suppose to save the errors to mysql.
<Log4j.xml>
<appender name="ERROR-OUT" class="org.apache.log4j.jdbcplus.JDBCAppender">
<param name="Threshold" value="ERROR"/>
<param name="dbclass" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://in.log.google.com"/>
<param name="username" value="error"/>
<param name="password" value="nobodynobodywantyou"/>
<param name="sqlhandler" value="com.google.kr.MySQLHandler"/>
<param name="Buffer" value="1"/>
</appender>
<logger name="com" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="ERROR-OUT"/>
</logger>
You have to save error-loging policy in your web application.
I think every logs have to store error log DB, so, I have policy to save all tomcat logs. Because every any kinds of errors can affect the performance of web application.
I have three policies to store the DB. I think those are very important to design error DB.
1. Using Interceptor in web work or struts2, web data such as url, form have to save MDC. (MDC is api of log4j framework)
Before web application meet java exceptions, the interceptor save the web information and after invoking action it checks the result of invoking action are failed(or throw exception). If the action throws the exception, those errors will sqlhandler (ERROR-OUT)
MDC.put("projectname", projectname);
MDC.put("cookie",cookie);
2. Use Servlet in web.xml.
You may extend and implements extends javax.servlet.http.HttpServlet class. Through the implemented class to handle error, you can store errors.
<servlet>
<servlet-name>errorHandler</servlet-name>
<servlet-class>com.google.kr.ErrorHandlerServlet</servlet-class>
</servlet>
3. Adding some fuctions to sqlhandler.
Most of error cases occur in calling action from users, but in some case internal web application invoker can make errors. For example batch or cache or scheduling based on Thread could make fault, but belows method can not include saving error logs.
And then, when you implement sqlhandler, you can add those.
You've got to adds some exceptional case on the sqlhandler.
import org.apache.log4j.jdbcplus.JDBCSqlHandler;
public class ErrorHandler implements JDBCSqlHandler {
...
}
<web applicatiion for error log>
You can show the errors stored in DB in simple.
Dynamically creating table in ibatis
checkng(or seeing) oracle jdbc driver(ojdbc.jar) version
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
System.out.println("Database Product Name : " + meta.getDatabaseProductName());
System.out.println("Database Product Version : " + meta.getDatabaseProductVersion());
System.out.println("JDBC Driver Name :" + meta.getDriverName());
System.out.println("JDBC Driver Version : " + meta.getDriverVersion());
Deadlock using commons-pool 1.4 and commons-dbcp 1.2.2
Busy http thread grew up until suspending its function. When the apache could not respond any request, it removed from L4 (it have L7 function) because of no response.
OS : CentOS
gcc version : gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)
glibc 버전 glibc-2.3.4-2.39
- Apache Server Status
- Server uptime: 4 days 20 hours 41 minutes 2 seconds
- Total accesses: 43491259 - Total Traffic: 10.8 GB
- CPU Usage: u33.75 s6.42 cu0 cs0 - .00956% CPU load
- 104 requests/sec - 27.0 kB/second - 266 B/request
- 109 requests currently being processed, 4 idle workers
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW_WWW.WWWWWWWWWWWW CWWWWWWWWWWWWWWWWWWWWW_WWWWCWWWWWWWWWRWWWWWW__CCR.C............. ................................................................ ................................................................
Scoreboard Key:
"_
" Waiting for Connection, "S
" Starting up, "R
" Reading Request,
"W
" Sending Reply, "K
" Keepalive (read), "D
" DNS Lookup,
"C
" Closing connection, "L
" Logging, "G
" Gracefully finishing,
"I
" Idle cleanup of worker, ".
" Open slot with no current process
..
i. java.lang.Thread.State: BLOCKED (on object monitor)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:916)
- waiting to lock <0x8fedb478> (a org.apache.commons.pool.impl.GenericObjectPool)
1. "TP-Processor2" daemon prio=10 tid=0x0821f400 nid=0x4286 waiting for monitor entry [0x88ed3000..0x88ed50a0]
2. "TP-Processor2" daemon prio=10 tid=0x0821f400 nid=0x4286 waiting for monitor entry [0x88ed3000..0x88ed50a0]
Found one Java-level deadlock:
=============================
"TP-Processor200":
waiting to lock monitor 0x080dfd24 (object 0x8fedb478, a org.apache.commons.pool.impl.GenericObjectPool),
which is held by "Timer-0"
"Timer-0":
waiting to lock monitor 0x080dfcc0 (object 0x8fee6f70, a org.apache.commons.dbcp.PoolableConnection),
which is held by "TP-Processor28"
"TP-Processor28":
waiting to lock monitor 0x080dfd24 (object 0x8fedb478, a org.apache.commons.pool.impl.GenericObjectPool),
which is held by "Timer-0"
"TP-Processor200": (Select query) return queryForList("xxx.selectXXXCount",param);
"TP-Processor28": (Select query)
queryForObject("selectmusic",params);
Commons DbcpDead lock using the evictorCreated: 26/Jun/08 10:18 AM Updated: 27/Jun/08 03:41 AM |
Patch attached, dead lock reported. the abandonedtrace does synchronized(this) when it really only needs to do synchronized(this.trace)
Dead lock reported when using the evictor
=============================
"Timer-3":
waiting to lock monitor 0x0000000053b40548 (object 0x00002aaabf3210f0, a
org.apache.tomcat.dbcp.dbcp.PoolableConnection),
which is held by "TP-Processor27"
"TP-Processor27":
waiting to lock monitor 0x0000000053b404d0 (object 0x00002aaab9fa8b08, a
org.apache.tomcat.dbcp.pool.impl.GenericObjectPool),
which is held by "Timer-3"
Java stack information for the threads listed above:
patch source
Because Commons-dbcp 1.3 is not year released in formal. (now : 4. 2009) and I do not know what willing happen if the snapshop patch version, I used patched commons-dbcp 1.2.2 library.
After patching that version, there is no trouble or problem like that.
Blog Archive
-
▼
2009
(33)
-
▼
May
(29)
- Welcom The close() method of ClassLoader in JDK7
- java sources for ojdbc (odjbc14-10.0.2.zip, ojdbc1...
- Notepad with class java file (Jad Usage Tip)
- addShutdownHook() of Runtime class
- JavaFx Programming Reference
- Setting property in svn repository
- JavaOne 2008
- No SqlHandler log4j:ERROR problem
- Thinking about saving error logs in web applicatio...
- Dynamically creating table in ibatis
- checkng(or seeing) oracle jdbc driver(ojdbc.jar) v...
- Deadlock using commons-pool 1.4 and commons-dbcp 1...
- Eclipse Code Style Sample (You can import!)
- MERGE INTO Statement
- Impossible to get merged row count in ibatis. (to ...
- Clone method in Java
- Implementing equals method of collections classes
- Weakness of Java Web Start
- When you apply for developer job..
- G1 garbage collection
- [DBCP] Without given validationQuery, no validatio...
- How to get hostname in http url in Java
- How to get java cpu usage (jvm instance)
- Rounding(Scaling) x postion of decimal point
- Effective Java References
- BCEL in java6
- Good JMX References
- ConcurrentModificationException in java collection...
- How to gain Calendar type to String type in java
-
▼
May
(29)