Closed kandrejevs closed 6 years ago
Let me know if you need any additional info
I suspect this is b/c of incomplete initialization of the entry-point (here for cron).
Can you share the exact version of Magento you're using?
enterprise edition 2.1.2
@kandrejevs Is this a standard cron job? If yes, can you provide me the name of the cronjob?
it is custom job
<job name="oe_export_invoices" instance="Test\OrderExport\Model\ICMExport" method="exportICM">
<schedule>0 3 1 * *</schedule>
</job>
If you still can easily provoke the error, can you please provide the command (and all output) executed with -vvv
switch which should give a backtrace (hopefull). Please mask (or cut away) any personal data in the output if applicable.
Load dist config
Search for Magento in folder pub
Search for Magento in folder /private/var/www/jlr3
Found Magento v2 in folder /private/var/www/jlr3
Load dist config
Add core command help -> Symfony\Component\Console\Command\HelpCommand
Add core command list -> Symfony\Component\Console\Command\ListCommand
Add core command admin:user:create -> Magento\Setup\Console\Command\AdminUserCreateCommand
Add core command setup:backup -> Magento\Setup\Console\Command\BackupCommand
Add core command setup:config:set -> Magento\Setup\Console\Command\ConfigSetCommand
Add core command setup:cron:run -> Magento\Setup\Console\Command\CronRunCommand
Add core command setup:db-data:upgrade -> Magento\Setup\Console\Command\DbDataUpgradeCommand
Add core command setup:db-schema:upgrade -> Magento\Setup\Console\Command\DbSchemaUpgradeCommand
Add core command setup:db:status -> Magento\Setup\Console\Command\DbStatusCommand
Add core command info:dependencies:show-framework -> Magento\Setup\Console\Command\DependenciesShowFrameworkCommand
Add core command info:dependencies:show-modules-circular -> Magento\Setup\Console\Command\DependenciesShowModulesCircularCommand
Add core command info:dependencies:show-modules -> Magento\Setup\Console\Command\DependenciesShowModulesCommand
Add core command setup:di:compile -> Magento\Setup\Console\Command\DiCompileCommand
Add core command setup:performance:generate-fixtures -> Magento\Setup\Console\Command\GenerateFixturesCommand
Add core command i18n:collect-phrases -> Magento\Setup\Console\Command\I18nCollectPhrasesCommand
Add core command i18n:pack -> Magento\Setup\Console\Command\I18nPackCommand
Add core command info:adminuri -> Magento\Setup\Console\Command\InfoAdminUriCommand
Add core command info:backups:list -> Magento\Setup\Console\Command\InfoBackupsListCommand
Add core command info:currency:list -> Magento\Setup\Console\Command\InfoCurrencyListCommand
Add core command info:language:list -> Magento\Setup\Console\Command\InfoLanguageListCommand
Add core command info:timezone:list -> Magento\Setup\Console\Command\InfoTimezoneListCommand
Add core command setup:install -> Magento\Setup\Console\Command\InstallCommand
Add core command setup:store-config:set -> Magento\Setup\Console\Command\InstallStoreConfigurationCommand
Add core command module:enable -> Magento\Setup\Console\Command\ModuleEnableCommand
Add core command module:disable -> Magento\Setup\Console\Command\ModuleDisableCommand
Add core command module:status -> Magento\Setup\Console\Command\ModuleStatusCommand
Add core command module:uninstall -> Magento\Setup\Console\Command\ModuleUninstallCommand
Add core command maintenance:allow-ips -> Magento\Setup\Console\Command\MaintenanceAllowIpsCommand
Add core command maintenance:disable -> Magento\Setup\Console\Command\MaintenanceDisableCommand
Add core command maintenance:enable -> Magento\Setup\Console\Command\MaintenanceEnableCommand
Add core command maintenance:status -> Magento\Setup\Console\Command\MaintenanceStatusCommand
Add core command setup:rollback -> Magento\Setup\Console\Command\RollbackCommand
Add core command setup:upgrade -> Magento\Setup\Console\Command\UpgradeCommand
Add core command setup:uninstall -> Magento\Setup\Console\Command\UninstallCommand
Add core command theme:uninstall -> Magento\Theme\Console\Command\ThemeUninstallCommand
Add core command customer:hash:upgrade -> Magento\Customer\Console\Command\UpgradeHashAlgorithmCommand
Add core command indexer:info -> Magento\Indexer\Console\Command\IndexerInfoCommand
Add core command indexer:reindex -> Magento\Indexer\Console\Command\IndexerReindexCommand
Add core command indexer:set-mode -> Magento\Indexer\Console\Command\IndexerSetModeCommand
Add core command indexer:show-mode -> Magento\Indexer\Console\Command\IndexerShowModeCommand
Add core command indexer:status -> Magento\Indexer\Console\Command\IndexerStatusCommand
Add core command indexer:reset -> Magento\Indexer\Console\Command\IndexerResetStateCommand
Add core command cache:enable -> Magento\Backend\Console\Command\CacheEnableCommand
Add core command cache:disable -> Magento\Backend\Console\Command\CacheDisableCommand
Add core command cache:flush -> Magento\Backend\Console\Command\CacheFlushCommand
Add core command cache:clean -> Magento\Backend\Console\Command\CacheCleanCommand
Add core command cache:status -> Magento\Backend\Console\Command\CacheStatusCommand
Add core command catalog:images:resize -> Magento\Catalog\Console\Command\ImagesResizeCommand
Add core command catalog:product:attributes:cleanup -> Magento\Catalog\Console\Command\ProductAttributesCleanUp
Add core command admin:user:unlock -> Magento\User\Console\UnlockAdminAccountCommand
Add core command cron:run -> Magento\Cron\Console\Command\CronCommand
Add core command setup:static-content:deploy -> Magento\Deploy\Console\Command\DeployStaticContentCommand
Add core command deploy:mode:set -> Magento\Deploy\Console\Command\SetModeCommand
Add core command deploy:mode:show -> Magento\Deploy\Console\Command\ShowModeCommand
Add core command dev:tests:run -> Magento\Developer\Console\Command\DevTestsRunCommand
Add core command dev:source-theme:deploy -> Magento\Developer\Console\Command\SourceThemeDeployCommand
Add core command dev:xml:convert -> Magento\Developer\Console\Command\XmlConverterCommand
Add core command dev:urn-catalog:generate -> Magento\Developer\Console\Command\XmlCatalogGenerateCommand
Add core command queue:consumers:start -> Magento\MessageQueue\Console\StartConsumerCommand
Add core command queue:consumers:list -> Magento\MessageQueue\Console\ConsumerListCommand
Add core command setup:db-schema:add-slave -> Magento\ResourceConnections\Console\Command\AddSlave
Add core command sampledata:deploy -> Magento\SampleData\Console\Command\SampleDataDeployCommand
Add core command sampledata:reset -> Magento\SampleData\Console\Command\SampleDataResetCommand
Add core command sampledata:remove -> Magento\SampleData\Console\Command\SampleDataRemoveCommand
Add core command setup:db-schema:split-quote -> Magento\ScalableCheckout\Console\Command\SplitQuote
Add core command setup:db-schema:split-sales -> Magento\ScalableOms\Console\Command\SplitSales
Add core command support:utility:check -> Magento\Support\Console\Command\UtilityCheckCommand
Add core command support:utility:paths -> Magento\Support\Console\Command\UtilityPathsCommand
Add core command support:backup:db -> Magento\Support\Console\Command\BackupDbCommand
Add core command support:backup:code -> Magento\Support\Console\Command\BackupCodeCommand
Add core command i18n:uninstall -> Magento\Translation\Console\Command\UninstallLanguageCommand
Add core command wyomind:dfm:generate -> Wyomind\DataFeedManager\Console\Command\Generate
Add core command wyomind:dfm:list -> Wyomind\DataFeedManager\Console\Command\Listing
Add command admin:user:list -> N98\Magento\Command\Admin\User\ListCommand
Add command admin:user:delete -> N98\Magento\Command\Admin\User\DeleteUserCommand
Add command admin:user:change-password -> N98\Magento\Command\Admin\User\ChangePasswordCommand
Add command cache:clean -> N98\Magento\Command\Cache\CleanCommand
Add command cache:disable -> N98\Magento\Command\Cache\DisableCommand
Add command cache:enable -> N98\Magento\Command\Cache\EnableCommand
Add command cache:flush -> N98\Magento\Command\Cache\FlushCommand
Add command cache:list -> N98\Magento\Command\Cache\ListCommand
Add command config:delete -> N98\Magento\Command\Config\DeleteCommand
Add command config:get -> N98\Magento\Command\Config\GetCommand
Add command config:set -> N98\Magento\Command\Config\SetCommand
Add command customer:create -> N98\Magento\Command\Customer\CreateCommand
Add command customer:info -> N98\Magento\Command\Customer\InfoCommand
Add command customer:list -> N98\Magento\Command\Customer\ListCommand
Add command db:console -> N98\Magento\Command\Database\ConsoleCommand
Add command db:create -> N98\Magento\Command\Database\CreateCommand
Add command db:drop -> N98\Magento\Command\Database\DropCommand
Add command db:dump -> N98\Magento\Command\Database\DumpCommand
Add command db:import -> N98\Magento\Command\Database\ImportCommand
Add command db:info -> N98\Magento\Command\Database\InfoCommand
Add command db:query -> N98\Magento\Command\Database\QueryCommand
Add command db:variables -> N98\Magento\Command\Database\VariablesCommand
Add command db:status -> N98\Magento\Command\Database\StatusCommand
Add command db:maintain:check-tables -> N98\Magento\Command\Database\Maintain\CheckTablesCommand
Add command db:info -> N98\Magento\Command\Database\InfoCommand
Add command dev:console -> N98\Magento\Command\Developer\ConsoleCommand
Add command dev:module:create -> N98\Magento\Command\Developer\Module\CreateCommand
Add command dev:report:count -> N98\Magento\Command\Developer\Report\CountCommand
Add command dev:symlinks -> N98\Magento\Command\Developer\SymlinksCommand
Add command dev:template-hints-blocks -> N98\Magento\Command\Developer\TemplateHintsBlocksCommand
Add command dev:template-hints -> N98\Magento\Command\Developer\TemplateHintsCommand
Add command dev:theme:list -> N98\Magento\Command\Developer\Theme\ListCommand
Add command eav:attribute:view -> N98\Magento\Command\Eav\Attribute\ViewCommand
Add command generation:flush -> N98\Magento\Command\Generation\FlushCommand
Add command giftcard:pool:generate -> N98\Magento\Command\GiftCard\Pool\GenerateCommand
Add command giftcard:create -> N98\Magento\Command\GiftCard\CreateCommand
Add command giftcard:info -> N98\Magento\Command\GiftCard\InfoCommand
Add command giftcard:remove -> N98\Magento\Command\GiftCard\RemoveCommand
Add command open-browser -> N98\Magento\Command\OpenBrowserCommand
Add command script:repo:list -> N98\Magento\Command\Script\Repository\ListCommand
Add command script:repo:run -> N98\Magento\Command\Script\Repository\RunCommand
Add command sys:check -> N98\Magento\Command\System\CheckCommand
Add command sys:cron:history -> N98\Magento\Command\System\Cron\HistoryCommand
Add command sys:cron:list -> N98\Magento\Command\System\Cron\ListCommand
Add command sys:cron:run -> N98\Magento\Command\System\Cron\RunCommand
Add command sys:info -> N98\Magento\Command\System\InfoCommand
Add command sys:maintenance -> N98\Magento\Command\System\MaintenanceCommand
Add command sys:setup:change-version -> N98\Magento\Command\System\Setup\ChangeVersionCommand
Add command sys:setup:compare-versions -> N98\Magento\Command\System\Setup\CompareVersionsCommand
Add command sys:setup:downgrade-versions -> N98\Magento\Command\System\Setup\DowngradeVersionsCommand
Add command sys:store:list -> N98\Magento\Command\System\Store\ListCommand
Add command sys:url:list -> N98\Magento\Command\System\Url\ListCommand
Add command sys:store:config:base-url:list -> N98\Magento\Command\System\Store\Config\BaseUrlListCommand
Add command sys:website:list -> N98\Magento\Command\System\Website\ListCommand
Add command index:list -> N98\Magento\Command\Indexer\ListCommand
Add command install -> N98\Magento\Command\Installer\InstallCommand
Add command dev:module:list -> N98\Magento\Command\Developer\Module\ListCommand
Add command dev:module:observer:list -> N98\Magento\Command\Developer\Module\Observer\ListCommand
Add command script -> N98\Magento\Command\ScriptCommand
Add command shell -> N98\Magento\Command\ShellCommand
Add command self-update -> N98\Magento\Command\SelfUpdateCommand
Run Summit\OrderExport\Model\OrderExportApi::exportOrders
[InvalidArgumentException]
Required parameter 'theme_dir' was not passed
Exception trace:
() at /private/var/www/jlr3/vendor/magento/framework/View/Design/Fallback/Rule/Simple.php:61
Magento\Framework\View\Design\Fallback\Rule\Simple->getPatternDirs() at /private/var/www/jlr3/vendor/magento/framework/View/Design/Fallback/Rule/Theme.php:69
Magento\Framework\View\Design\Fallback\Rule\Theme->getPatternDirs() at /private/var/www/jlr3/vendor/magento/framework/View/Design/FileResolution/Fallback/Resolver/Simple.php:123
Magento\Framework\View\Design\FileResolution\Fallback\Resolver\Simple->resolveFile() at /private/var/www/jlr3/vendor/magento/framework/View/Design/FileResolution/Fallback/Resolver/Simple.php:66
Magento\Framework\View\Design\FileResolution\Fallback\Resolver\Simple->resolve() at /private/var/www/jlr3/vendor/magento/framework/View/Design/FileResolution/Fallback/LocaleFile.php:42
Magento\Framework\View\Design\FileResolution\Fallback\LocaleFile->getFile() at /private/var/www/jlr3/vendor/magento/framework/View/FileSystem.php:105
Magento\Framework\View\FileSystem->getLocaleFileName() at /private/var/www/jlr3/vendor/magento/framework/Translate.php:366
Magento\Framework\Translate->_getThemeTranslationFile() at /private/var/www/jlr3/vendor/magento/framework/Translate.php:311
Magento\Framework\Translate->_loadThemeTranslation() at /private/var/www/jlr3/vendor/magento/framework/Translate.php:180
Magento\Framework\Translate->loadData() at /private/var/www/jlr3/vendor/magento/module-store/Model/App/Emulation.php:155
Magento\Store\Model\App\Emulation->startEnvironmentEmulation() at /private/var/www/jlr3/vendor/magento/module-email/Model/AbstractTemplate.php:509
Magento\Email\Model\AbstractTemplate->applyDesignConfig() at /private/var/www/jlr3/vendor/magento/module-email/Model/Template.php:359
Magento\Email\Model\Template->processTemplate() at /private/var/www/jlr3/vendor/magento/framework/Mail/Template/TransportBuilder.php:273
Magento\Framework\Mail\Template\TransportBuilder->prepareMessage() at /private/var/www/jlr3/vendor/magento/framework/Mail/Template/TransportBuilder.php:227
Magento\Framework\Mail\Template\TransportBuilder->getTransport() at /private/var/www/jlr3/app/code/Summit/OrderExport/Helper/Email.php:145
Summit\OrderExport\Helper\Email->sendMail() at /private/var/www/jlr3/app/code/Summit/OrderExport/Helper/Email.php:83
Summit\OrderExport\Helper\Email->sendOrderExportError() at /private/var/www/jlr3/app/code/Summit/OrderExport/Model/OrderExportApi.php:149
Summit\OrderExport\Model\OrderExportApi->login() at /private/var/www/jlr3/app/code/Summit/OrderExport/Model/OrderExportApi.php:506
Summit\OrderExport\Model\OrderExportApi->getUserCookie() at /private/var/www/jlr3/app/code/Summit/OrderExport/Model/OrderExportApi.php:244
Summit\OrderExport\Model\OrderExportApi->validateOrder() at /private/var/www/jlr3/app/code/Summit/OrderExport/Model/OrderExportApi.php:188
Summit\OrderExport\Model\OrderExportApi->exportOrders() at n/a:n/a
call_user_func_array() at /private/var/www/jlr3/vendor/magento/framework/App/State.php:171
Magento\Framework\App\State->emulateAreaCode() at phar:///private/var/www/jlr3/n98-magerun2.phar/src/N98/Magento/Command/System/Cron/RunCommand.php:80
N98\Magento\Command\System\Cron\RunCommand->execute() at phar:///private/var/www/jlr3/n98-magerun2.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
Symfony\Component\Console\Command\Command->run() at phar:///private/var/www/jlr3/n98-magerun2.phar/src/N98/Magento/Command/AbstractMagentoCommand.php:437
N98\Magento\Command\AbstractMagentoCommand->run() at phar:///private/var/www/jlr3/n98-magerun2.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:882
Symfony\Component\Console\Application->doRunCommand() at phar:///private/var/www/jlr3/n98-magerun2.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at phar:///private/var/www/jlr3/n98-magerun2.phar/src/N98/Magento/Application.php:526
N98\Magento\Application->doRun() at phar:///private/var/www/jlr3/n98-magerun2.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at phar:///private/var/www/jlr3/n98-magerun2.phar/src/N98/Magento/Application.php:564
N98\Magento\Application->run() at /private/var/www/jlr3/n98-magerun2.phar:8
sys:cron:run [job]
hi, I added some changes to the development version. if you update to it you can try again.
I get the same error "Required parameter 'theme_dir' was not passed" on the latest 1.3.3 version. Do you have any workaround?
We had te same problem today and we used this to resolve the issue:
$appState->emulateAreaCode(Area::AREA_ADMINHTML, function () use () {
// Send your email
});
Because the startEnvironmentEmulation
doesn't change the area code in Magento.
And Magerun uses emulateAreaCode('crontab'…)
to run the cron jobs.
@jacquesbh: Thanks for the feedback. When I reviewed the cron invocation last time, I did not find a place where the area code is changed. Can the code be set per cronjob somehow?
I don't think so. The best way to do that is to emulate (both store and area code).
Wouldn't that then be the job of the module's / cron action's code? Magento's own code is hard to follow / a bit convoluted when it's about to invoke the cron actions which makes it hard to mimic the behaviour for single cron action invocation as by Magerun.
I use emulation in some of my cronjobs yes, directly in the module's code.
I'm having the same issue. I am trying to send an email via a cron job, but I get the same error as https://github.com/netz98/n98-magerun2/issues/245#issuecomment-275353281. This is the code I currently have:
Acme/DropShipment/Cron/SendDropShipmentEmails.php
<?PHP
namespace Acme\DropShipment\Cron;
use Magento\Framework\Mail\Template\TransportBuilder;
class SendDropshipmentEmails
{
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* @var TransportBuilder
*/
private $transportBuilder;
public function __construct(
\Psr\Log\LoggerInterface $logger,
TransportBuilder $transportBuilder
)
{
$this->logger = $logger;
$this->transportBuilder = $transportBuilder;
}
/**
* Execute the cron
*
* @return void
*/
public function execute()
{
$templateVars = [];
$transport = $this->transportBuilder->setTemplateIdentifier('acme_dropshipment_email')
->setTemplateOptions( [ 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => 1 ] )
->setTemplateVars( $templateVars )
->setFrom( [ "name" => "rick", "email" => "local@mail.dev" ] )
->addTo('email@address.com')
->setReplyTo( "someone@mail.dev" )
->getTransport();
$transport->sendMessage();
$this->_logger->addDebug( "Message sent" );
}
}
Acme/DropShipment/etc/email_templates.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
<template id="acme_dropshipment_email" label="DropShipment Email" file="dropshipment.html" type="html" module="Acme_DropShipment" area="frontend"/>
</config>
Acme/DropShipment/view/frontend/email/dropshipment.html
Hello world :D
When I comment out the InvalidArgumentException
in /vendor/magento/framework/View/Design/Fallback/Rule/Simple.php:61
, the code continues without any hiccups.
I updated magerun2 to 2.0.0. Does someone have the fix for this issue?
Any fix for this? Got the same error when running sys:cron:run sales_send_order_emails
@PascalBrouwers Until this day I comment out /vendor/magento/framework/View/Design/Fallback/Rule/Simple.php:61
during development. I have no clue how to actually fix the problem.
Same error with version 2.1.2. Magerun sets area code as "crontab" and Magento can't find the template file.
Also happening in 2.1.7
2.2 +1
Some notice: This fix resolve a double emulation. If you want to send mails in frontend-mode, you still need startEnvironmentEmulation. For more details look at the pull request description: #397
I'm trying to send email with cronjob to list from adminhtml area, throws error:
Required parameter 'theme_dir' was not passed
email sending works with magento cron:run command.