enriquepiatti / Magicento

PHPStorm plugin for Magento developers
115 stars 35 forks source link

[Magento2] NullPointerException when using plugin #234

Closed zupermanzupereroe closed 7 years ago

zupermanzupereroe commented 7 years ago

Hi Enrique,

I have some serious problem with PhpStorm 2016.2.2 (magicento2, version 1.3.0) on Linux Mint 18.

When I click Create Controller or Create New Theme or Create CRUD Model or Create Setup Files or Create Admin Menu I get the NullPointerException from the IDE.

For example if I click on Create Controller I get the following exception:

null
java.lang.NullPointerException
    at java.io.File.<init>(File.java:277)
    at com.magicento2.ui.components.ModulesComboBox.fillModules(ModulesComboBox.java:35)
    at com.magicento2.ui.components.ModulesComboBox.init(ModulesComboBox.java:26)
    at com.magicento2.ui.dialog.NewControllerDialog.createCenterPanel(NewControllerDialog.java:47)
    at com.intellij.openapi.ui.DialogWrapper.init(DialogWrapper.java:1279)
    at com.magicento2.ui.dialog.NewControllerDialog.<init>(NewControllerDialog.java:39)
    at com.magicento2.actions.CreateControllerAction.executeAction(CreateControllerAction.java:32)
    at com.magicento2.actions.Magicento2ActionAbstract.actionPerformed(Magicento2ActionAbstract.java:418)
    at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:197)
    at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88)
    at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:156)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:211)
    at com.intellij.ui.popup.PopupFactoryImpl$ActionPopupStep.performAction(PopupFactoryImpl.java:875)
    at com.intellij.ui.popup.PopupFactoryImpl$ActionPopupStep.a(PopupFactoryImpl.java:863)
    at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:199)
    at com.intellij.ui.popup.AbstractPopup.a(AbstractPopup.java:1390)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at com.intellij.ide.IdeEventQueue.c(IdeEventQueue.java:795)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:631)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Am I missing something in my configuration?

Thanks

enriquepiatti commented 7 years ago

Hi @zupermanzupereroe seems that Magicento2 is detecting some module but is not being able to find the file path for that module, are you sure you have all your modules up to date in Magento2? You can also try clearing Magicento2 indexes (ALT+M ...) or PhpStorm cache (File > Invalidate cache restart) Let me know if that helps (I will add a warning to this in next version anyway)

zupermanzupereroe commented 7 years ago

Hi Enrique,

Refreshing Magicento2 Indexes fixed the issue. :)

Thanks

bsdnomad commented 7 years ago

Hello,

Upgrade from 1.2.0. to 1.4.0 causes NullPointerException to get thrown even while invoking Magicento2 menu with Alt+M. Neither index refresh, nor full index rebuild resolve the issue. Here's stack trace:

java.lang.NullPointerException at com.magicento2.models.phpclass.ResourceModel.isResourceModel(ResourceModel.java:27) at com.magicento2.actions.Magicento2ActionAbstract.isResourceModel(Magicento2ActionAbstract.java:588) at com.magicento2.actions.CreateGridAction._isApplicable(CreateGridAction.java:325) at com.magicento2.actions.Magicento2ActionAbstract.isApplicable(Magicento2ActionAbstract.java:74) at com.magicento2.Magicento2Action._getMagentoContextActions(Magicento2Action.java:129) at com.magicento2.Magicento2Action.executeAction(Magicento2Action.java:37) at com.magicento2.actions.Magicento2ActionAbstract.actionPerformed(Magicento2ActionAbstract.java:422) at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:199) at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:215) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:587) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:634) at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:204) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:633) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.e(IdeKeyEventDispatcher.java:477) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:211) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:657) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:391) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

IDE version is 2016.3.3 All plugins are up to date.

Any suggestions would be great. Thanks in advance!

enriquepiatti commented 7 years ago

Hi @bsdnomad, you are right, there is a bug (will be fixed in new release) but it should happen only if you use ALT+M when editing some "php" file without any class (for example registration.php or inside the PHP part from some .phtml), so you should be ok avoiding those files as a workaround

PS: you can also download and instlal Magicento again I have added a quick bugfix to that