Could Not Create Java Implementation Loader

The "Could Not Create Java Implementation Loader" error message appears for some people when installing a Java-based LibreOffice/OpenOffice extension. It is difficult to reproduce and sometimes disappears by just disabling/enabling Java. Some people manage to fix the issue by re-installing LibreOffice/OpenOffice. In some cases, the problem can be solved by setting a different version of Java and then selecting it in the settings of LibreOffice/OpenOffice.

Some links:

Affected extensions

LanguageTool, Oracle report Builder, ODFToEPub, Zotero, Anaphraseus - basically any Java-based extension

Analysis in source code (low level)

This is what Stephan Bergmann explained to me:

What typically fails is

err= pCreateJavaVM(&pJavaVM, ppEnv, &vm_args);

in ./libo/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx. This returns an error code that doesn't help (-1). Debugging might be possible using system-dependent tools like depends.exe under Windows, strace or LD_DEBUG under Linux.

How to continue now

  • Find someone who can reproduce the problem and ask them to reproduce with "soffice.exe 2> log.txt" under Cygwin. Maybe the log file contains useful information. (Source)
  • Find if there are debug builds available - point people to them if they cannot solve the problem otherwise - it's still unclear if the debug information would help

Analysis in source code (high level)

(This is what I found out, it might be useful for someone, but the "Analysis in source code (low level)" is probably more useful)

I'm not a LibreOffice/OpenOffice nor a C++ developer, but I tried to find the location of the code that causes the problem anyway. The message is displayed in ./core/stoc/source/javaloader/javaloader.cxx when getJavaLoader() returns null. The relevant location might around line 180:

    OSL_ENSURE(sizeof (sal_Int64)
                >= sizeof (jvmaccess::UnoVirtualMachine *),
                "Pointer cannot be represented as sal_Int64");
    sal_Int64 nPointer = reinterpret_cast< sal_Int64 >(
        static_cast< jvmaccess::UnoVirtualMachine * >(0));
    javaVM_xJavaVM->getJavaVM(processID) >>= nPointer;
    rtl::Reference< jvmaccess::UnoVirtualMachine > xVirtualMachine(
        reinterpret_cast< jvmaccess::UnoVirtualMachine * >(nPointer));
    if (!
        //throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
        //   "javaloader error - JavaVirtualMachine service could not provide a VM")),
        //   css::uno::Reference<XInterface>());
        // We must not throw a RuntimeException, because this might end the applications.
        // It is ok if java components
        // are not working because the office can be installed without Java support.
        return m_javaLoader; // null-ref

This looks relevant:

javaVM_xJavaVM->getJavaVM(processID) >>= nPointer;

It's defined in ./core/stoc/source/javavm/javavm.cxx. This returns a null (or rather css::uno::Any()) without showing a warning in the following cases:

line ~729:

    if (aId != aProcessId)
        return css::uno::Any();

line ~738:

    if (m_bDontCreateJvm)
        //throw css::uno::RuntimeException();
        return css::uno::Any();
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License