Previously I have been able to run this script that read events from a url.ics
import net.fortuna.ical4j.util.Calendars
import net.fortuna.ical4j.model.component.VEvent
@Grapes(
@Grab(group='org.mnode.ical4j', module='ical4j', version='2.2.0')
)
def url = 'https://calendar.google.com/calendar/ical/xxxx/basic.ics'.toURL()
def cal = Calendars.load(url)
However, now I am getting this exception java.lang.NoClassDefFoundError: javax/cache/configuration/Configuration
.
I assume there is some sort of dependency change that has occurred. I have noted this
javax.cache.cache-api [optional*] - Supports caching timzeone definitions. * NOTE: when not included you must set a value for the net.fortuna.ical4j.timezone.cache.impl configuration
however, now I am getting this java.lang.NoClassDefFoundError: Could not initialize class net.fortuna.ical4j.validate.AbstractCalendarValidatorFactory
any help appreciated.
ical4j looks for a properties file called ical4j.properties
and loads configuration from it. Create this file in the same folder and add
net.fortuna.ical4j.timezone.cache.impl=net.fortuna.ical4j.util.MapTimeZoneCache
to specify in-memory cache provider that uses ConcurrentHashMap
. When property net.fortuna.ical4j.timezone.cache.impl
is not specified, ical4j falls back to JCacheTimeZoneCache
which uses cache manager and requires valid caching library to be present in the classpath.
The alternative to using ical4j.properties
file is to set this property programatically, e.g.
System.setProperty("net.fortuna.ical4j.timezone.cache.impl", "net.fortuna.ical4j.util.MapTimeZoneCache")
Just remember to set it before calling Calendars.load(url)
and it should work.