Receiving the following error when trying to browse for a link in Message templates:

Failed to start application

  at /var/www/joomla/libraries/src/Factory.php:158
  at Joomla\CMS\Factory::getApplication()
  at authenticate_joomla()
  at checkAuthentication()
  at require('/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/integration/civicrm.php')
  at require('/var/www/joomla/administrator/components/com_civicrm/civicrm/packages/kcfinder/core/bootstrap.php')

How can i resolve?

enter image description here enter image description here enter image description here

  • I'd try to replace line 203 in ../civicrm.php as "JFactory::" is deprecated in Joomla 5 and must be replaced. I raised an issue 6 days ago. lab.civicrm.org/dev/joomla/-/issues/55
    – Guitarman
    Commented Apr 16 at 16:15
  • this is in joomla 4 Commented Apr 17 at 7:53
  • made changes per your proposed change, and Factory could no longer be found Commented Apr 17 at 8:00

2 Answers 2


Have you tried using CKeditor5 or summernote as a replacement got Kcfinder?

  • Ckeditor is fine, but you lose the ability to browse for links Commented Apr 24 at 11:25

Please change the file administrator/civicrm/packages/kcfinder/integration/civicrm.php and use the following code for the function authenticate_joomla near the end of the file (line 193 f.) to the following:

function authenticate_joomla($config) {

  $joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));

  define( '_JEXEC', 1 );
  define('JPATH_BASE', $joomlaBase);
  require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
  require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

if (version_compare(JVERSION, '4.0.0', 'lt')) {
    $mainframe = JFactory::getApplication('administrator');
    $user_id = JFactory::getUser()->id;
  else {
    $container = \Joomla\CMS\Factory::getContainer();

    $container->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');

    $app = $container->get(\Joomla\CMS\Application\AdministratorApplication::class);
    $user_id = Joomla\CMS\Factory::getUser()->id;

  if (JFactory::getUser()->id == 0) {
    return false;
  return true;

I tested this successfully.

  • 1
    We have to avoid using JFactory::getApplication('administrator') as since Joomla 4 'getApplication' no longer takes arguments. From the J4 potential backward compatibility page, docs.joomla.org/…
    – Guitarman
    Commented Apr 24 at 9:10
  • I will test this first chance I get Commented Apr 24 at 11:25
  • could you test this already?
    – Guitarman
    Commented Apr 29 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.