-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Log4j WARN Configuration:125 - No configuration found.
PostPosted: Tue May 31, 2005 10:06 pm 
Newbie

Joined: Mon Feb 21, 2005 3:49 am
Posts: 15
Hi All

It looks having problems that hibernate read the hibernate.properties file first then load the hibernate.cfg.xml which does override value from hibernate.properties, that is fine and accetable. ... question is once I got instance of SessionFactory, Session Object, log4j warn: "no configuration found ... "

my working environment:
OS -> Debian Linux
JVM -> JDK 1.5.0.03
Hibernate -> 2.1.8
Struts -> 1.2.4
MySQL -> 4.1.11
mysql-connector -> 3.1.8
DB connection pool -> c3p0-0.8.4.5 ( had tried Apache's DBCP & hibernate default db connection pool, but with same error result)
Tomcat -> 5.0.28

all configure files are placed under /WEB-INF/src and *.hbm.xml, pojo are in the same package

eg.
WEB-INF/src
- com.abc.hib
|_ Cat.java
|_ Cat.hbm.xml
|_ ...
.
.
- hibernate.cfg.xml
- hibernate.properties
- log4j.properties
.
.

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 2.1.8
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="com.cfreecom.dating.hib2">
<class name="Cat" table="cat">
<id
column="cat_id"
name="id"
type="string"
>
<generator class="vm" />
</id>
<property
column="sex"
length="1"
name="sex"
not-null="false"
type="string"
/>
<property
column="name"
length="16"
name="name"
not-null="true"
type="string"
/>
<property
column="weight"
length="10"
name="weight"
not-null="false"
type="big_decimal"
/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
BaseAction.java
/*

* $Header: /var/lib/cvs/dating/WEB-INF/src/com/cfreecom/dating/actions/BaseAction.java,v 1.3 2005/05/31 16:35:08 maxj Exp $

* $Revision: 1.3 $

* $Date: 2005/05/31 16:35:08 $

*

* Copyright 1999-2004 The Apache Software Foundation.

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/



package com.cfreecom.dating.actions;



import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;



import com.cfreecom.dating.util.Constants;



import java.util.Iterator;

import net.sf.hibernate.cfg.Configuration;

import net.sf.hibernate.*;



public class BaseAction extends Action {



private static SessionFactory sFactory = null;



// ----------------------------------------------------- Instance Variables



/**

* The <code>Log</code> instance for this application.

*/

protected Log log = LogFactory.getLog(Constants.PACKAGE);



// ------------------------------------------------------ Protected Methods



protected Session getSession() throws HibernateException {



System.out.println("BaseAction's getSession()");

Session s = null;



if (sFactory == null){

System.out.println("sFactory == null");

// Loads hibernate.properties from the classpath

Configuration config = new Configuration().configure();

// Read mapping xml files from the classpath

sFactory = config.buildSessionFactory();

System.out.println("sFactory = "+sFactory.toString());

s = sFactory.openSession();

System.out.println("Success: openSession()");

if (s.isConnected()){

System.out.println("Database isConnected");

}else{

System.out.println("Database not Connected");

}

}



return s;

}



protected Iterator findAll(Session session, String queryStr) throws HibernateException {

Query query = session.createQuery(queryStr);

return query.iterate();

}



/**

* Return the local or global forward named "failure"

* or null if there is no such forward.

* @param mapping Our ActionMapping

* @return Return the mapping named "failure" or null if there is no such mapping.

*/

protected ActionForward findFailure(ActionMapping mapping) {

return (mapping.findForward(Constants.FAILURE));

}





/**

* Return the mapping labeled "success"

* or null if there is no such mapping.

* @param mapping Our ActionMapping

* @return Return the mapping named "success" or null if there is no such mapping.

*/

protected ActionForward findSuccess(ActionMapping mapping) {

return (mapping.findForward(Constants.SUCCESS));

}



// ------------------------------------------------------ Public Methods



//public abstract void hibExecute(String[] args) throws HibernateException;

//public abstract String exampleString();

}

CatAction.java
package com.cfreecom.dating.actions;

import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;

import com.cfreecom.dating.hib2.*;
import com.cfreecom.dating.hib2.dao.*;

