-->
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.  [ 7 posts ] 
Author Message
 Post subject: problem: ehcache.xml not found
PostPosted: Mon Mar 03, 2008 7:06 am 
Newbie

Joined: Tue May 22, 2007 10:52 am
Posts: 13
Hi,

I cannot enable the second level cache using EHcache. I have followed the instructions, and at deployment the ehcache.xml file seems not to be found, even though it is placed inside war
in WEB-INF/classes( More specific: the application is called ibxrequest.ear, and the ehcache.xml has the path: ibxrequest.ear\ibxrequest.war\WEB-INF\classes\ehcache.xml)

We are using JBoss 4.2.0 as an application server. Below is a list of logs, configurations, etc.

Please help!
Thanks

Hibernate version:
[Version] Hibernate Annotations 3.3.0.GA
[Environment] Hibernate 3.2.4.sp1
[Version] Hibernate EntityManager 3.3.1.GA
[Version] Hibernate Validator 3.0.0.GA
[Version] Hibernate Search 3.0.0.GA

persistence.xml:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0">

<persistence-unit name="ibxrequest">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/ibxrequestDatasource</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.cache.use_query_cache" value="true"/>

<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
<property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml"/>

<property name="jboss.entity.manager.factory.jndi.name" value="java:/ibxrequestEntityManagerFactory"/>
<property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="hibernate.default_schema" value="dbo"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>

</properties>
</persistence-unit>

</persistence>

ehcache.xml:
<ehcache>
<diskStore path="java.io.tmpdir"/>

<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>

<cache name="com.ibx.ibxrequest.model.CoreMessageBuyerTranslation"
maxElementsInMemory="300"
timeToIdleSeconds="0"
timeToLiveSeconds="600"
eternal="false"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>

</ehcache>

The entity that has second level cache enabled:

package com.ibx.ibxrequest.model;
@Entity
@Table(name = "CORE_MessageBuyerTranslation", uniqueConstraints = {})
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region="com.ibx.ibxrequest.model.CoreMessageBuyerTranslation")
public class CoreMessageBuyerTranslation implements java.io.Serializable {
...
}

Name and version of the database and driver:
[SettingsFactory] RDBMS: Microsoft SQL Server, version: 08.00.2039
[SettingsFactory] JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2
[Dialect] Using dialect: org.hibernate.dialect.SQLServerDialect

Debug level Hibernate log excerpt:
2008-03-03 12:47:23,520 INFO (org.hibernate.cfg.SettingsFactory.buildSettings:235) Second-level cache: enabled
2008-03-03 12:47:23,520 INFO (org.hibernate.cfg.SettingsFactory.createCacheProvider:373) Cache provider: org.hibernate.cache.EhCacheProvider
2008-03-03 12:47:23,535 INFO (org.hibernate.cfg.SettingsFactory.buildSettings:254) Optimize cache for minimal puts: disabled
2008-03-03 12:47:23,535 INFO (org.hibernate.cfg.SettingsFactory.buildSettings:259) Cache region prefix: ibxrequest_ear,ibxrequest_jar,ibxrequest
2008-03-03 12:47:23,535 INFO (org.hibernate.cfg.SettingsFactory.buildSettings:263) Structured second-level cache entries: disabled
2008-03-03 12:47:23,535 INFO (org.hibernate.cfg.SettingsFactory.createQueryCacheFactory:360) Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
2008-03-03 12:47:24,504 DEBUG (org.hibernate.cache.EhCacheProvider.loadResource:146) Creating EhCacheProvider from a specified resource: /ehcache.xml Resolved to URL: null
2008-03-03 12:47:27,926 DEBUG (org.hibernate.cache.CacheFactory.createCache:39) instantiating cache region: ibxrequest_ear,ibxrequest_jar,ibxrequest.com.ibx.ibxrequest.model.CoreMessageBuyerTranslation usage strategy: nonstrict-read-write
2008-03-03 12:47:27,926 WARN (org.hibernate.cache.EhCacheProvider.buildCache:86) Could not find configuration [ibxrequest_ear,ibxrequest_jar,ibxrequest.com.ibx.ibxrequest.model.CoreMessageBuyerTranslation]; using defaults.
2008-03-03 12:47:27,957 DEBUG (org.hibernate.cache.EhCacheProvider.buildCache:89) started EHCache region: ibxrequest_ear,ibxrequest_jar,ibxrequest.com.ibx.ibxrequest.model.CoreMessageBuyerTranslation
2008-03-03 12:47:35,066 INFO (org.hibernate.cache.UpdateTimestampsCache.<init>:41) starting update timestamps cache at region: ibxrequest_ear,ibxrequest_jar,ibxrequest.org.hibernate.cache.UpdateTimestampsCache
2008-03-03 12:47:35,066 WARN (org.hibernate.cache.EhCacheProvider.buildCache:86) Could not find configuration [ibxrequest_ear,ibxrequest_jar,ibxrequest.org.hibernate.cache.UpdateTimestampsCache]; using defaults.
2008-03-03 12:47:35,066 DEBUG (org.hibernate.cache.EhCacheProvider.buildCache:89) started EHCache region: ibxrequest_ear,ibxrequest_jar,ibxrequest.org.hibernate.cache.UpdateTimestampsCache
2008-03-03 12:47:35,082 INFO (org.hibernate.cache.StandardQueryCache.<init>:52) starting query cache at region: ibxrequest_ear,ibxrequest_jar,ibxrequest.org.hibernate.cache.StandardQueryCache
2008-03-03 12:47:35,082 WARN (org.hibernate.cache.EhCacheProvider.buildCache:86) Could not find configuration [ibxrequest_ear,ibxrequest_jar,ibxrequest.org.hibernate.cache.StandardQueryCache]; using defaults.
2008-03-03 12:47:35,098 DEBUG (org.hibernate.cache.EhCacheProvider.buildCache:89) started EHCache region: ibxrequest_ear,ibxrequest_jar,ibxrequest.org.hibernate.cache.StandardQueryCache


2008-03-03 12:47:24,488 DEBUG (org.hibernate.impl.SessionFactoryImpl.<init>:177) instantiating session factory with properties: {java.vendor=Sun Microsystems Inc., sun.java.launcher=SUN_STANDARD, catalina.base=C:\Program Files\jboss-4.2.0.GA\server\default, sun.management.compiler=HotSpot Server Compiler, hibernate.ejb.discard_pc_on_close=false, catalina.useNaming=false, hibernate.transaction.flush_before_completion=false, os.name=Windows XP, sun.boot.class.path=C:\Program Files\jboss-4.2.0.GA\lib\endorsed\serializer.jar;C:\Program Files\jboss-4.2.0.GA\lib\endorsed\xalan.jar;C:\Program Files\jboss-4.2.0.GA\lib\endorsed\xercesImpl.jar;D:\Programs\jdk1.5.0_11\jre\lib\rt.jar;D:\Programs\jdk1.5.0_11\jre\lib\i18n.jar;D:\Programs\jdk1.5.0_11\jre\lib\sunrsasign.jar;D:\Programs\jdk1.5.0_11\jre\lib\jsse.jar;D:\Programs\jdk1.5.0_11\jre\lib\jce.jar;D:\Programs\jdk1.5.0_11\jre\lib\charsets.jar;D:\Programs\jdk1.5.0_11\jre\classes, sun.desktop=windows, hibernate.c3p0.max_size=200, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_11-b03, hibernate.connection.autocommit=true, hibernate.c3p0.min_size=5, ibxrequest.jobs.execute=false, hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider, user.name=agheorghe, shared.loader=, jboss.remoting.version=22, jboss.bind.address=127.0.0.1, tomcat.util.buf.StringCache.byte.enabled=true, hibernate.session_factory_name=persistence.units:ear=ibxrequest.ear,jar=ibxrequest.jar,unitName=ibxrequest, hibernate.connection.release_mode=auto, jboss.remoting.instanceid=727dd148fb073293x68c245b5x113531def34x-8000364, hibernate.c3p0.timeout=1800, jboss.home.dir=C:\Program Files\jboss-4.2.0.GA, com.arjuna.common.util.logging.DebugLevel=0x00000000, user.language=en, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, sun.boot.library.path=D:\Programs\jdk1.5.0_11\jre\bin, hibernate.jndi.java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, com.arjuna.ats.jta.lastResourceOptimisationInterface=org.jboss.tm.LastResource, jboss.home.url=file:/C:/Program Files/jboss-4.2.0.GA/, java.version=1.5.0_11, user.timezone=Europe/Athens, jboss.server.home.dir=C:\Program Files\jboss-4.2.0.GA\server\default, hibernate.bytecode.provider=javassist, sun.arch.data.model=32, java.endorsed.dirs=C:\Program Files\jboss-4.2.0.GA\lib\endorsed, jboss.server.home.url=file:/C:/Program Files/jboss-4.2.0.GA/server/default/, sun.cpu.isalist=, sun.jnu.encoding=Cp1252, file.encoding.pkg=sun.io, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, hibernate.format_sql=false, com.arjuna.ats.tsmx.agentimpl=com.arjuna.ats.internal.jbossatx.agent.LocalJBossAgentImpl, java.class.version=49.0, jboss.server.config.url=file:/C:/Program Files/jboss-4.2.0.GA/server/default/conf/, user.country=US, java.home=D:\Programs\jdk1.5.0_11\jre, java.vm.info=mixed mode, jboss.lib.url=file:/C:/Program Files/jboss-4.2.0.GA/lib/, os.version=5.1, hibernate.jndi.java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces, hibernate.jacc.ctx.id=ibxrequest.jar, hibernate.transaction.factory_class=org.hibernate.ejb.transaction.JoinableCMTTransactionFactory, hibernate.query.jpaql_strict_compliance=true, path.separator=;, java.vm.version=1.5.0_11-b03, user.variant=, java.protocol.handler.pkgs=org.jboss.net.protocol, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., com.arjuna.common.util.logger=log4j_releveler, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces, hibernate.cache.region_prefix=ibxrequest_ear,ibxrequest_jar,ibxrequest, jboss.server.temp.dir=C:\Program Files\jboss-4.2.0.GA\server\default\tmp, java.rmi.server.RMIClassLoaderSpi=org.jboss.system.JBossRMIClassLoader, user.home=C:\Documents and Settings\agheorghe.TSWARP, sun.rmi.dgc.client.gcInterval=3600000, jboss.identity=727dd148fb073293x68c245b5x113531def34x-8000364, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=validate, java.vendor.url=http://java.sun.com/, java.library.path=D:\Programs\jdk1.5.0_11\bin;.;C:\WINDOWS\system32;C:\WINDOWS;D:\Programs\jdk1.5.0_11\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;D:\Programs\OpenSSL\bin;D:\Programs\apache-ant-1.6.5\bin;D:\Programs\maven-2.0.6\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Subversion\bin;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\MSSQL7\BINN, program.name=run.bat, hibernate.connection.driver_class=net.sourceforge.jtds.jdbc.Driver, java.vm.vendor=Sun Microsystems Inc., sun.rmi.dgc.server.gcInterval=3600000, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=D:\Programs\jdk1.5.0_11\lib\tools.jar;C:\Program Files\jboss-4.2.0.GA\bin\run.jar, hibernate.bytecode.use_reflection_optimizer=false, jboss.server.log.dir=C:\Program Files\jboss-4.2.0.GA\server\default\log, jbossmx.loader.repository.class=org.jboss.mx.loading.UnifiedLoaderRepository3, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, jboss.remoting.domain=JBOSS, catalina.home=C:\Program Files\jboss-4.2.0.GA\server\default, jboss.server.lib.url=file:/C:/Program Files/jboss-4.2.0.GA/server/default/lib/, sun.os.patch.level=Service Pack 2, sun.cpu.endian=little, com.arjuna.common.util.logging.VisibilityLevel=0xffffffff, hibernate.cache.use_query_cache=true, hibernate.connection.provider_class=org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider, com.arjuna.ats.arjuna.objectstore.objectStoreDir=C:\Program Files\jboss-4.2.0.GA\server\default\data/tx-object-store, java.io.tmpdir=C:\DOCUME~1\AGHEOR~1.TSW\LOCALS~1\Temp\, java.rmi.server.codebase=http://127.0.0.1:8083/, TSMX_VERSION=unknown, org.w3c.dom.DOMImplementationSourceList=org.apache.xerces.dom.DOMXSImplementationSourceImpl, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=, hibernate.default_schema=dbo, jboss.server.data.dir=C:\Program Files\jboss-4.2.0.GA\server\default\data, java.rmi.server.hostname=127.0.0.1, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, os.arch=x86, jboss.remoting.jmxid=agheorghe_1204541180145, java.ext.dirs=D:\Programs\jdk1.5.0_11\jre\lib\ext, user.dir=C:\Program Files\jboss-4.2.0.GA\bin, PROPERTIES_FILE=tsmx.properties, jboss.entity.manager.factory.jndi.name=java:/ibxrequestEntityManagerFactory, line.separator=
, java.vm.name=Java HotSpot(TM) Server VM, jboss.server.base.dir=C:\Program Files\jboss-4.2.0.GA\server, org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger, com.arjuna.common.util.logging.FacilityLevel=0xffffffff, hibernate.cache.provider_configuration_file_resource_path=/ehcache.xml, hibernate.cache.use_second_level_cache=true, jboss.server.base.url=file:/C:/Program Files/jboss-4.2.0.GA/server/, javax.management.builder.initial=org.jboss.mx.server.MBeanServerBuilderImpl, file.encoding=Cp1252, hibernate.use_identifier_rollback=false, catalina.ext.dirs=C:\Program Files\jboss-4.2.0.GA\server\default\lib, hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup, java.specification.version=1.5, jboss.server.name=default, hibernate.c3p0.max_statements=50, hibernate.show_sql=true}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 7:08 am 
Newbie

Joined: Tue May 22, 2007 10:52 am
Posts: 13
I am using ehcache.jar version 1.4.1


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 9:59 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Hi andreigh.ts,

i think you just have to change "value="/ehcache.xml"/> " to
Code:
value="ehcache.xml"
and the configuration file should be findable by the runtime.

My persistence.xml - residing in META-INF directory, which is a child of the root class path - does the same. I put ehcache.xml just into the root directory of the classpath (in the jar).

Carlo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 10:43 am 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
Why do you have to mention the path of ehcache, unless it is kep in a different directory other than root of the of your src directory.

I think the following property is not required.

Code:
<property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml"/>


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 12:55 pm 
Newbie

Joined: Tue May 22, 2007 10:52 am
Posts: 13
I changed path to:

<property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache.xml"/>

and now I put the ehcache.xml in the ear root (instead of webinf/classes)

Now it finds the file. However, it was another problem, it seems that the name of the cache configuration was wrong. For an unknown reason, hibernate/ehcache is looking for a weird prefix, and the configuration should be something like:


<cache name="ibxrequest_ear,ibxrequest_jar,ibxrequest.com.ibx.ibxrequest.model.CoreMessageBuyerTranslation"
.....

Now it works.


Top
 Profile  
 
 Post subject: Re: problem: unable to cache the Named Query more than 2 minutes
PostPosted: Wed Jul 22, 2009 3:42 am 
Newbie

Joined: Tue Jul 21, 2009 5:07 am
Posts: 3
Hi,



Really the information posted above is uiseful.

One query, I am trying to cache named queries in JPA, to cache the Named Query results for a particular time period of more than 20 minutes.

I have written the ehcache.xml and defined the same reference in the persistence.xml, In the Entity option object, for the Named Query I have defined the Hints --> QueryHint = cacheable to true and the region.

But the query is being cached for only 2 minutes(120seconds). I would like to cache the query about 20 minutes.


Please find the below are the code in persistence.xml, ehcache.xml, POJO(Example: Option.java) and DAO(OptionDAO.java).



POJO(Option.java):

@NamedQuery(name = "findOptionsByLineOfBusinessAndStatus", query = "from Option where uniqueOptionKey.lineOfBusinessId= :lineOfBusiness AND optionStatus= :stateCode", hints = { @QueryHint(name = "org.hibernate.cacheable", value = "true"), @QueryHint(name = "org.hibernate.cacheRegion", value = "query.AdministrativeAreasPerCountry") })



persistence.xml:

<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.generate_statistics" value="true"/>
<property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache.xml"/> <!-- ehcache.xml is along with the persistence.xml in META-INF-->


ehcache.xml

<ehcache>
<diskStore path="c:\\web\\"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="360000"
timeToLiveSeconds="360000"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="360000"
memoryStoreEvictionPolicy="LRU"
/>

<cache name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="360000"
timeToLiveSeconds="360000"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="360000"
memoryStoreEvictionPolicy="LRU"
/>

<cache name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="360000"
timeToLiveSeconds="360000"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="360000"
memoryStoreEvictionPolicy="LRU"
/>

<cache name="query.AdministrativeAreasPerCountry"
maxElementsInMemory="500"
eternal="false"
timeToIdleSeconds="180000"
timeToLiveSeconds="864000"
overflowToDisk="true"/>
</ehcache>



OptionDAO:

Query query = getEntityManager().createNamedQuery("from Option where uniqueOptionKey.lineOfBusinessId= :lineOfBusiness AND optionStatus= :stateCode)";
query.setParameter(LINE_OF_BUSINESS, lineOfBusiness);
query.setParameter(STATE_CODE, stateCode);

options = (List<Option>) query.getResultList();


Could you please provide some information on the same. where exactly is missing the configuration properties being set are overridden to the default. The query being cached for 2 minutes is the default time to cache.


Thanks and Regards,
Jayadev S


Top
 Profile  
 
 Post subject: Re: problem: ehcache.xml not found
PostPosted: Wed Dec 16, 2009 2:06 pm 
Newbie

Joined: Wed Dec 16, 2009 12:31 pm
Posts: 1
I lost a few hours to this issue. It turned out the problem was having ehcache-core.jar in the JBoss server/default/lib directory. When I removed it from there and added it to the ear file's lib directory, ehcache was able to find the ehcache.xml file located in the root of the ear.


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

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.