4

Just moved some Lightning Component code (run via Lightning Out from a Visualforce page) from a non-namespace org where it works fine to a namespace org (where a managed package is created) where it doesn't.

The broken code is of this form:

public with sharing class LifePaymentsController {

    public class Data {
        @AuraEnabled public Payee[] payees;
        ...
    }

    public class Payee {
        @AuraEnabled public String id;
        @AuraEnabled public String name;
        ...
    }

    @AuraEnabled
    public static Data init(Id psId) {
        ...
    }
}

with this gack reported:

An internal server error has occurred
Error ID: 262515546-19951 (-1487509830)

org.auraframework.throwable.AuraUnhandledException: apex://LifePaymentsController.Payee: 404 Not Found (Application Error)
at .(apex://LifePaymentsController.Payee)
at org.auraframework.impl.adapter.ServletUtilAdapterImpl.handleServletException(ServletUtilAdapterImpl.java:191)
at aura.impl.sfdc.bean.adapter.SFDCAuraServletsUtilAdapter.actionServletGetPre(SFDCAuraServletsUtilAdapter.java:82)

...

at ui.aura.util.impl.AuraServletsUtilImpl.preAuraRequest(AuraServletsUtilImpl.java:93)
at aura.impl.sfdc.bean.adapter.SFDCAuraServletsUtilAdapter.actionServletGetPre(SFDCAuraServletsUtilAdapter.java:73)
... 162 more
Caused by: java.lang.NullPointerException
at aura.impl.apex.utils.AuraApexUtils.getUiTierCompatibleApexType(AuraApexUtils.java:133)
... 181 more

I am wondering if the problem is the use of nested classes; in a no-namespace org the class name is:

LifePaymentsController.Payee

but in the namespace org the class name is:

nsprefix.LifePaymentsController.Payee

and perhaps not handled well.

If this scenario does or does not work for you please answer so I know whether to look elsewhere for the cause of the problem or need to go ahead and refactor to avoid the nested classes (there are quite a few of them).

(Will also pursue Salesforce support to get any info they can supply from the gack error ID.)

6

As a workaround, you could set the type to be Object:

<aura:attribute name="payee" type="Object"/>

This does work, and to date I have not noticed any negative side effects of doing so.

  • Yep I've gone with this approach and no problems so far including in the installed package. Thanks! – Keith C May 6 '17 at 20:52
1

I had a single controller class with 9 inner data holder classes representing the various pieces of data being presented and edited. One top level class for one area of functionality - pretty clear and cohesive. There were various private constants and methods defined in the controller class used by the data holder classes and the data holder class names were short and descriptive because the context of their use was clear. This pattern has worked well in the past when implementing @RestResource classes.

I now have 9 extra top level classes and many extra public constants and methods. Much uglier. But the code works.

The problem appears to originate from the aura:attribute definition. The following works if there is no namespace but doesn't if there is a namespace:

<aura:attribute name="payee" type="LifePaymentsController.Payee"/>

requiring this change to using top-level classes:

<aura:attribute name="payee" type="LifePaymentsPayee"/>

So as of May 2017, avoid using inner classes in aura:attribute.

  • To save yourself the new top level classes, have you tried using type="Object" instead? I'm pretty sure that works (or worked). – Phil Hawthorn May 6 '17 at 11:17
  • @PhilHawthorn Yes I thought about that: its pretty unclear to me why the specific type information is there in the first place. Do you have any idea? I'll give that a go. – Keith C May 6 '17 at 11:22
  • I don't, seems odd but fortunate that Object works, and kind of makes it redundant – Phil Hawthorn May 6 '17 at 11:39
  • 1
    @PhilHawthorn I've gone with your type="Object" approach and looks good so far. If you want to post that as an answer I'll accept its a much simpler work-around. – Keith C May 6 '17 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.