I am installing software, call it anonymously "productx", which uses hibernate among other things. During installation I get:
Code:
[schemaexport] log4j:WARN No appenders could be found for logger
(net.sf.hibernate.cfg.Environment).
[schemaexport] log4j:WARN Please initialize the log4j system properly.
Productx developers are suggesting that I ignore these warnings, and that if I do want to pursue them further then I should ask you (the hibernate user list). So I have two questions for you. One question is: what's the risk involved if I do ignore these warnings? The other question is: how do I fix what these warnings are warning me about? Below I shall include what relevant details I am able to muster after searching your FAQs, user mailing list, and the relevant part of the hibernate documentation (which I don't understand yet).
Hibernate is not the main thing I'm after. I just want a fairly clean productx installation and to get at the core functionality of productx. It comes wrapped up in Ant, Log4j, etc., etc., including Hibernate, all of which I'm trying to wade through just to get to the part of productx that I need.
I do want log4j to work, at least for productx. I don't know whether the log4j configuration relevant to hibernate logging is also going to affect productx logging. Productx does use log4j, and in the past has logged messages successfully with it.
One of your instructions to posters is to include enough details! So I hope you are willing to read through the details. I'll tell you what I know. The information is a little scatterred for two reasons: (1) I don't fully understand the situation, and (2) it was presented scatterred (that's one of the underlying problems). I also looked at the straight hibernate documentation but in order to understand it I'd probably have to spend more days learning more software parts. The productx developers are suggesting that since the log4j warnings aren't "errors" anyway, I can ignore them and move on to what I was originally intending to do.
1. The warnings are coming from a "schemaexport" task in an Ant build.xml file. "schemaexport" is executing net.sf.hibernate.tool.hbm2ddl.SchemaExportTask which (or whatever it calls) seems to be the code that's generating the warnings. (I don't have its source code.)
2. The schemaexport task is defined like this:
Code:
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="classpath"/>
Elsewhere in the same build.xml file is this definition of that path-like structure:
Code:
<path id="classpath">
<pathelement location="${build.classes}"/>
<!-- this is for the servlet JARs in Tomcat 4.1.x -->
<fileset dir="${env.CATALINA_HOME}/common/lib">
<include name="activation.jar"/>
<include name="servlet.jar"/>
</fileset>
<!-- this is for the XML JARs in Tomcat 4.1.x -->
<fileset dir="${env.CATALINA_HOME}/common/endorsed">
<include name="*.jar"/>
</fileset>
<fileset dir="lib/ext">
<exclude name="*.LICENSE"/>
<include name="*.jar"/>
</fileset>
<pathelement path="${java.class.path}"/>
</path>
3. I'm using tomcat-4.1.18 standalone. But at this phase of installation, when I get the warning messages, I'm not "running" anything in tomcat; the installation process is just installing things under the tomcat directory tree.
4. log4j-1.2.7.jar is in lib/ext. I looked inside it and found that there are appenders in it, and I suppose that's where the appenders are supposed to be coming from. build.xml is already coded so that this jar file is in the path with id=classpath, which is referenced in the schemaexport task in the Ant build file (as shown above).
5. When I do echoproperties (in Ant), it does not show log4j-1.2.7.jar. I think (but am not certain) that that's because the path with id=classpath is not one of the paths that echoproperties is supposed to show.
6. I have not yet found a hibernate.cfg.xml. However, one of your forum messages indicates that hibernate.properties might be substituted for it successfully. (Reference: date 2003-04-30 06:01, in which srcfrguser writes "... hibernate.cfg.xml is not working so I replaced with hibernate.properties. At least now I am getting DB connection.")
7. I do have a hibernate.properties file which I got from hibernate-2.0 and I put it into path id=classpath, but still get the same two log4j warnings. Here is where it is:
Code:
<fileset dir="webapps/productx/WEB-INF/persistence">
<include name="hibernate.properties"/>
</fileset>
And here is the contents of that hibernate.properties (excluding some comments which begin with #):
Code:
hibernate.show_sql=false
hibernate.connection.poolsize=40
## HSQL
hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect
hibernate.connection.username=[name withheld in this message]
hibernate.connection.password=[password withheld in this message]
hibernate.connection.url=jdbc:hsqldb:@PRODUCTX_WEBAPP@/WEB-INF/database/productx
hibernate.connection.driver_class=org.hsqldb.jdbcDriver
8. I tried log4j.properties like this: in the path with id=classpath I put:
Code:
<fileset dir="webapps/productx/WEB-INF/classes">
<include name="log4j.properties"/>
</fileset>
where the contents of that log4j.properties is:
Code:
# Set root category priority to ERROR and its only appender to A1.
log4j.rootCategory=ERROR, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] (%F:%L) %-5p %c %x - %m%n
log4j.logger.org.productxparent.productx=DEBUG
but still got the same two log4j warnings.
9. I also tried another log4j.properties (which I got from hibernate-2.0), like this:
Code:
<fileset dir="hibernate-2.0">
<include name="log4j.properties"/>
</fileset>
That log4j.properties contains:
Code:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ##
log4j.rootLogger=warn, stdout
log4j.logger.net.sf.hibernate=info
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace
### log JDBC bind parameters ###
log4j.logger.net.sf.hibernate.type=info
### log prepared statement cache activity ###
log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=info
but I still got the same two warnings from log4j.
10. I am not certain exactly which version of hibernate comes bundled with productx, but it has lib/ext/hibernate2.jar which I suppose might be version 2.0.
11. lib/ext/commons-logging.jar exists and is already in path id=classpath. But it didn't get rid of the two log4j warnings.
12. Reference date 2003-06-12 15:02 in which rdjanati added "the JVM property -Dorg.apache.commons.logging.Log=
org.apache.commons.logging.impl.NoOpLog" and, for him, "the logging warning has disappeared". I haven't figured this one out yet. The only place I see to put a -D property like that is in starting tomcat, but that doesn't make sense to me because these log4j warnings are, in my case, occurring in the installation stage; I'm not yet in the tomcat-running phase.
13. I haven't yet found any commons-logging-apis.jar. (On 2003-08-11 13:06, turin42 mentions it.) (But even if it is needed, kokopelli-bldr replies on 2003-08-11 13:42 that it didn't solve the problem for him.)
14. Reference date Dec 15, 2003 11:52 am in which ecossian had the same warnings; and Dec 15, 2003 9:43 pm in which he put the "common-logging.jar" file into the WEB-INF/lib folder which solved the problem for him. So I tried the same thing (with commons-logging.jar, not common-logging.jar), both in $CATALINA_HOME/webapps/productx/WEB-INF/lib and in webapps/productx/WEB-INF/lib
to no avail: I still got the same two warnings from log4j.
15. All the above was done on a Linux system.
Thanks in advance.
Please cc reply posts to:
jrlehman@mail.arc.nasa.gov