public class CatAction extends BaseAction {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

System.out.println("Hibernate - CatAction ...");

Configuration config = null;
SessionFactory sf = null;
Session session = null;
Transaction trans = null;

/*
for (int i=0; i<props.length; i=i+2)
config.setProperty(props[i], props[i+1]);
*/
try {
/*
sf = new Configuration().configure().buildSessionFactory();
System.out.println("sessionFactory: "+sf.toString());

session = sf.openSession();
*/
session = this.getSession();
System.out.println("session: "+session.toString());

Criteria query = session.createCriteria(Cat.class);
// loop over the results
Iterator results = query.list().iterator();
while(results.hasNext()) {
Cat mycat = (Cat)results.next();
System.out.print(mycat.getId()+" ");
System.out.print(mycat.getName()+" ");
System.out.println(mycat.getWeight());
}

trans = session.beginTransaction();
System.out.println("trans: "+trans.toString());
// do your job here ...
Cat cat = new Cat();
cat.setId("Cat1");
cat.setName("Cat1");
cat.setWeight(new java.math.BigDecimal(7.4f));

session.save(cat);
trans.commit();
System.out.println("trans commit ");


} catch (HibernateException e) {
System.out.println("HibernateException: "+e.getMessage());
e.printStackTrace();
} finally {
if(session != null) {
try {
session.close();
System.out.println("session close ");
} catch (HibernateException e) {
System.out.println("HibernateException: "+e.getMessage());
e.printStackTrace();
}
}
}


/*
// load the configuration file
_RootDAO.initialize();

try {
Cat cat = new Cat();
cat.setId("Cat1");
cat.setName("Cat1");
cat.setWeight(new java.math.BigDecimal(7.4f));

session = _RootDAO.createSession();
System.out.println("CatAction: return from getSession()");
if (session == null) {
System.out.println("CatAction: session is null");
} else {
System.out.println("CatAction: "+session.toString());
}
trans = session.beginTransaction();
System.out.println("CatAction: trans@"+trans.toString());
session.save(cat);
trans.commit();
} catch (HibernateException he) {
System.out.println("Initial SessionFactory creation failed." + he);
he.printStackTrace();
} finally {
if (session != null) {
session.close();
}
}
*/
return (mapping.getInputForward());
}

public void printCol(String str) {
System.out.print(str);
System.out.print(" | ");
}

}

DAO code are generated from HibernateSync

