I just upgraded to Apache Cayenne 4.0 M5 and I got the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/cache/CacheManager at org.apache.cayenne.jcache.JCacheModule.configure(JCacheModule.java:44) at org.apache.cayenne.di.spi.DefaultInjector.(DefaultInjector.java:68) at org.apache.cayenne.di.DIBootstrap.createInjector(DIBootstrap.java:38) at org.apache.cayenne.di.DIBootstrap.createInjector(DIBootstrap.java:46) at org.apache.cayenne.configuration.CayenneRuntime.(CayenneRuntime.java:79) at org.apache.cayenne.configuration.server.ServerRuntime.(ServerRuntime.java:128) at org.apache.cayenne.configuration.server.ServerRuntimeBuilder.build(ServerRuntimeBuilder.java:234) at com.company.databases.postgresql.financedb.runtime.FinanceDBRuntime.getFinanceAccountsDBPostgreSQLRuntime(FinanceDBRuntime.java:11)
The changes I did was changing from new ServerRuntime("configfile") (which was flagged deprecated) to ServerRuntime.builder("configfile").build(). And... I used the Modeler to regenerate all classes, which changed to "Property.create("...
I downgraded to M4, reverted all the changes and everything worked fine.
Is this a bug in M5 release? Or how do I workaround this? Thanks!
A short answer - please remove cayenne-jcache-4.0.M5.jar
from your app dependencies if you are not planning to use JCache.
Longer answer - Cayenne 4.0.M5 features module auto-loading. So whenever you are putting any cayenne-*.jar
on classpath, it will try to install its extensions in ServerRuntime. Specifically cayenne-jcache-4.0.M5.jar
tried to install JCache-based QueryCache, and since JCache library was not available, the exception was thrown.
For more details and other M5 changes see the M5 UPGRADE.txt.