We use Magento in conjunction with EE for our site. In one of my templates, I have this code to load the Magento object model to be used in the template:
include_once($_SERVER['DOCUMENT_ROOT'] . '/store/app/Mage.php');
Mage::app();
The template loads fine and the code works.
But if I include the exact same code in another template, I get this:
Fatal error: Uncaught exception 'Exception' with message 'Warning: include(Query.php):
failed to open stream:
No such file or directory in /srv/www/htdocs/store/lib/Varien/Autoload.php on line 93' in /srv/www/htdocs/store/app/code/core/Mage/Core/functions.php:245
Stack trace:
#0 /srv/www/htdocs/store/lib/Varien/Autoload.php(93): mageCoreErrorHandler(2, 'include(Query.p...', '/srv/www/htdocs...', 93, Array)
#1 /srv/www/htdocs/store/lib/Varien/Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload('query')
#3 [internal function]: spl_autoload_call('query')
#4 /srv/www/htdocs/na_cms/expressionengine/libraries/Template.php(1089): class_exists('query')
#5 /srv/www/htdocs/na_cms/expressionengine/libraries/Template.php(968): EE_Template->process_tags()
#6 /srv/www/htdocs/na_cms/expressionengine/libraries/Template.php(497): EE_Template->tags()
#7 /srv/www/htdocs/na_cms/expressionengine/libraries/Template.php(248): EE_Template->parse('??
These templates are NOT nested.
Any ideas why this is happening and how to fix it?
At some point in your code, or the EE code, you're trying to use a class named "Query". This class is undefined, so PHP attempts to use its autoloader mechanism to load the class Query.
The code above indicates Magento's autoload tries to load the class Query. This fails (as the class isn't a Magento class). Also, it appears you're in Magento's developer mode, where all Notices and warnings are turned into Exceptions. Since the autoload fails with a warning, a fatal exception is thrown.
So, the problem could be two things. The first is someone's trying to instantiate a non-existant Query class. If this is the case, stop doing it.
The second is that the Query class exists, but EE's autoloader never has a chance to load it because Magento's autoload tries first. If this is the case you'll need to insert some code somewhere that jiggers the autoloaders to change their order. You could also try manually including the Query class to fix this specific instance.
Related
I need help regarding this below issue:
Fatal error: Uncaught Exception: Error: Could not load template /www/hosting/part2print.cz/eshop/catalog/view/theme/default/template/checkout/payment_manager/confirm.tpl! in /www/hosting/part2print.cz/eshop/system/storage/modification/system/library/template/template.php:23 Stack trace: #0 /www/hosting/part2print.cz/eshop/system/storage/modification/system/library/template.php(57): Template\Template->render() #1 /www/hosting/part2print.cz/eshop/system/storage/modification/system/engine/loader.php(128): Template->render() #2 /www/hosting/part2print.cz/eshop/system/ocmodify/classes/engine/override.php(8): Loader->view() #3 /www/hosting/part2print.cz/eshop/system/ocmodify/classes/override/loader.php(55): OCMOverride->__call() #4 /www/hosting/part2print.cz/eshop/system/ocmodify/classes/engine/bridge.php(47): OCMLoader->view() #5 /www/hosting/part2print.cz/eshop/system/ocmodify/classes/library/load.php(82): OCMBridge->__call() #6 /www/hosting/part2print.cz/eshop/system/ocmodify/classes/engine/controller.php(121): OCMLoad->view in /www/hosting/part2print.cz/eshop/system/storage/modification/system/library/template/template.php on line 23
As I am using Opencart Version 3.0.3.1, when I go through checkout and reach to the 2nd last step "Payment Method" and select a method and click Continue, it gives me this above error (this error comes for some of method, like cash on delivery but not for all - This page (..catalog/view/theme/default/template/checkout/payment_manager/confirm.tpl!) is not even available, but Yes checkout/payment_manager folder is available).
One thing I want to clear, that I didn't changed the Payment Method controller file code and neither of confirm.twig file code, its a default opencart code. But this behaving strange.
Anybody of you can help please!!
As already said, OpenCart from version 3.x on use .twig only and not .tpl as template file extension.
And your message says it already all: you are using an additional extension which tries to load the template payment_manager/confirm.tpl
So, either you are using beside this extension also another one which allows .tpl files (not recommended!), or your extension is not for OC 3.x
btw: the path template/checkout/payment_manager shows me, that that extension does not follow the standard.
And, why are you using OC 3.0.3.1 and not 3.0.3.2 (which is better because of several bugfixes)?
How to replace just one exception template for own exception inside a plugin, which is extended built-in exception? :)
Exception located is in /vendor/author/pluginName/src/Exception/TestException.php
But i try replace template by create file /src/Template/PluginName/Error/test.ctp but doesn't work.
Of course, if I create file inside /src/Template/Error/test.ctp works fine.
I have many plugins and each can has own TestException class.
So, How I can use /PluginName direcotry?
Cake 3.6
The correct template path for overriding a plugin template on app level starts with Template/Plugin/, followed by the plugin name and the expected local template path, ie for a plugin named Foobar, the path for overriding its test error template would be:
src/Template/Plugin/Foobar/Error/test.ctp
Also it's important to keep in mind that error templates will by default only be looked up in plugins, if the exception is being triggered in a plugin controller request, to be specific, when the current global request object (Router::getRequest(true)) has a plugin parameter set ($request->getParam('plugin'))!
It should also be noted that individual templates that map to exception/method names, will only be used for non-HTTP exceptions (\Cake\Http\Exception\HttpException), and only when debug mode is enabled, if it's a HTTP-Exception or debug mode is disabled, then only the error400 or error500 template will be used!
See also
Cookbook > Plugins > Plugin Views > Overriding Plugin Templates from Inside Your Application
I have a component named MyComponent with the following folder structure in RTC:
/MyProject
/MyProject/TestFile.txt
/MyProject/Folder1
/MyProject/Folder1/loadrules.txt
/MyProject/Folder1/TestFile2.txt
And this is what I have in my loadrules.txt file::
versionableName=/MyProject/TestFile.txt
I've specified the loadrules.txt file in my build definition for this component as the component load rule, but when the build runs, I'm getting the following exception when it tries to fetch the files:
com.ibm.team.repository.common.TeamRepositoryException: Unexpected line "versionableName=/MyProject/TestFile.txt" encountered in build load rules for component "MyComponent"
at com.ibm.team.filesystem.client.internal.load.LoadRule.getRules(LoadRule.java:176)
at com.ibm.team.filesystem.client.internal.load.LoadRule.addLoadRules(LoadRule.java:101)
at com.ibm.team.build.internal.scm.ComponentLoadRules.getLoadRules(ComponentLoadRules.java:134)
at com.ibm.team.build.internal.engine.JazzScmPreBuildParticipant.preBuild(JazzScmPreBuildParticipant.java:235)
at com.ibm.team.build.internal.engine.BuildLoop.invokePreBuildParticipants(BuildLoop.java:844)
at com.ibm.team.build.internal.engine.BuildLoop$2.run(BuildLoop.java:650)
at java.lang.Thread.run(Thread.java:662)
Any idea what I'm doing wrong? I've tried following the example here but I can't figure why it's not working for me. Regardless of what I put in the loadrules.txt file (nothing/empty string, random garbage text, etc.), I still get this exception for the first line of the file.
This is in RTC 3.0
This kind of error is likely to be an encoding issue.
One way to test that is to create the loadrules.txt through the scm command-line interface, as detailed in "Reference > Source control command line reference > scm > create"
scm create loadrules [options]
The OP holic87 confirms:
I just used Notepad++ to recreate the text file and it's working as expected now.
I have been researching this, and cannot seem to find anything about it.
We work on CF8. When my coworker tried installing my latest code updates, he started seeing errors that the argument supplied to a function was not of the specified interface type. Worked fine for me. Same set up. Sometimes it works for him. Also have the problem on our dev server.
I have since been able to isolate and reproduce the problem locally.
Here is the set up.
I have 2 mappings on the server:
"webapp/" goes to c:\webroot\
"packages/" goes to c:\webroot\[domain]
Then I created an interface, call it ISubject and a component that implements it, called Person, and saved both under packages. Here is the declaration for Person:
cfcomponent implements="packages.ISubject"
Finally, there is a component, called SubjectMediator with a function, called setSubject, that wants an object of the ISubject interface type. Here is the argument declaration for setSubject:
cfargument name="subject_object" type="packages.ISubject"
To implement:
variables.person = createObject("component", "packages.Person").Init();
variables.subjectMediator = createObject("component", "packages.SubjectMediator ").Init();
variables.subjectMediator.setSubject(variables.person);
That last line throws the error that Person is not of type ISubject. If I do isInstanceOf() on Person against ISubject it validates fine.
So the reason this is happening? Dumping getMetaData(variables.person) shows me that the interface path is webapp.[domain].ISubject. And indeed, if I change the type attribute of the argument to use this path instead of packages.ISubject, all is fine again.
Coldfusion seems to be arbitrarily choosing which mapping to resolve the interface to, and then simply doing a string comparison for check the type argument?
Anyone had to contend with this? I need the webapp mapping, and I cannot change all references to "packages" to "webapp.[domain]." I also am not able in this instance to use an application-specific mapping for webapp. While any of these 3 options would circumvent the issue, I'm hoping someone has some insight...
The best I've got is to set argument type to "any" and then check isInstanceOf() inside the function... Seems like poor form.
Thanks,
Jen
Can you move the contents of the packages mapping to outside the webroot? This seems like the easiest way to fix it.
I have added one condition on my HTML page that is
#{if userObject == null}
Text
#{/if}
The code is working fine on the dev mode and getting this error in PROD mode.
SEVERE: Cannot start in PROD mode with errors
java.lang.ClassFormatError: Invalid method Code length 65561 in class file Template_M1175588447$_run_closure1_closure2
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at play.templates.GroovyTemplate$TClassLoader.defineTemplate(GroovyTemplate.java:77)
at play.templates.GroovyTemplate.compile(GroovyTemplate.java:133)
at play.templates.TemplateLoader.scan(TemplateLoader.java:184)
at play.templates.TemplateLoader.scan(TemplateLoader.java:194)
at play.templates.TemplateLoader.scan(TemplateLoader.java:194)
at play.templates.TemplateLoader.getAllTemplate(TemplateLoader.java:164)
at play.Play.preCompile(Play.java:501)
at play.Play.init(Play.java:273)
at play.server.Server.main(Server.java:131)
Is there any way out on this
I believe your issue is not related to the code you added, but to having a template "too big" that goes over the allowed lines size (in Java) for a method.
Probably you are xtending big templates or your page is really long.
As said on the official Java documentation, that means the jvm tries to read a class file that is malformed. Thus, try to delete all class files, tmp folder and recompile.