Cannot enter seam provider

Env: Seam 2.2, ehcache-core 2.1.0

I tried to enter CacheProvider using the following call in my bean for the session

    @In CacheProvider cacheProvider;

    WEB-INF\components.xml contains the following line to enable the cache provider
    <cache:eh-cache-provider/>

The above configuration seems to return a null value for the cache provider


Using the cache provider like this         
CacheProvider cacheProvider = CacheProvider.instance();
throws the following warning

    15:29:27,586 WARN [CacheManager] Creating a new instance of CacheManager using
    the diskStorePath "C:\DOCUME~1\user5\LOCALS~1\Temp\" which is already used by an
    existing CacheManager.
    The source of the configuration was net.sf.ehcache.config.generator.Configuratio
    nSource$DefaultConfigurationSource@15ed0f9.
    The diskStore path for this CacheManager will be set to C:\DOCUME~1\user5\LOCALS
    ~1\Temp\\ehcache_auto_created_1276682367586.
    To avoid this warning consider using the CacheManager factory methods to create
    a singleton CacheManager or specifying a separate ehcache configuration (ehcache
    .xml) for each CacheManager instance.

What am I missing here?

+3
source share
1 answer

Keep in mind that net.sf.ehcache.Cache should be in the classpath (I'm not sure, but I think ehcache-core.jar contains this class) if you want to use EhCahceProvider. Here is his signature

@Name("org.jboss.seam.cache.cacheProvider")
@Scope(APPLICATION)
@BypassInterceptors
@Install(value = false, precedence=BUILT_IN, classDependencies="net.sf.ehcache.Cache")
@AutoCreate
public class EhCacheProvider extends CacheProvider<CacheManager> {

Note the classDependencies attribute. Its documentation is understandable.

Indicates that the component should not be installed unless class definitions are specified in the classpath

, classpath net.sf.ehcache.Cache ,

<cache:eh-cache-provider/>

, , @In-jection,

ApplicationContext.getContext().get("cacheProvider");

UPDATE

  • < cache: eh-cache-provider/ > . , (. ).

-,

  • , CacheProvider null, @In true, . - , CacheProvider .

    assert cacheProvider!= null

-,

  • , cacheProvider.instance(). . CacheProvider??? .

-,

  • . , ,
+1

Source: https://habr.com/ru/post/1750266/


All Articles