Custom module problem in Docker container
-
14-04-2021 - |
質問
I am having an issue getting a custom module created with
https://cedcommerce.com/magento-2-module-creator/
to work properly inside of a Docker container.
I have tried containers from
https://github.com/alexcheng1982/docker-magento2
https://github.com/bitnami/bitnami-docker-magento
Both install and operate fine and when I include my module files by creating a volume I can install it just fine. The problem occurs when I add a new entry through the admin panel. I have this same module running locally on AMPPS server and it works as expected.
When deployed in default mode I get this display:
This is normal when run locally:
Here is the output of the errors produced when in developer mode:
2 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: [Vendor]\[Module]\Block\Adminhtml\Testmodel\Edit\Form
Exception #1 (ReflectionException): Class [Vendor]\[Module]\Block\Adminhtml\Testmodel\Edit\Form does not exist
Any help is appreciated.
EDIT:
(include docker-compose.yml)
My docker-compose.yml showing how I am mounting ./modules
to /app/code
version: '3.0'
services:
web:
image: alexcheng/magento2
ports:
- "80:80"
links:
- db
volumes:
- magento-data:/var/www/html
- ./modules:/var/www/html/app/code
env_file:
- env
db:
image: mysql:5.6.23
volumes:
- db-data:/var/lib/mysql/data
env_file:
- env
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- "8580:80"
links:
- db
volumes:
magento-data:
db-data:
EDIT:
(include full error)
2 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: TattcomTest\TestModuleName\Block\Adminhtml\Testmodel\Edit\Form
Exception #1 (ReflectionException): Class TattcomTest\TestModuleName\Block\Adminhtml\Testmodel\Edit\Form does not exist
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: TattcomTest\TestModuleName\Block\Adminhtml\Testmodel\Edit\Form
<pre>#1 Magento\Framework\View\Layout\Generator\Block->createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [vendor/magento/framework/View/Layout.php:785]
#2 Magento\Framework\View\Layout->_createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [vendor/magento/framework/View/Layout.php:768]
#3 Magento\Framework\View\Layout->createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:349]
#4 Magento\Framework\View\Layout\Interceptor->createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [vendor/magento/framework/View/Element/AbstractBlock.php:404]
#5 Magento\Framework\View\Element\AbstractBlock->addChild('form', 'TattcomTest\Test...') called at [vendor/magento/module-backend/Block/Widget/Form/Container.php:151]
#6 Magento\Backend\Block\Widget\Form\Container->_prepareLayout() called at [vendor/magento/framework/View/Element/AbstractBlock.php:287]
#7 Magento\Framework\View\Element\AbstractBlock->setLayout(&Magento\Framework\View\Layout\Interceptor#000000000bdc60ac0000000074d4eff1#) called at [vendor/magento/framework/View/Layout/Generator/Block.php:149]
#8 Magento\Framework\View\Layout\Generator\Block->process(&Magento\Framework\View\Layout\Reader\Context#000000000bdc66ec0000000074d4eff1#, &Magento\Framework\View\Layout\Generator\Context#000000000bdc663e0000000074d4eff1#) called at [vendor/magento/framework/View/Layout/GeneratorPool.php:81]
#9 Magento\Framework\View\Layout\GeneratorPool->process(&Magento\Framework\View\Layout\Reader\Context#000000000bdc66ec0000000074d4eff1#, &Magento\Framework\View\Layout\Generator\Context#000000000bdc663e0000000074d4eff1#) called at [vendor/magento/framework/View/Layout.php:352]
#10 Magento\Framework\View\Layout->generateElements() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:89]
#11 Magento\Framework\View\Layout\Interceptor->generateElements() called at [vendor/magento/framework/View/Layout/Builder.php:129]
#12 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Page/Builder.php:55]
#13 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Layout/Builder.php:65]
#14 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Page/Config.php:224]
#15 Magento\Framework\View\Page\Config->build() called at [vendor/magento/framework/View/Page/Config.php:237]
#16 Magento\Framework\View\Page\Config->publicBuild() called at [vendor/magento/framework/App/View.php:170]
#17 Magento\Framework\App\View->loadLayoutUpdates() called at [vendor/magento/framework/App/View.php:114]
#18 Magento\Framework\App\View->loadLayout() called at [app/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit.php:35]
#19 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#20 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callParent('execute', array()) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#21 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php:51]
#22 Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute(&TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor#000000000bdc67490000000074d4eff1#, &Closure#000000000bdc66040000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#23 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#24 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callPlugins('execute', array(), array(array('customerNotifica...', 'themeRegistratio...'))) called at [generated/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit/Interceptor.php:26]
#25 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#26 Magento\Framework\App\Action\Action->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/module-backend/App/AbstractAction.php:151]
#27 Magento\Backend\App\AbstractAction->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#28 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#29 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]
#30 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(&TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor#000000000bdc67490000000074d4eff1#, &Closure#000000000bdc60ed0000000074d4eff1#, &Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#31 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#32 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#), array(array('adminLoadDesign'))) called at [generated/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit/Interceptor.php:39]
#33 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/App/FrontController.php:186]
#34 Magento\Framework\App\FrontController->processRequest(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#, &TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor#000000000bdc67490000000074d4eff1#) called at [vendor/magento/framework/App/FrontController.php:118]
#35 Magento\Framework\App\FrontController->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#36 Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#37 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#38 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#), array(array('default_store_se...', 'page_cache_from_...', 'storeCookieValid...', 'install', 'configHash'))) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#39 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/App/Http.php:116]
#40 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#41 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000000bdc633f0000000074d4eff1#) called at [index.php:39]
</pre>
Exception #1 (ReflectionException): Class TattcomTest\TestModuleName\Block\Adminhtml\Testmodel\Edit\Form does not exist
<pre>#1 Magento\Framework\Code\Reader\ClassReader->getConstructor('TattcomTest\Test...') called at [vendor/magento/framework/ObjectManager/Definition/Runtime.php:54]
#2 Magento\Framework\ObjectManager\Definition\Runtime->getParameters('TattcomTest\Test...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:100]
#3 Magento\Framework\ObjectManager\Factory\Compiled->create('TattcomTest\Test...', array('data' => array())) called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56]
#4 Magento\Framework\ObjectManager\ObjectManager->create('TattcomTest\Test...', array('data' => array())) called at [vendor/magento/framework/View/Element/BlockFactory.php:46]
#5 Magento\Framework\View\Element\BlockFactory->createBlock('TattcomTest\Test...', array('data' => array())) called at [vendor/magento/framework/View/Layout/Generator/Block.php:272]
#6 Magento\Framework\View\Layout\Generator\Block->getBlockInstance('TattcomTest\Test...', array('data' => array())) called at [vendor/magento/framework/View/Layout/Generator/Block.php:252]
#7 Magento\Framework\View\Layout\Generator\Block->createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [vendor/magento/framework/View/Layout.php:785]
#8 Magento\Framework\View\Layout->_createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [vendor/magento/framework/View/Layout.php:768]
#9 Magento\Framework\View\Layout->createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:349]
#10 Magento\Framework\View\Layout\Interceptor->createBlock('TattcomTest\Test...', 'testmodulename_t...', array('data' => array())) called at [vendor/magento/framework/View/Element/AbstractBlock.php:404]
#11 Magento\Framework\View\Element\AbstractBlock->addChild('form', 'TattcomTest\Test...') called at [vendor/magento/module-backend/Block/Widget/Form/Container.php:151]
#12 Magento\Backend\Block\Widget\Form\Container->_prepareLayout() called at [vendor/magento/framework/View/Element/AbstractBlock.php:287]
#13 Magento\Framework\View\Element\AbstractBlock->setLayout(&Magento\Framework\View\Layout\Interceptor#000000000bdc60ac0000000074d4eff1#) called at [vendor/magento/framework/View/Layout/Generator/Block.php:149]
#14 Magento\Framework\View\Layout\Generator\Block->process(&Magento\Framework\View\Layout\Reader\Context#000000000bdc66ec0000000074d4eff1#, &Magento\Framework\View\Layout\Generator\Context#000000000bdc663e0000000074d4eff1#) called at [vendor/magento/framework/View/Layout/GeneratorPool.php:81]
#15 Magento\Framework\View\Layout\GeneratorPool->process(&Magento\Framework\View\Layout\Reader\Context#000000000bdc66ec0000000074d4eff1#, &Magento\Framework\View\Layout\Generator\Context#000000000bdc663e0000000074d4eff1#) called at [vendor/magento/framework/View/Layout.php:352]
#16 Magento\Framework\View\Layout->generateElements() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:89]
#17 Magento\Framework\View\Layout\Interceptor->generateElements() called at [vendor/magento/framework/View/Layout/Builder.php:129]
#18 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Page/Builder.php:55]
#19 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Layout/Builder.php:65]
#20 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Page/Config.php:224]
#21 Magento\Framework\View\Page\Config->build() called at [vendor/magento/framework/View/Page/Config.php:237]
#22 Magento\Framework\View\Page\Config->publicBuild() called at [vendor/magento/framework/App/View.php:170]
#23 Magento\Framework\App\View->loadLayoutUpdates() called at [vendor/magento/framework/App/View.php:114]
#24 Magento\Framework\App\View->loadLayout() called at [app/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit.php:35]
#25 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#26 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callParent('execute', array()) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#27 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php:51]
#28 Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute(&TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor#000000000bdc67490000000074d4eff1#, &Closure#000000000bdc66040000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#29 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#30 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callPlugins('execute', array(), array(array('customerNotifica...', 'themeRegistratio...'))) called at [generated/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit/Interceptor.php:26]
#31 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#32 Magento\Framework\App\Action\Action->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/module-backend/App/AbstractAction.php:151]
#33 Magento\Backend\App\AbstractAction->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#34 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#35 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]
#36 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(&TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor#000000000bdc67490000000074d4eff1#, &Closure#000000000bdc60ed0000000074d4eff1#, &Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#37 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#38 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#), array(array('adminLoadDesign'))) called at [generated/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit/Interceptor.php:39]
#39 TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/App/FrontController.php:186]
#40 Magento\Framework\App\FrontController->processRequest(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#, &TattcomTest\TestModuleName\Controller\Adminhtml\TestController\Edit\Interceptor#000000000bdc67490000000074d4eff1#) called at [vendor/magento/framework/App/FrontController.php:118]
#41 Magento\Framework\App\FrontController->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#42 Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#43 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#44 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#), array(array('default_store_se...', 'page_cache_from_...', 'storeCookieValid...', 'install', 'configHash'))) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#45 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000000bdc63c50000000074d4eff1#) called at [vendor/magento/framework/App/Http.php:116]
#46 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#47 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000000bdc633f0000000074d4eff1#) called at [index.php:39]
</pre>
EDIT
(include app/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit.php)
From error-
#18 Magento\Framework\App\View->loadLayout() called at [app/code/TattcomTest/TestModuleName/Controller/Adminhtml/TestController/Edit.php:35]
<?php
namespace Tattcom\SponsoredArtists\Controller\Adminhtml\SponsoredArtistsControllerAdmin;
class Edit extends \Magento\Backend\App\Action
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
public function execute()
{
// 1. Get ID and create model
$id = $this->getRequest()->getParam('id');
$model = $this->_objectManager->create('Tattcom\SponsoredArtists\Model\SponsoredArtists');
$registryObject = $this->_objectManager->get('Magento\Framework\Registry');
// 2. Initial checking
if ($id) {
$model->load($id);
if (!$model->getId()) {
$this->messageManager->addError(__('This row no longer exists.'));
$this->_redirect('*/*/');
return;
}
}
// 3. Set entered data if was error when we do save
$data = $this->_objectManager->get('Magento\Backend\Model\Session')->getFormData(true);
if (!empty($data)) {
$model->setData($data);
}
$registryObject->register('tattcom_sponsoredartists', $model);
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
}
解決 2
This doesn't appear to be a Docker issue but rather a Linux vs OSX file naming issue.
This post describes the problem Link
After building new module with new names it is working.
SponsoredArtistsController > Sponsoredartistscontroller
他のヒント
I assume you are using mac? If so, this is tipycally a sync issue between your local and the container.
- quick fix worth trying: try to stop and restart your container.
- another fix (possibly more optimised) is to mount the generated folder so that docker does not try to sync it. This would speed up your docker setup in fact. The generated line should give you a mapping. Unfortunately, I can't test this as I am on linux and don't need the line in practice.
- also if you use docker-sync, hit the command
docker-sync log
and you might see what's in the way in your sync