I want EhCache to create caches using the default template. Here's my ehcache.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<config
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.0.xsd">
<service>
<jsr107:defaults default-template="default" jsr-107-compliant-atomics="true">
</jsr107:defaults>
</service>
<cache-template name="default">
<expiry>
<ttl unit="seconds">5</ttl>
</expiry>
<heap>100</heap>
</cache-template>
<!-- <cache alias="test" uses-template="default" />--> <!-- I want to omit this. -->
</config>
Here's my application.yml file:
spring:
cache:
jcache:
config: classpath:ehcache.xml
I don't want to have to update ehcache.xml every time I add need new cache name. How do I configure EhCache with Spring Boot to use my default Template?
If I don't specify the cache name configuration, I get this error:
java.lang.IllegalArgumentException: Cannot find cache named 'test' for CacheResultOperation
I believe you are missing this configuration:
properties.put("hibernate.javax.cache.missing_cache_strategy", "create-warn"); //Use create if you don't want to see a warning
Related
I've overridden \Magento\Checkout\Block\Cart\Item\Renderer and when I add this to the end of config in /app/etc/di.xml the override works.
<preference for="Magento\Checkout\Block\Cart\Item\Renderer" type="Tls\Module\Block\Cart\Item\Renderer" />
However, when I try to use /app/code/Tls/Module/etc/di.xml there is no effect. This is the contents of my di.xml (though I've tried many things)
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Block\Cart\Item\Renderer" type="Tls\Module\Block\Cart\Item\Renderer" />
</config>
Magento 2.2.4
I integrated SpringFramwork with Ehcache 3.x, and got exception when specified the key/value types in ehcache.xml. This is my configuration:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ehcache.org/v3" xmlns:jsr107="http://www.ehcache.org/v3/jsr107"
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.0.xsd">
<persistence directory="${user.home}/.ehcache" />
<cache alias="mycache">
<key-type>java.lang.String</key-type>
<value-type>java.lang.String</value-type>
<resources>
<offheap unit="GB">1</offheap>
<heap unit="MB">300</heap>
<disk unit="GB" persistent="true">10</disk>
</resources>
</cache>
and I get exception:Cache [XXX] specifies key/value types. Use getCache(String, Class, Class).
Here is the stacktrack:
Caused by: java.lang.IllegalArgumentException: Cache [homeFeeds] specifies key/value types. Use getCache(String, Class, Class)
at org.ehcache.jsr107.Eh107CacheManager.getCache(Eh107CacheManager.java:297)
at org.springframework.cache.jcache.JCacheCacheManager.loadCaches(JCacheCacheManager.java:105)
at org.springframework.cache.support.AbstractCacheManager.initializeCaches(AbstractCacheManager.java:61)
at org.springframework.cache.support.AbstractCacheManager.afterPropertiesSet(AbstractCacheManager.java:50)
at org.springframework.cache.jcache.JCacheCacheManager.afterPropertiesSet(JCacheCacheManager.java:97)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 35 more
Something wrong with my configuration?
I recommend you read my answer on this other question, that was very similar to yours, if not the same
Do I have to restart clickhouse to make it read any update to users.xml?
Is there a way to juse "reload" clickhouse?
These files are reloaded in runtime, no need to restart the server.
As you can notice config folder has several files, like
config-preprocessed.xml
config.xml
users-preprocessed.xml
users.xml
.*-preprocessed.xml are for parsed config so you will see when it is loaded and parsed.
I wouldn't recommend to modify files '/etc/clickhouse-server/config.xml' or 'etc/clickhouse-server/user.xml' because it will be rewritten after upgrading ClickHouse and you will lose custom settings.
The subfolder '/etc/clickhouse-server/config.d/' and '/etc/clickhouse-server/users.d/' serve to store overrides for 'config.xml' and 'user.xml' relatively.
Example overrides for 'config.xml':
config.d/config.xml
<?xml version="1.0"?>
<yandex>
<listen_host replace="replace">::</listen_host>
<dictionaries_config replace="replace">dictionaries/*.xml</dictionaries_config>
<openSSL>
<client>
<verificationMode replace="replace">none</verificationMode>
</client>
</openSSL>
</yandex>
config.d/cluster.xml
<?xml version="1.0"?>
<yandex>
<remote_servers>
<your_cluster>
<!-- topology definition -->
</your_cluster>
</remote_servers>
<zookeeper>
<!-- .. -->
</zookeeper>
</yandex>
config.d/kafka.xml
<?xml version="1.0"?>
<yandex>
<!-- The default configuration for Kafka Engine Table (https://clickhouse.yandex/docs/en/operations/table_engines/kafka/#configuration). -->
<kafka>
<bootstrap_servers>11.22.33.44:6667,11.22.33.55:6667,11.22.33.66:6667</bootstrap_servers>
<auto_offset_reset>latest</auto_offset_reset>
</kafka>
<!-- The Topics configurations. -->
<kafka_topic_name>
<group_id>clickhouse-group_id</group_id>
</kafka_topic_name>
</yandex>
Example overrides for 'users.xml':
users.d/user.xml
<?xml version="1.0"?>
<yandex>
<users>
<default>
<password replace="replace">hello_clickhouse</password>
</default>
<readonly>
<password replace="replace">hello</password>
</readonly>
</users>
</yandex>
Another example of config overrides.
See for details ClickHouse Configuration files.
I can't seem to get this working locally, even though the same WAR works on a remote server. When I go to visit my application locally, I get the "Context Root Not Found" error. The Liberty profile version is 8.5.5.5.
Here are the relevant files:
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="tlc server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
<feature>ssl-1.0</feature>
<feature>localConnector-1.0</feature>
<feature>restConnector-1.0</feature>
<feature>json-1.0</feature>
<feature>jaxrs-1.1</feature>
<feature>servlet-3.0</feature>
<feature>jpa-2.0</feature>
<feature>beanValidation-1.0</feature>
<feature>jndi-1.0</feature>
<feature>jdbc-4.0</feature>
<feature>monitor-1.0</feature>
</featureManager>
<httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443" virtualHost="default_host" />
<jdbcDriver id="DerbyJDBCDriver">
<library name="DerbyLib">
<fileset dir="C:\tools\servers\wlp\lib" includes="derbyclient-10.6.1.0.jar" />
</library>
</jdbcDriver>
<dataSource jndiName="jdbc/TLCDataSource" id="derbyDataSource" jdbcDriverRef="DerbyJDBCDriver">
<properties.derby.client databaseName="TLC" password="APP" user="APP" />
</dataSource>
<applicationMonitor updateTrigger="mbean" />
<application id="TLC_war" context-root="/TLC" location="C:\Users\nd26434\gitrepos\tlc\target\TLC-1.0.0-SNAPSHOT.war" name="TLC_war" type="war">
<classloader delegation="parentLast">
<privateLibrary>
<fileset dir="C:\tools\servers\wlp\lib" includes="aspectjweaver-1.8.0.jar" />
</privateLibrary>
</classloader>
</application>
</server>
message.log
[3/18/15 20:19:54:789 EDT] 0000001b com.ibm.ws.app.manager.AppMessageHelper A CWWKZ0022W: Application TLC_war has not started in 30.018 seconds.
[3/18/15 20:20:03:174 EDT] 0000001f com.ibm.ws.webcontainer.osgi.webapp.WebGroup I SRVE0169I: Loading Web Module: TLC-1.0.0-SNAPSHOT.
[3/18/15 20:20:03:175 EDT] 0000001f com.ibm.ws.webcontainer I SRVE0250I: Web Module TLC-1.0.0-SNAPSHOT has been bound to tlc_host.
ibm-web-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="tlc_host"/>
<resource-ref name="jdbc/TLCDataSource"
binding-name="jdbc/TLCDataSource" />
</web-bnd>
ibm-web-ext.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<reload-interval value="3"/>
<context-root uri="TLC" />
<enable-directory-browsing value="false"/>
<enable-file-serving value="true"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="false" />
</web-ext>
Remove <virtual-host name="tlc_host"/> from your ibm-web-ext.xml file. As you dont have tlc_host, but default_host.
Context Root Not found is caused due to issue in one of the config files.
In my case, web.xml had an unclosed comment due to which the war was not built correctly.
This resulted in EAR file not updating.
Solution:
Compare you web.xml with previous versions to see what changed.
Add war to the server instead of the ear file to see the error. (If Running on Liberty Server)
Bean Decleration:
bean id="cacheManager" class="org.infinispan.spring.provider.SpringEmbeddedCacheManagerFactoryBean"
p:configurationFileLocation="classpath:infinispan.xml" ..
infinispan.xml
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
xmlns="urn:infinispan:config:5.1">
<global>
<transport clusterName="CASCluster"/>
<globalJmxStatistics enabled="true"/>
</global>
<default>
<jmxStatistics enabled="true"/>
<clustering mode="distribution">
<hash numOwners="2" rehashRpcTimeout="120000"/>
<sync/>
</clustering>
</default>
<namedCache name="mtx.infinispan.global">
<eviction strategy="LIRS" maxEntries="50000" />
</namedCache>
<namedCache name="books">
<eviction strategy="LIRS" maxEntries="50000" />
</namedCache>
<namedCache name="scheduleprofiletemplates">
<eviction maxEntries="1000000" strategy="LIRS" />
<loaders passivation="false" shared="false" preload="true">
<!-- We can have multiple cache loaders, which get chained -->
<loader class="org.infinispan.loaders.file.FileCacheStore"
fetchPersistentState="true" purgerThreads="3" purgeSynchronously="true"
ignoreModifications="false" purgeOnStartup="false">
<!-- See the documentation for more configuration examples and flags. -->
<properties>
<property name="location" value="/home/cas/infinispanCache" />
</properties>
</loader>
</loaders>
</namedCache>
I want deploy the application Jboss cluster so that the cache created in one node is accessible/replicated to other node also....
I am using Jboss Domain mode full-ha for the deployment....I have HornetQ, Mod_cluster working properly on the same cluster.
By googling, I cam to know that it achieving thru JNDI....Can you pls tel how to modify the XMl files to achiiev this....I have to create 4 named cache(Where to create this ? In sping config file or Jboss domain.xml).
Thanks in advance
Create a Jboss cluster full-ha profile.
2.Create queus on Jboss side
3.Ovveride the SpringEmbeddedCacheManagerFactoryBean cacheManager