A blog by a system administrator and programmer.

org.apache.jasper.JasperException: java.lang.NullPointerException 
Monday, August 19, 2013, 09:19 PM - Programming
Posted by Administrator
If your server can startup normally but when you try to access any jsp and the pages show the following exception.

java.lang.NullPointerException org.apache.jsp.index_jsp._jspInit(index_jsp.java:26) org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:338) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.pahome.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:18) org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738) com.pahome.filter.CheckLoginFilter.doFilter(CheckLoginFilter.java:173) com.pahome.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:18)

At line 26 it usually show something like this.
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();

It usually means that your WEB-INF contain duplicated jars especially jsp-api.jar and servlet-api.jar. Remove them and restart your server will solve the problem.
3215 comments ( 34883 views )   |  permalink   |   ( 2.4 / 1008 )
Java Out of Memory problems 
Sunday, September 18, 2011, 02:31 PM - Programming
Posted by Freddy Chu

Java heap

java.lang.OutOfMemoryError: Java heap

Just simply apply -Xmx will fix the issue. But notice that one thing there have max. value for difference os.
32bit Windows around 2G
32bit Linux around 2.5G
64bit I only tried to use 4G, the limit seems much higher than 32bit systems.

PermGen space

java.lang.OutOfMemoryError: PermGen space

Presenting the Permanent Generation

By my understanding, PermGen space is for loading classes specifications. Usually you will not able to see this exception. Expecte that you have many lib need to be load and use.
Using Jboss with more than 1 big web application may hit this. You can change this limit by using -XX:PermSize and -XX:MaxPermSize

GC overhead limit exceeded

I think this is most uncommon exception that will be hitted
java.lang.OutOfMemoryError: GC overhead limit exceeded

Excessive GC Time and OutOfMemoryError
The parallel collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line.


The best way is to solve the coding problem. It is believed that the code have genereated too many trivial object. Especially in loops, if that is the case rather reuse the object than new an object.

If you really don't want to change the code or you cannot found the problem you can try the following way. Hopefully it will solve the issue, but not the best way and may require a long time to finish.

JVM have 3 difference garbage collectors you can try switching between them.

serial collector
single processor
jvm flag: -XX:+UseSerialGC

parallel collector
high throughput sometimes with pause
jvm flag: -XX:+UseParallelGC

concurrent collector
low lag time & moderate throughput
jvm flag: -XX:+UseConcMarkSweepGC -XX:+UseParNewGC

3019 comments ( 22131 views )   |  permalink   |   ( 2.9 / 1178 )
file_get_contents getting mad? 
Tuesday, April 20, 2010, 08:20 PM - Programming
Posted by Freddy Chu
My blog is died for awhile after php upgrade to 5.2.13. It is full of error about putting a non-array into rsort.

The root cause of the problem is due to the this blog store entries in file base, some of the file listing is serialized array. If you copy those content and try to unserialize it, it is perfect no error.

It really make me shocked as i expected the problem is come from serialization algorithm but it is not. It really cost me some time to figure out that the problem is from file_get_contents. It is really tricky, it won't show on command line mode but only happens in php modules of apache.

The REAL reason of unserializable is because file_get_contents add slashes into the output string. I have really no idea why i happens...

So I use the most DIRTY way to fix that ... add a stripslashes after call file_get_contents.

If anybody know the reasons please let me know :(

4422 comments ( 97456 views )   |  permalink   |   ( 3 / 614 )
java.io.IOException: Too many open files 
Saturday, October 25, 2008, 12:06 AM - System, Programming
Posted by Administrator
Yesterday I have face a funny java exception on my Linux server.

java.io.IOException: Too many open files at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:145) at org.mortbay.jetty.nio.SelectChannelConnector$1.acceptChannel(SelectChannelConnector.java:75) at org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:475) at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:166) at org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124) at org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:537)

It have cost me few minutes to figure out what is that problem.

At first i think it is caused by sysctl
but i found
fs.file-max = 65535

and my lsof -nn | wc -l is only around 10xx so i know that is not the problem.

After that i think about ulimit, if you are careless you may fake by default result the command ulimit's output. unlimited

When you execute ulimit -a you will see the whole story.

#ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
max nice (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 16370
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
max rt priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 16370
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

Now you know the point is there ... most Linux default openfile per user is limited to 1024. So you must edit the file /etc/security/limits.conf

add those 2 lines below to override the default limit.

* soft nofile 65536
* hard nofile 65536

4425 comments ( 3749 views )   |  permalink   |   ( 3 / 9450 )
Oracle moving index to another table space 
Tuesday, April 8, 2008, 05:04 PM - Programming
Posted by Freddy Chu
These days I am super busy. Nearly no time to write my blog. :(

There is so many people asking me how to move the index after created. As you know if you use plsql developer's GUI it will drop the constraint and add again with index. I don't know why it work like that but there is some simple solution.


Here also show you a simple procedure to move all index of a table from one tablespace to another tablespace.

create or replace procedure MOVE_INDEX_BETWEEN_TABLESPACE(from_ts in string,
to_ts in string,
tablename in string) is
cursor index_names is
select user_indexes.index_name
from user_indexes
where user_indexes.table_name like upper(tablename)
and user_indexes.tablespace_name = upper(from_ts);
index_name user_indexes.index_name%type;
open index_names;
fetch index_names
into index_name;
exit when index_names%notfound;
if index_name is not null and to_ts is not null then
end if;
end loop;

3 comments ( 235 views )   |  permalink   |   ( 3 / 844 )
Java disk usage 
Friday, January 11, 2008, 11:56 AM - Programming
Posted by Freddy Chu
It have been a long time for me to found a way to check the disk usage in Java.

Finially i get the solutions. It is in Java 6.0. java.io.File

There is 2 functions.

getTotalSpace() --- Returns the size of the partition named by this abstract pathname.
getUsableSpace() --- Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.

If your application is limited to use versions before 6.0. Then you can only keep using external commands.
Linux/Unix: df
Windows: fsutil volume diskfree c:

Alternative solutions for system independent solutions is to setup a snmp on the server you want to check and use java snmp client to query the result. That will be quite complex.

Useful links:
3 comments ( 241 views )   |  permalink   |   ( 3.1 / 1854 )

| 1 | 2 |