Wildfly 10 Infinispan TreeCache is not working - wildfly

I'm migrating from Wildfly 8.2 to 10.1 Unfortunately, I'm encountering problems with Infinispan TreeCache.
Here are several issues:
Invocation batching is no longer supported in Wildfly 10
configuration
Here's my config:
<subsystem xmlns="urn:jboss:domain:infinispan:4.0">
...
<cache-container name="my_container" default-cache="my_tree_cache" jndi-name="java:jboss/my_container">
<transport lock-timeout="60000"/>
<local-cache name="my_cache"/>
<local-cache name="my_tree_cache" batching="true"/>
</cache-container>
</subsystem>
Error on startup:
> Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[345,17]
> Message: WFLYCTL0197: Unexpected attribute 'batching' encountered
If I remove "batching" attribute. I get this error:
com.daiwacm.modjsf.dataaccess.DataException: getTreeCache has failed for jndi value (my_tree_cache)
Caused by: org.infinispan.commons.CacheConfigurationException: invocationBatching is not
enabled for cache 'my_tree_cache'. Make sure this is enabled by calling configurationBuilder.invocationBatching().enable()
If I set batching programmatically:
Context context = new InitialContext();
CacheContainer cacheContainer = (CacheContainer) context.lookup(jndiName);
TreeCacheFactory tcf = new TreeCacheFactory();
Cache cache = cacheContainer.getCache(cacheName);
cache.getCacheManager().defineConfiguration(cacheName,
new ConfigurationBuilder().read(cache.getCacheConfiguration()).invocationBatching().enable().build());
TreeCache treeCache = tcf.createTreeCache(cache);
I get this error:
> Caused by: org.infinispan.commons.CacheConfigurationException:
> ISPN000381: This configuration is not supported for simple cache
> at org.infinispan.configuration.cache.ConfigurationBuilder.validateSimpleCacheConfiguration(ConfigurationBuilder.java:219)
> ...
> at org.infinispan.configuration.cache.InvocationBatchingConfigurationBuilder.build(InvocationBatchingConfigurationBuilder.java:12)
> ...

Don't set the configuration programmatically; I am not sure this is a valid approach, despite it seems to ~work.
The configuration option you're looking for is
<local-cache name="my_cache">
<transaction transaction-mode="BATCH" />
</local-cache>
(please consult the schema in docs/schema/jboss-as-infinispan_4_0.xsd should you have any doubts)
The last problem is that for local caches, WF automatically enables certain optimizations when it's possible. When you redefine the cache programmatically, this optimization (simple cache) is set on. So you'd have to set
new ConfigurationBuilder().read(cache.getCacheConfiguration())
.simpleCache(false)
.invocationBatching().enable()

Related

Infinispan Cache store - "class not found" Exception in wildlfy addon module

I am using the 11.0.7 Infinispan cache store which is configured with an XML file. I have imported that cache module in a Wildlfy server. I am using this dependency in my application. But when I try to fetch cache elements from cache, it gives me the exception ClassNotFound.
I have used this configuration:
<local-cache name="TaskStoreCache" statistics="false">
<locking acquire-timeout="60000" />
<persistence passivation="false">
<rocksdb-store path=" C:\CacheStore\Data\TaskStoreCache" preload="false" shared="false"
purge="false" read-only="false">
<expiration path="C: \CacheStore\Expired\TaskStoreCache"/>
</rocksdb-store>
</persistence>
<memory max-count="500"/>
<encoding media-type="application/x-java-object"/>
</local-cache>
And I used this serialization:
<serialization marshaller="org.infinispan.commons.marshall.JavaSerializationMarshaller">
<white-list>
<regex>com.xyz.cache.*</regex>
<regex>java.util.*</regex>
<regex>java.lang.*</regex>
</white-list>
</serialization>
I am sure it is a class loading related issue. Please help me with that.
You should double-check how the dependency is wrapped into your application (war/ear), and make sure the scope is correct.
If you did not pack it within your application, the module has to be present on your wildfly and known to your application (e.g. jboss-deployment-structure.xml)

Wildfly 18 - WFLYCTL0362: Capabilities required by resource '/subsystem=undertow/server=default-server/http-listener=http' are not available

