Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-17079

Fuse 7 standalone:camel-ehcache option `configurationUri` doesn't work in Karaf

XMLWordPrintable

    • False
    • False
    • % %
    • +
    • Automated
    • Undefined
    • Hide

      The workaround is to configure the endpoint with the CacheManager using and the right classloader.

      For example:

      public final class XmlCacheManagerBuilder {
        private static CacheManager cacheManager;
        
        public static CacheManager createCacheManager() {
          ClassLoader cl = Thread.currentThread().getContextClassLoader();
          try {
            URL url = XmlCacheManagerBuilder.class.getResource("/ehcache-config.xml");
            Thread.currentThread().setContextClassLoader(CacheManager.class.getClassLoader());
            XmlConfiguration xmlConfiguration = new XmlConfiguration(url);
            cacheManager = CacheManagerBuilder.newCacheManager((Configuration)xmlConfiguration);
            cacheManager.init();
          } finally {
            Thread.currentThread().setContextClassLoader(cl);
          } 
          return cacheManager;
        }
        
        public static CacheManager getCacheManager() {
          return cacheManager;
        }
      }
          <?xml version="1.0" encoding="UTF-8"?><blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xsi:schemaLocation="   http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd   http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           
                  <bean id="cacheManager" class="org.jboss.qe.camel.components.ehcache.XmlCacheManagerBuilder" factory-method="createCacheManager"/>
           
                  <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="ehcache">
                          <route>
                                  <from uri="direct:start"/>
                                  <to uri="ehcache://mycache?cacheManager=#cacheManager"/>
                                  <to uri="log:org.apache.camel.component.ehcache?level=INFO&amp;showAll=true&amp;multiline=true"/>
                                  <to uri="mock:result"/>
                          </route>
                  </camelContext>
          </blueprint>
      
      Show
      The workaround is to configure the endpoint with the CacheManager using and the right classloader. For example: public final class XmlCacheManagerBuilder { private static CacheManager cacheManager; public static CacheManager createCacheManager() { ClassLoader cl = Thread .currentThread().getContextClassLoader(); try { URL url = XmlCacheManagerBuilder. class. getResource( "/ehcache-config.xml" ); Thread .currentThread().setContextClassLoader(CacheManager. class. getClassLoader()); XmlConfiguration xmlConfiguration = new XmlConfiguration(url); cacheManager = CacheManagerBuilder.newCacheManager((Configuration)xmlConfiguration); cacheManager.init(); } finally { Thread .currentThread().setContextClassLoader(cl); } return cacheManager; } public static CacheManager getCacheManager() { return cacheManager; } } <?xml version= "1.0" encoding= "UTF-8" ?> <blueprint xmlns= "http://www.osgi.org/xmlns/blueprint/v1.0.0" xsi:schemaLocation= " http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" > <bean id= "cacheManager" class= "org.jboss.qe.camel.components.ehcache.XmlCacheManagerBuilder" factory-method= "createCacheManager" /> <camelContext xmlns= "http://camel.apache.org/schema/blueprint" id= "ehcache" > <route> <from uri= "direct:start" /> <to uri= "ehcache://mycache?cacheManager=#cacheManager" /> <to uri= "log:org.apache.camel.component.ehcache?level=INFO&amp;showAll=true&amp;multiline=true" /> <to uri= "mock:result" /> </route> </camelContext> </blueprint>

      Using the ehcache configuration with the `configurationUri`

        <from uri="ehcache://testcache?configurationUri=ehcache.xml"/>
      

      fails with the following root exception

      Caused by: javax.xml.bind.JAXBException: "org.ehcache.xml.model" doesnt contain ObjectFactory.class or jaxb.index
      

      Is probably related to the ENTESB-16576

            ggrzybek Grzegorz Grzybek
            rhn-support-agagliar Antonio Gagliardi
            Federico Mariani Federico Mariani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: