Magento: Helper Data not found error

I created a module, let’s say, ‘MyModule’. When I go to the Admin -> System -> Configuration section of this module, I get this weird error.

Fatal error: Class ‘Mage_MyModule_Helper_Data’ not found

– My Module is enabled.
– I have helper class in ‘Helper’ folder of my module.
– I have deleted/refreshed all cache and session.

According to my findings, the problem should be in XML file. Either the XML file inside app/etc/modules or the XML file inside MyNamespace/MyModule/etc.

1) XML is strictly case sensitive

I opened app/etc/modules/MyNamespace_MyModule.xml to check the case sensitive issue as the XML files are strictly case sensitive.

Everything was okay with it. Here is the code:-


<?xml version="1.0"?>
<config>
  <modules>
    <MyNamespace_MyModule>
      <codePool>local</codePool>
      <active>true</active>
    </MyNamespace_MyModule>
  </modules>
</config> 

I was checking the codePool node. You might get this error if you write codepool (all small letters) instead of codePool (P capital). However, in my case, it was okay.

2) XML doesn’t ignore whitespace (even if it is commented)

This was the main cause of the error in my case. You should not keep space in between XML content. I had kept space in MyNamespace/MyModule/etc/config.xml

The tricky part is that the space was inside commented XML code. Didn’t know that XML checks for whitespace inside commented code as well.

I have commented out some code in config.xml as below:-


<!-- <default>
		<catalog>
			<mymodule>
				<mymessage>Hello World!</mymessage>
			</mymodule>
	</default> -->

The space just after the comment start (before default node) and the space just before the comment end (after closing default node) was causing the error. I deleted the whole commented code and my problem was solved. :)

Hope this helps. Thanks.