Magento – Warning: include(): failed to open stream: No such file or directory

adminhtmlerrorlayoutmagento-1.7module

In app/code/local/AB/CarLocator/controllers/Adminhtml/CarlocatorController.php code I have:

class AB_CarLocator_Adminhtml_CarlocatorController extends Mage_Adminhtml_Controller_Action
{
    public function editAction ()
    {   
         $this->_setTitle();
         $model = Mage::getModel('carlocator/car');
         if ($id = $this->getRequest()->getParam('id')) {
              $model->load($id);
         }
         Mage::register('_current_car', $model);
         $this->loadLayout(); //THIS IS WHERE THE CODE CRUSHES AND I GET THE ERROR IN system.xml
         $this->_setActiveMenu('carlocator');
    }
}

which generated the following error in var/log/system.log:

Warning: include(Mage/Ab/Carlocator/Helper/Data.php): failed to openstream:
No such file or directory 
in /var/www/vhosts/abcars.com/httpdocs/staging/lib/Varien/Autoload.php on line 93
Warning: include(): Failed opening 'Mage/Ab/Carlocator/Helper/Data.php' for inclusion
(include_path='/var/www/vhosts/abcars.com/httpdocs/staging/app/code/local
:/var/www/vhosts/abcars.com/httpdocs/staging/app/code/community
:/var/www/vhosts/abcars.com/httpdocs/staging/app/code/core
:/var/www/vhosts/abcars.com/httpdocs/staging/lib:.:')
in /var/www/vhosts/abcars.com/httpdocs/staging/lib/Varien/Autoload.php on line 93

It looks quite similar to the problem here and here so I tried the solutions suggested there and verified my config.xml file over and over and it still gives me this error.

maybe the problem derives from the fact that Magento is looking for the file under Mage/Ab/Carlocator/Helper/Data.php while it exists in code/local/AB/CarLocator/Helper/Data.php

Any help would be truly appreciated!

EDIT

app/code/local/AB/CarLocator/etc/config.xml:

<?xml version="1.0"?>
<config>
<modules>
    <AB_CarLocator>
        <version>0.1.0</version>
    </AB_CarLocator>
</modules>
<global>
    <blocks>
        <carlocator>
            <class>AB_CarLocator_Block</class>
            <rewrite>
                <carlocator>AB_CarLocator_Block_CarLocator</carlocator>
            </rewrite>
        </carlocator>
    </blocks>
    <helpers>
        <carlocator>
            <class>AB_CarLocator_Helper</class>
        </carlocator>
    </helpers>
    <request>
        <direct_front_name>
            <carlocator />
        </direct_front_name>
    </request>
    <models>
        <carlocator>
            <class>AB_CarLocator_Model</class>
            <resourceModel>carlocator_resource</resourceModel>
        </carlocator>
        <carlocator_resource>
            <class>AB_CarLocator_Model_Resource</class>
            <entities>
                <car>
                    <table>cars</table>
                </car>
            </entities>
        </carlocator_resource>
    </models>
    <resources>
        <carlocator_setup>
            <setup>
                <module>AB_CarLocator</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </carlocator_setup>
    </resources>
</global>
<frontend>
    <routers>
        <carlocator>
            <use>standard</use>
            <args>
                <module>AB_CarLocator</module>
                <frontName>carlocator</frontName>
            </args>
        </carlocator>
    </routers>
    <layout>
       <updates>
            <carlocator>
                <file>carlocator.xml</file>
            </carlocator>
       </updates>
    </layout>
    <translate>
        <modules>
            <carlocator>
                <files>
                    <default>CarLocator.csv</default>
                </files>
          </carlocator>
        </modules>
    </translate>
</frontend>
<adminhtml>
    <layout>
        <updates>
            <carlocator>
                <file>carlocator.xml</file>
            </carlocator>
        </updates>
    </layout>
</adminhtml>
<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <carlocator before="Mage_Adminhtml">AB_CarLocator_Adminhtml</carlocator>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
<default>
    <catalog>
        <carlocator>
            <google_api_key>1</google_api_key>
        </carlocator>
    </catalog>
</default>
</config>

app/code/local/AB/CarLocator/Helper/Data.php:

<?php

class AB_CarLocator_Helper_Data extends Mage_Core_Helper_Abstract
{

}

Best Answer

  1. check your modules registration file it should be at app/etc/modules/ Naming should be like YourNamespace_YourModulesName.xml

it should looks like :

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <YourNamespace_ModulesName>
            <active>true</active>
            <codePool>local</codePool>
        </YourNamespace_ModulesName>
    </modules>
</config>

Now check in your Adminpanel at System -> Configuration -> ADVANCED -> Advances weather your module is listed here. If its not you should propably have an error in your registration file.

2.1 If registration file is ok check your modules configuration file it should be at app/code/local/YourNamespace/YourModulesName/etc/config.xml. To find the problem here it would be great if you could post your modules configuratino file. But also you can check in the source code of Magento how the config.xml is setup up in the right way.

Hope my answers helped you.