Hello All.
I’m having some issues configuring EHCache with Hibernate 3.0 EJB3 annotations. I’m running everything on Tomcat 5.5, Oracle9i and Hibernate 3.0 (I’m hosting the app in Eclipse’s WTP, but the errors occur when launching Tomcat 5.5 standalone as well)
I keep getting this error:
2005-11-14 10:22:48,171 WARN [net.sf.ehcache.config.Configurator] - <No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/tools/Tomcat-5.5/common/lib/ehcache-1.1.jar!/ehcache-failsafe.xml>
2005-11-14 10:22:48,421 WARN [org.hibernate.cache.EhCacheProvider] - <Could not find configuration [com.mydomain.data.persistence.AssessmentItem]; using defaults.>
ehcache.xml is the root of my classes folder, the same folder as hibernate.cfg.xml. Does anyone have any idea of how to troubleshoot this issue?
Here’s the steps I’ve taken so far:
I can confirm that caching is working by viewing my SQL output and noticing that queries of cached objects are not being executed twice, as expected.
I’ve also successfully validated my ehcache.xml against the schema provided in their documentation. (using
http://tools.decisionsoft.com/schemaValidate.html)
I’ve confirmed the file is properly propagating:
Directory of C:\Files\Projects\LearningPath\JavaSource
11/08/2005 11:43a 2,271 assessments.hbm.xml
11/08/2005 11:32a 3,385 ehcache.xml
11/04/2005 04:04p 1,497 hibernate.cfg.xml
10/27/2005 01:31p 1,736 unit_test_hibernate.cfg.xml
Here’s my hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/StellaAssessment</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<mapping resource="assessments.hbm.xml"/>
<!-- <mapping class="com.mydomain.data.persistence.Assessment"/> -->
<mapping class="com.mydomain.data.persistence.AssessmentItem"/>
<mapping class="com.mydomain.data.persistence.HierarchyType"/>
<mapping class="com.mydomain.data.persistence.HierarchyInformation"/>
<mapping class="com.mydomain.data.persistence.Product"/>
<mapping class="com.mydomain.data.persistence.Owner"/>
<mapping class="com.mydomain.data.persistence.Remediation"/>
<mapping class="com.mydomain.data.persistence.RemediationCategory"/>
<mapping class="com.mydomain.data.persistence.RemediationType"/>
<mapping class="com.mydomain.data.persistence.RuntimeSessionInfo"/>
</session-factory>
</hibernate-configuration>
Here’s my warning
Nov 14, 2005 10:22:43 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-9080
Nov 14, 2005 10:22:43 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 719 ms
Nov 14, 2005 10:22:43 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Nov 14, 2005 10:22:43 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.9
Nov 14, 2005 10:22:43 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Nov 14, 2005 10:22:46 AM org.apache.catalina.startup.ContextConfig applicationWebConfig
INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[]
Nov 14, 2005 10:22:46 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-9080
Nov 14, 2005 10:22:46 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:9009
Nov 14, 2005 10:22:46 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/63 config=null
Nov 14, 2005 10:22:46 AM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Nov 14, 2005 10:22:46 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3484 ms
2005-11-14 10:22:48,171 WARN [net.sf.ehcache.config.Configurator] - <No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/tools/Tomcat-5.5/common/lib/ehcache-1.1.jar!/ehcache-failsafe.xml>
2005-11-14 10:22:48,421 WARN [org.hibernate.cache.EhCacheProvider] - <Could not find configuration [com.mydomain.data.persistence.AssessmentItem]; using defaults.>
2005-11-14 10:22:48,484 WARN [org.hibernate.cache.EhCacheProvider] - <Could not find configuration [com.mydomain.data.persistence.Product]; using defaults.>
2005-11-14 10:22:48,640 WARN [org.hibernate.cache.EhCacheProvider] - <Could not find configuration [com.mydomain.data.persistence.Remediation]; using defaults.>
2005-11-14 10:22:48,671 WARN [org.hibernate.cache.EhCacheProvider] - <Could not find configuration [com.mydomain.data.persistence.HierarchyInformation]; using defaults.>
Here’s a sample persistence file
package com.mydomain.data.persistence;
import javax.persistence.*;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import com.mydomain.data.TypesDAO;
/**
* This value object represents hierarchy information and is never mean to be constructed by user.
* It was created to accomodate normalized database structure.
* See Hierarchy object for useage details.
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name="seq0", sequenceName="hierarchy_information_seq")
@Table(name="hierarchy_information")
public class HierarchyInformation {
private int id;
private String name;
private String description;
private HierarchyType type;
/** This constructor is used primarily for hibernate. */
public HierarchyInformation(){}
protected HierarchyInformation(String name, String description, HierarchyType type){
setName(name);
setDescription(description);
setType(type);
}
protected HierarchyInformation(String name, String description, String type){
this(name, description, TypesDAO.getHierarchyType(type));
}
@Id(generate=GeneratorType.SEQUENCE, generator="seq0")
@Column(name="hierarchy_id")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="hierarchy_description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name="hierarchy_name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "hierarchy_type_id")
public HierarchyType getType() {
return type;
}
public void setType(HierarchyType type) {
this.type = type;
}
/**
* This method is used for developer debugging.
* If it's ever used in production, please update comments.
*/
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append(" id = " + id + "\n");
sb.append(" name = " + name + "\n");
sb.append(" description = " + description + "\n");
sb.append(" type = " + type + "\n");
return sb.toString();
}
}
Here’s my ehcache.xml
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"/>
<cache name="com.mydomain.data.persistence.AssessmentItem" maxElementsInMemory="10000" eternal="true" overflowToDisk="false"/>
<cache name="com.mydomain.data.persistence.Product" maxElementsInMemory="10000" eternal="true" overflowToDisk="false"/>
<cache name="com.mydomain.data.persistence.Remediation" maxElementsInMemory="10000" eternal="true" overflowToDisk="false"/>
<cache name="com.mydomain.data.persistence.HierarchyInformation" maxElementsInMemory="10000" eternal="true" overflowToDisk="false"/>
</ehcache>