DefaultTimeZoneRegistryFactory Error

  • Anonymous - 2012-07-27


    I'm trying to parse a downloaded ical file in an android project with ical4j.

    I have added the following files to my libs directory and added them into the build path using the android plugin.

    backport-util-concurrent-3.1.jar, commons-codec-1.5.jar, commons-lang-2.6.jar, commons-logging-1.1.1.jar, ical4j-1.0.3.jar

    I am getting an error when I call

    CalendarBuilder builder = new CalendarBuilder();

    The error is

    07-28 00:46:08.362: I/Configurator(19472): not found.
    07-28 00:46:08.392: W/dalvikvm(19472): Exception Ljava/lang/NullPointerException; thrown while initializing Lnet/fortuna/ical4j/model/TimeZoneRegistryImpl;
    07-28 00:46:08.392: I/SyncAdapter(19472): Closing network connection and releasing provider.
    07-28 00:46:08.412: W/dalvikvm(19472): threadid=11: thread exiting with uncaught exception (group=0x40a3c1f8)
    07-28 00:46:08.412: E/AndroidRuntime(19472): FATAL EXCEPTION: SyncAdapterThread-1
    07-28 00:46:08.412: E/AndroidRuntime(19472): java.lang.ExceptionInInitializerError
    07-28 00:46:08.412: E/AndroidRuntime(19472):    at net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory.createRegistry(
    07-28 00:46:08.412: E/AndroidRuntime(19472):    at<init>(
    07-28 00:46:08.412: E/AndroidRuntime(19472):    at ie.clashoftheash.timetabler.syncadapter.SyncAdapter.onPerformSync(
    07-28 00:46:08.412: E/AndroidRuntime(19472):    at android.content.AbstractThreadedSyncAdapter$
    07-28 00:46:08.412: E/AndroidRuntime(19472): Caused by: java.lang.NullPointerException
    07-28 00:46:08.412: E/AndroidRuntime(19472):    at net.fortuna.ical4j.util.ResourceLoader.getResourceAsStream(
    07-28 00:46:08.412: E/AndroidRuntime(19472):    at net.fortuna.ical4j.model.TimeZoneRegistryImpl.<clinit>(
    07-28 00:46:08.412: E/AndroidRuntime(19472):    ... 4 more

    I'm stumped as to what is wrong or what I can do to fix the problem, I've tried google and this forum but have not found anything to help me. Is there anything I can do to fix this issue?

    I have also added an file to the root of my src directory but I get a message saying that it cant find it (which can also be seen above). I'd also be delighted if you could help me fix this too.


    Is mise le meas,

  • Ben Fortuna

    Ben Fortuna - 2012-07-31

    Hi Ian,

    I suspect both of these issues are related, as it seems resources are not being loaded correctly from the classpath. Here is the static code in TimeZoneRegistryImpl that is most likely the cause of the ExceptionInInitializerError:

    static {
              try {
              catch (IOException ioe) {
                          "Error loading timezone aliases: " + ioe.getMessage());

    I am not sure if anything changed recently on Android, but I have run some simple tests with 2.1 and it worked ok. Make sure you are including resources in the final APK being generated, otherwise I will try to test it when I get some time.


  • Anonymous - 2012-08-14

    I have the same problem in Android.

    The call works fine if I do it from an Activity, but when I run it from a Service this happens.

  • Anonymous - 2012-08-14

    Oh and I also get this error right before it crashes:

    I/Configurator(19472): not found.

    I think it may be the cause.

    Where am I supposed to put this file? I've tried almost every folder there is, but it still won't see it.

  • Anonymous - 2012-08-14

    Okay, problem solved. It was indeed because it did not see the file, which should be located in the base of your src/ folder. Additionally you have to restart Eclipse before it will register the file.

  • Anonymous - 2012-08-14

    Nevermind. That wasn't it. It sort of worked for a while (not sure what happened, maybe the program just didn't launch properly), but now it's back again.

  • Anonymous - 2012-08-14

    The problem is that CalendarBuilder is not thread-safe. That is why it's not going to work in a Service. Is there already a bug report on this?

  • pengin

    pengin - 2013-04-23

    Did anyone find a solution or workaround for this?

  • pengin

    pengin - 2013-04-23

    Did anyone find a solution or workaround for this?

    Also note I have verified the "tz.alias" file exists in the ical4j jar that fortuna mentions.

  • Ben Fortuna

    Ben Fortuna - 2013-04-23

    I haven't had much time to investigate this, however if you want to look at an example of using ical4j in Android there is this:

    I haven't tried this project recently, but it was parsing and loading calendar files last time I checked. Note that this doesn't use Android services tho, so the initial issue here may be related to something I am not aware of.


  • nis

    nis - 2013-04-29

    I have the same problem when using a service.
    I tested the following log statements from ical4j-android-test:

    Log.i("Class.getResource", String.valueOf(getClass().getResource("net/fortuna/ical4j/model/tz.alias")));
    Log.i("Class.getResource", String.valueOf(getClass().getResource("/net/fortuna/ical4j/model/tz.alias")));
    Log.i("ClassLoader.getResource", String.valueOf(getClass().getClassLoader().getResource("net/fortuna/ical4j/model/tz.alias")));
    Log.i("ClassLoader.getResource", String.valueOf(getClass().getClassLoader().getResource("/net/fortuna/ical4j/model/tz.alias")));

    The statements without a leading slash give a null result, but the ones WITH a leading slash give the correct jar path. So it seems that the leading slash is necessary, but the static block in TimeZoneRegistryImpl doesn't use it.

    Hope that helps.

  • nis

    nis - 2013-04-29

    Hi guys. I found fix! The problem seems to be the class ResourceLoader. The following statement failes with a NPE.

    stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);

    This is because


    returns null.

    So I tried to set the context class loader as follows


    an it works!

  • Parag

    Parag - 2015-09-23

    I am trying to use the jar, but I am missing tz.alias along with all the ics files in my apk (verified using baksmali)? I added the ical4j as a static lib in my, but I am missing something which would tell the apk to keep the non-java files that are not specified as resources and/or assets. Or should I define them as assets? Any help would be appreciated.


    Last edit: Parag 2015-09-24

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks