Ich versuche, ehcache in meiner Android App zu verwenden. Es schlägt in der ersten Zeile fehl. Das hat also nichts mit einer schlechten Cache-Konfiguration zu tun. Ich plane, Cache programmatisch zu konfigurieren, also habe ich keine Config-Dateien. Alles, was ich getan habe, war, ehcache als Abhängigkeit hinzuzufügen und die Methode unten aufzurufen. Mit ehcache 2.10.2java.lang.NullPointerException: parentLoader == null &&! NullAllowed
CacheManager singletonManager = CacheManager.create();
Stacktrace:
W/System.err: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
W/System.err: SLF4J: Defaulting to no-operation (NOP) logger implementation
W/System.err: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
E/AndroidRuntime: FATAL EXCEPTION: Thread-158
Process: test.app, PID: 7275
java.lang.ExceptionInInitializerError
at net.sf.ehcache.config.Configuration.<init>(Configuration.java:208)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:152)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:103)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:140)
at net.sf.ehcache.CacheManager.newInstance(CacheManager.java:892)
at net.sf.ehcache.CacheManager.create(CacheManager.java:873)
at test.app.MyCache.setup(MyCache.java:20)
Caused by: java.lang.NullPointerException: parentLoader == null && !nullAllowed
at java.lang.ClassLoader.<init>(ClassLoader.java:210)
at java.lang.ClassLoader.<init>(ClassLoader.java:202)
at net.sf.ehcache.EhcacheDefaultClassLoader.<init>(EhcacheDefaultClassLoader.java:35)
at net.sf.ehcache.EhcacheDefaultClassLoader.<clinit>(EhcacheDefaultClassLoader.java:26)
at net.sf.ehcache.config.Configuration.<init>(Configuration.java:208)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:152)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:103)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:140)
at net.sf.ehcache.CacheManager.newInstance(CacheManager.java:892)
at net.sf.ehcache.CacheManager.create(CacheManager.java:873)
at test.app.MyCache.setup(MyCache.java:20)
dasselbe Problem. Nach der Überprüfung, getInstance nur Anrufe erstellen – user1159819
Überprüfen Sie meine bearbeitete Antwort. Ich versuchte es. es behebt das Problem –
Das behebt das Problem nicht für mich, obwohl der SLF4J-Konfigurationsfehler wegging. Ich sehe das im Protokoll, aber ich glaube nicht, dass ich mich darum kümmern muss: System.err: [main] WARN net.sf.ehcache.config.ConfigurationFactory - Keine Konfiguration gefunden. Konfigurieren von ehcache aus ehcache-failsafe.xml im Klassenpfad: jar: file: /data/app/test.app-2/base.apk! /ehcache-failsafe.xml – user1159819