I am migrating my jboss eap 6 to wildfly 18 as we are moving our application from java 6 to java 8 . I am new to wildfly 18, while starting the server I am getting below error -
09:22:59,671 ERROR [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0362: Capabilities required by resource '/subsystem=undertow/server=default-server/https-listener=https' are not available:
org.wildfly.network.socket-binding.https; Possible registration points for this capability:
/socket-binding-group=*/socket-binding=*
09:22:59,672 ERROR [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0362: Capabilities required by resource '/subsystem=undertow/server=default-server/http-listener=http' are not available:
org.wildfly.network.socket-binding.https; Possible registration points for this capability:
/socket-binding-group=*/socket-binding=*
09:22:59,678 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.**
09:22:59,698 INFO [org.jboss.as] (MSC service thread 1-6) WFLYSRV0050: WildFly Full 18.0.0.Final (WildFly Core 10.0.0.Final) stopped in 13ms
I changed socket bindinfs in standalone.xml file and standalone-ha.xmlAdded Socket binding changes in both files -
As i copied all these sockets from previous jboss eap 6 files.
Can i get explanation why these different 2 socket bindings needed and also worked in jboss?
What capabilities is it searching for? do i need to add some externals?
Need suggestions on this .. Do am i missing something in standalone.xml file? or package in module folder? I am confused, need to solve this issue as soon i can..
Thank you in advance!!
As #Shrishti Jain mentioned socket-binding for http would have not present in both standalone.xml and standalone-ha.xml which could be one possible reason for the error.
There is an another possibility for the above error.
As the console error log('/subsystem=undertow/server=default-server/http-listener=http' are not available) clearly gives a hint that http-listener for listener-name http under subsystem configuration for undertow server with the server name "default-server" is not available or not configured properly. The section you have to check is mentioned below
<!-- subsystem section for undertow server(subsystem=undertow/server) -->
<subsystem xmlns="urn:jboss:domain:undertow:3.1">
<buffer-cache name="default"/>
<!-- server=default-server -->
<server name="default-server">
<!-- http-listener=http -->
<http-listener name="http" socket-binding="http-new" max-post-size="6442450944" redirect-socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" max-post-size="6442450944" security-realm="SSLRealm" enable-http2="true"/>
....
</subsystem>
In the above snippet there are chances where the socket-binding of "http-new" might have not configured properly. In the above case the socket-binding of http-new is not present in <socket-binding-group>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
....
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
</socket-binding-group>
NOTE:
The issue causing listener's socket-binding configuration should exist in both standalone.xml and standalone-ha.xml files
For this error - https , management-https ports were missing in standalone-ha.xml. We have to sure it should be there in both standalone and standalone-ha xml files.

Infinispan cache table not auto-created with Wildfly 15+ using invalidation-cache and jdbc-store

I am attempting to use the jdbc-store type for my session cache in Wildfly 15+.
I ran the following commands to configure my standalone-full-ha.xml configuration file:
/subsystem=infinispan/cache-container=web/invalidation-cache=jdbc/:add(mode=SYNC)
/subsystem=infinispan/cache-container=web/invalidation-cache=jdbc/store=none:remove(){allow-resource-service-restart=true}
/subsystem=infinispan/cache-container=web/invalidation-cache=jdbc/store=jdbc/:add(data-source="...",passivation=false,shared=true){allow-resource-service-restart=true}
/subsystem=infinispan/cache-container=web/invalidation-cache=jdbc/component=transaction/:add()
/subsystem=infinispan/cache-container=web/invalidation-cache=jdbc/component=transaction/:write-attribute(name=mode,value=BATCH)
/subsystem=infinispan/cache-container=web:write-attribute(name=default-cache,value=jdbc)
... which produces the following in the configuration file:
<cache-container name="web" default-cache="jdbc" module="org.wildfly.clustering.web.infinispan">
<transport lock-timeout="60000"/>
<invalidation-cache name="jdbc">
<transaction mode="BATCH"/>
<jdbc-store data-source="..." passivation="false" shared="true">
<table/>
</jdbc-store>
</invalidation-cache>
<distributed-cache name="dist">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
<file-store/>
</distributed-cache>
</cache-container>
It looks like I've configured the cache correctly using JBoss CLI, but when the cluster instances start-up, the session store table is not created in the database, even though everything starts up properly.
My question is, is there something that I should be setting in the <table/> element that I'm just overlooking? Looking at the documentation, I don't see any required attributes, or anything about auto-creation.
I've looked at previous examples of how to achieve this in Wildfly 11, but the string-keyed-jdbc-store element no longer seems to be valid. I know the Infinispan documentation mentions the create-on-start attribute on the string-keyed-table element, but this configuration is so wildly different in Wildfly that it's completely unhelpful.
Add
<property name="createTableOnStart">
true
</property>
in your jdbc-store element
and make sure your web.xml is <distributable />

Wildfly 12 infinispan cache lookup is not working

I'm migration from wildfly 10 to wildfly 12. I have created local cache same as configured in wildfly 10.
standalone-full.xml configuration:
<cache-container name="DataCache" default-cache="modelcache" statistics-enabled="false">
<local-cache name="modelcache" statistics-enabled="false"/>
</cache-container>
Lookup code in singleton ejb annotated with #startup:
#Resource(lookup = "java:jboss/infinispan/container/DataCache")
private CacheContainer Container;
#PostConstruct
public void init() {
Container.start();
modelCache = Container.getCache("modelcache");
}
I'm getting the below exception while deploying file
Caused by:
org.infinispan.commons.CacheConfigurationException: ISPN000436: Cache 'modelcache' has been requested, but no cache configuration exists
with that name and no default cache has been set for this container
How to fix this?
Put
<resource-ref>
<res-ref-name>infinispan/DataCache</res-ref-name>
<lookup-name>java:jboss/infinispan/cache/DataCache/modelcache</lookup-name>
</resource-ref>
in jboss-web.xml. When requesting the cache do it like this (note that the name annotation property is used to specify the resource):
#Resource(name = "infinispan/DataCache")
private Cache<K, V> cache;
See this thread for more details: https://developer.jboss.org/thread/277425
Put the following entry in your project descriptor file (web.xml, ejb-jar.xml, etc)
<resource-ref>
<res-ref-name>infinispan/DataCache</res-ref-name>
<lookup-name>java:jboss/infinispan/container/DataCache</lookup-name>
</resource-ref>
For wildfly 10 you can lookup your infinispan cache or cache container in the following way
You need to define your cache in standalone-ha.xml(High availability) under the following subsystem
<cache-container name="myCacheContainer" default-cache="myCache" module="org.wildfly.clustering.ejb.infinispan">
<transport lock-timeout="60000"/>
<replicated-cache name="myCache">
<expiration lifespan="86400000" max-idle="3600000"/>
</replicated-cache>
</cache-container>
Once you have defined the cache you can lookup either the cache or the container.
2.a To lookup the cache you should setup a resource ref element in your project
descriptor file i.e (web.xml,jboss-web.xml etc.)
infinispan/myCache
java:jboss/infinispan/cache/myCacheContainer/myCache
2.b If you want to lookup cache container instead you also need to define configuration lookup in your project descriptor. So resource ref looks like this
<resource-ref>
infinispan/myCacheContainer
org.infinispan.manager.CacheContainer
java:jboss/infinispan/container/myCacheContainer
infinispan/myCache-config
org.infinispan.configuration.cache.Configuration
java:jboss/infinispan/configuration/myCacheContainer/default
Now if using spring you can do a JNDI lookup for cache like this
<jee:jndi-lookup id="myCache"
jndi-name="infinispan/myCache" />
3.a Or you can lookup the container like this
<jee:jndi-lookup id="myCacheContainer"
jndi-name="infinispan/myCacheContainer" />
Now you can inject the cache like the following
#Resource(name="myCache")
private Cache cache;
4.a You can inject the container like the following
#Resource(name="myCacheContainer")
private CacheContainer cacheContainer;

How to change JBoss eap 6.1 deployment folder

I'm trying to change deployment folder for JBoss without success.
Regarding some information which I've found on google I was trying to change standalone.xml configuration file. I've added following lines after <extensions> node :
<system-properties>
<property name="deploydir" value="/home/Artur"/>
</system-properties>
And I've changed <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1"> as following:
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="deployments" relative-to="deploydir" scan-interval="10000"/>
</subsystem>
I have the following path /home/Artur/deployments on my system.
But when i try to run JBoss server I always get an error :
09:05:21,283 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 2) JBAS014612: Operation ("add") failed - address: ([
("subsystem" => "deployment-scanner"),
("scanner" => "default")
]): java.lang.IllegalArgumentException: JBAS014847: Could not find a path called 'deployments'
I was trying to configure it with different paths on my system, I was checking also for spelling in every case. But nothing helps. Does anyone have and idea how to properly configure path for deployment folder in JBoss ? (version as in title)
OK I solved this issue. To change deployment directory it's needed to specyify path to this directory in block :
<paths>
<path name="deploydir" path="/home/Artur"/>
</paths>
instead of
<system-properties>
<property name="deploydir" value="/home/Artur"/>
</system-properties>
which I mentioned about earlier. So i conclusion we need to specify <path> node in standalone.xml configuration file and change <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1"> to point on newly created path (in this case to "deploydir")