Problem with multithreaded cache manager acces - XmlConfiguration

311 views
Skip to first unread message

David Brodski

unread,
Jun 5, 2017, 7:42:24 PM6/5/17
to ehcache-users
  1. What version of Ehcache you are currently using;
    3.3.1
  2. Paste the configuration for the Cache/CacheManager you have an issue with;
    <?xml version="1.0" encoding="UTF-8"?>

    <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.3.xsd http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.3.xsd ">

      <thread-pools>
        <thread-pool alias="defaultPool" min-size="1" max-size="8"
          default="true" />
        <thread-pool alias="defaultDiskPool" min-size="1"
          max-size="8" />
        <thread-pool alias="defaultEventPool" min-size="1"
          max-size="8" />
      </thread-pools>

      <event-dispatch thread-pool="defaultEventPool" />
      <write-behind thread-pool="defaultDiskPool" />

      <cache-template name="containerCacheTemplate">
        <expiry>
          <tti unit="hours">1</tti>
        </expiry>
        <loader-writer>
          <class>java.lang.Object</class>
          <write-behind concurrency="1" size="50">
            <batching batch-size="5" coalesce="true">
              <max-write-delay unit="seconds">10</max-write-delay>
            </batching>
          </write-behind>
        </loader-writer>

        <resources>
          <heap unit="entries">150</heap>
          <offheap unit="GB">1</offheap>
        </resources>
      </cache-template>

      <cache-template name="projectsCacheTemplate">
        <expiry>
          <tti unit="hours">18</tti>
        </expiry>
        <resources>
          <heap unit="entries">50</heap>
        </resources>
      </cache-template>
    </config>
  3. Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate),
    non
  4. Providing JDK and OS versions maybe useful as well.
    Windows - jdk 8-131

When running my tests multithreaded I sometimes get the following error:


org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/C:/Projekte/.../target/testtemp/Test5854976511211866905/CacheConfig.xml
        at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:167)
        at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:131)
        ....
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.Suite.runChild(Suite.java:27)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:393)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
        at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory$XMLGrammarPoolWrapper.retrieveInitialGrammarSet(XMLSchemaFactory.java:510)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.initGrammarBucket(XMLSchemaLoader.java:1085)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.reset(XMLSchemaLoader.java:1008)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:559)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:538)
        at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:255)
        at org.ehcache.xml.ConfigurationParser.<init>(ConfigurationParser.java:155)
        at org.ehcache.xml.XmlConfiguration.parseConfiguration(XmlConfiguration.java:175)
        at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:163)
        ... 16 more


I think there is some locking missing, either on my side or on ehcache.

Is there something I have to lock before calling: new XmlConfiguration(dataDir.resolve(CACHE_CONFIG_FILE_NAME).toUri().toURL(), this.getClass().getClassLoader()) ?

I could not find anything in the documentation about needing lock before using the cache providers.


Thanks a lot,

David

Chris Dennis

unread,
Jun 8, 2017, 9:29:44 AM6/8/17
to ehcach...@googlegroups.com
Hi David,

You are right. I’ve filed https://github.com/ehcache/ehcache3/issues/2018 as a bug to track fixing this (more analysis there).

Thanks

Chris

> On Jun 5, 2017, at 7:42 PM, David Brodski <david....@bosch.com> wrote:
>
> • What version of Ehcache you are currently using;
> --
> You received this message because you are subscribed to the Google Groups "ehcache-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
> To post to this group, send email to ehcach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/1fc89e87-95a2-469a-962d-b237bdcc3f48%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages