log4j initialization Problem

I had this today and drove me nuts. I am upgrading my app to Weblogic server 10. I have experienced the log4j init problem. It really sucks when I have done putting log4j.xml or props in the Classpath right and put in weblogic.xml with prefer-web-inf-classes as true.

and still got this:

log4j:WARN Please initialize the log4j system properly.

I think wls 10 just probably has log4j in itself and doing something fishy so your own log4j pack can never locate your own log4j.xml, no matter where in the CP it is.

I found a solution and it is a sure way to fix it – like this class below, this is to be called by any startup class or servlet init method.

public class LogConfigurator {

final static String LOG4J_XML_PATH = “/WEB-INF/classes/log4j.xml”; // in your ear/war

public static void configure(ServletContext context) throws MalformedURLException{
URL path_url = context.getResource(LOG4J_XML_PATH);


If you have log4j.properties file, use PropertyConfigurator instead of DOMConfigurator.

it works like a charm.

Use Oracle sequence ID in Hibernate

Today I had tried a few times with hibernate using oracle sequence ID. The params of the generator was not very clear from documentations. But after a few permutation, it turns out this works nicely.

<id name=”file_id” type=”long” column=”file_id”>
<generator class=”sequence” />
<param name=”sequence”>file_seq_id</param>

This requires pre-generation of file_seq_id sequence in oracle database. It is also good for cluster
use. Increment type is not.