Full stack trace of any exception that occurs:
Hibernate - CatAction ...
BaseAction's getSession()
sFactory == null
08:24:12,019 INFO Environment:483 - Hibernate 2.1.8
08:24:12,021 INFO Environment:512 - hibernate.properties not found
08:24:12,024 INFO Environment:543 - using CGLIB reflection optimizer
08:24:12,026 INFO Environment:572 - using JDK 1.4 java.sql.Timestamp handling
08:24:12,037 INFO Configuration:909 - configuring from resource: /hibernate.cfg .xml
08:24:12,038 INFO Configuration:881 - Configuration resource: /hibernate.cfg.xm l
08:24:12,209 INFO Configuration:332 - Mapping resource: com/cfreecom/dating/hib 2/Cat.hbm.xml
08:24:12,329 INFO Binder:229 - Mapping class: com.cfreecom.dating.hib2.Cat -> c at
08:24:12,408 INFO Configuration:332 - Mapping resource: com/cfreecom/dating/hib 2/Photo.hbm.xml
08:24:12,427 INFO Binder:229 - Mapping class: com.cfreecom.dating.hib2.Photo -> photo
08:24:12,674 INFO Configuration:332 - Mapping resource: com/cfreecom/dating/hib 2/Role.hbm.xml
08:24:12,684 INFO Binder:229 - Mapping class: com.cfreecom.dating.hib2.Role -> role
08:24:12,698 INFO Configuration:332 - Mapping resource: com/cfreecom/dating/hib 2/User.hbm.xml
08:24:12,727 INFO Binder:229 - Mapping class: com.cfreecom.dating.hib2.User -> user
08:24:12,730 INFO Configuration:1067 - Configured SessionFactory: null
08:24:12,732 INFO Configuration:641 - processing one-to-many association mappin gs
08:24:12,737 INFO Binder:1181 - Mapping collection: com.cfreecom.dating.hib2.Ro le.userSet -> user
08:24:12,738 INFO Binder:1181 - Mapping collection: com.cfreecom.dating.hib2.Us er.photoSet -> photo
08:24:12,739 INFO Configuration:650 - processing one-to-one association propert y references
08:24:12,742 INFO Configuration:675 - processing foreign key constraints
08:24:12,772 INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.MySQLDia lect
08:24:12,787 INFO SettingsFactory:70 - Maximim outer join fetch depth: 2
08:24:12,788 INFO SettingsFactory:74 - Use outer join fetching: true
08:24:12,796 INFO C3P0ConnectionProvider:48 - C3P0 using driver: com.mysql.jdbc .Driver at URL: jdbc:mysql://localhost:3306/dating
08:24:12,797 INFO C3P0ConnectionProvider:49 - Connection properties: {user=dati ng, password=dating}
08:24:12,848 INFO TransactionFactoryFactory:31 - Transaction strategy: net.sf.h ibernate.transaction.JDBCTransactionFactory
08:24:12,855 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLoo kup configured (in JTA environment, use of process level read-write cache is not recommended)
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@1321f5 [ conn ectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@4788 d5 [ acquireIncrement -> 1, autoCommitOnClose -> false, connectionTesterClassNam e -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> n ull, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 1, maxIdleTime -> 360, maxPoolSize -> 10, maxStatements -> 50 , minPoolSize -> 1, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSou rce@1a6518 [ description -> null, driverClass -> null, factoryClassLocation -> n ull, jdbcUrl -> jdbc:mysql://localhost:3306/dating, properties -> {user=dating, password=dating} ] , propertyCycle -> 300, testConnectionOnCheckout -> false ] , factoryClassLocation -> null, numHelperThreads -> 3 ]
08:24:13,313 INFO SettingsFactory:114 - Use scrollable result sets: true
08:24:13,317 INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): true
08:24:13,320 INFO SettingsFactory:120 - Optimize cache for minimal puts: false
08:24:13,320 INFO SettingsFactory:126 - echoing all SQL to stdout
08:24:13,321 INFO SettingsFactory:129 - Query language substitutions: {}
08:24:13,322 INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache. EhCacheProvider
08:24:13,327 INFO Configuration:1130 - instantiating and configuring caches
08:24:13,339 WARN Configurator:125 - No configuration found. Configuring ehcach e from ehcache-failsafe.xml found in the classpath: file:/usr/local/jakarta-tomc at-5.0.28/work/Catalina/localhost/dating/loader/ehcache-failsafe.xml
08:24:13,380 INFO SessionFactoryImpl:119 - building session factory
08:24:13,709 WARN XMLDatabinder:261 - no XSLT implementation found - databindin g disabled
08:24:13,715 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
sFactory = net.sf.hibernate.impl.SessionFactoryImpl@191e4c

Name and version of the database you are using:
MySQL 4.1.11 under Debian Linux
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
log4j.properties
### 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=info, stdout

#log4j.logger.org.hibernate=info
log4j.logger.net.sf.hibernate=debug

### log JDBC bind parameters ###
#log4j.logger.org.hibernate.type=info
log4j.logger.net.sf.hibernate.type=debug

### log schema export/update ###
log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug

### log just the SQL
log4j.logger.net.sf.hibernate.SQL=debug

### log cache activity ###
log4j.logger.net.sf.hibernate.cache=info

### log JDBC resource acquisition
log4j.logger.net.sf.hibernate.jdbc=debug

### log PreparedStatement cache activity ###
log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=info

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace

I have tried hibernate with db connection pool (c3p0, dbcp ... or hibernate native) or without, JDK1.5.0.03 or scale back to JDK1.4.2, Tomcat 5.5.9 or scale back to Tomcat 5.0.28), utilize code from generated by HibernateSync or own java code to invoke hibernate ... but all does the same log4j log message which says "No configuration found.:

any commects are appreciated

max


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.