8

When I package my app in Managed Package for outside world, the other org gets "Internal Server Error" when the Lightning Component Tab is loaded in S1 or new Lightning Experience interface.

I worked out myself to see if I missed namespaces. While doing that I'm trying to work namespaces according to this document - Lightning Component Usage in Organizations with a Namespace Prefix

Now I'm having big trouble in getting my code to save with things mentioned in the document.

For example:

1] The document suggests this format for initiating sObject and default:

<aura:attribute name="newExpense" type="myns.Expense__c"
    default="{ 'sobjectType': 'myns__Expense__c',
               'Name': '',
               'myns__Amount__c': 0
    }" />

I save my code just like the way mentioned above. But it auto changes back to this format:

<aura:attribute name="newExpense" type="myns__Expense__c"
    default="{ 'sobjectType': 'myns__Expense__c',
               'Name': '',
               'myns__Amount__c': 0
    }" />

Please note that the attribute type auto changed from type="myns.Expense__c" to type="myns__Expense__c" and I've no understanding if this could cause the Internal Server Error and if so, how can I make this fix? Because I try to change CORRECT format of code but Developer Console changes it back to incorrect format.

2] Secondly, the same kind of issue in attribute noticed in another place: I am trying to save this attribute like this:

<aura:attribute name="matches" type="myns.wDataItem[]" description="The data items returned by the Apex controller." />

but it auto changes back to this:

<aura:attribute name="matches" type="myns.wDataItem" description="The data items returned by the Apex controller." />

Noticed the changes of Type attribute again? It changed from type="myns.wDataItem[]" to type="myns.wDataItem". I want a Custom Apex class array datatype. The APEX Class is Public and all Properties are marked with @AuraEnabled.

But if I change the attribute to this:

<aura:attribute name="matches" type="c.wDataItem[]" description="The data items returned by the Apex controller." />

It save correctly with Datatype being an Array instead of single item. Here I used the default namespace c this making type="c.wDataItem[]"

And with these namespace or default namespace, the Lightning Component Tab works absolutely fine in the Dev Org environment.

And from SFDC Support I was able to get more details about Internal Server Error, they say the error is this:

404 Not Found (Application Error)
Cause: InvalidExpressionException: Unable to read SObject

So it seems the sObject is not readable due to namespacing issue and if I am not able to save the correct code from Developer Console, how can I make sure I get this error resolved? I'm really stuck bad here, need help!

3

After Spring '16 deployment the same component started working fine.

SFDC support was also not able to pin point the cause. They were able to reproduce it but have not suggested it as a bug (strange!).

Though Spring '16 deployment have magically fixed that. I'm now able to run my same old code without any modifications and no errors of internal server on tab load in managed packaged lightning component.

It seems I was in fact doing all things right.

2

Have you done anything as far as setting access so that your component (and any necessary resources it uses) are accessible outside of the package namespace?

I am not an expert at this, but when you build a package, and you need to make features (components, Apex classes, VF pages) accessible to the installing org to use, you must make them global. Perhaps this is your problem.

You have not mentioned setting access. So if you've not done this already, I would suggest having a read of the topic on setting access for lightning components. And then the topic on packaging and distributing components. This second has a link to the general ISV guide, which might help you check the other features are set as the correct access, too.

The syntax for doing this is trivial. On the open tag of any components you want the installing org to be able to use:

<aura:component access="global" ...all the other stuff... >
  • The component is part of my single package. At this point I dont want it to be exposed to external org and the Component and Lightning Component Tab both are part of my package itself and after installation of the package in testing org I get the Error when I load the lightning component tab in S1 and lightning experience. – VarunC Dec 10 '15 at 12:18
  • Your testing org is the external org, in this instance. In order for your installed component to work in any other org, with any other namespace you need to make its access global. – pchittum Dec 10 '15 at 14:49
  • I'll give that a try as well. But still not able to clearly understand this sry :-) ... I've 1 Dev org with namespace myns and I created a package in this org with normal VF pages and apex classes. Now I added new Lightning Component to this package and the Component has following markup <aura:component controller="myns.ExpenseDataController" implements="force:appHostable,flexipage:availableForAllPageTypes"> and uploaded new version. Then installed the new version in separate Org. then I need to provide access="global" even though no second namespace is involved, correct? – VarunC Dec 10 '15 at 14:56
  • Normally with VF Pages/VF Components/Apex and Managed Package we don't need to make a VF page or VF Component or Apex class a Global entity. Global entity would allow external org be able to create custom component referencing our Managed Package code or component. – VarunC Dec 10 '15 at 14:59
  • As I stated, I'm not an expert. But the first link states unequivocally, "Setting access="global" makes a bundle available to package subscribers and other namespaces." My understanding is that the second org is using a different namespace. The "local" namespace of that org counts as a different namespace from the installed package's. – pchittum Dec 10 '15 at 15:11
0

The correction in the first case is correct you need to use __ to separate namespace of an object.

Regarding to the second correction try to specify type="List" as there are a some core issues that broke serialization of arrays.

And most probably you have the same error as in stated here- SObject array parameter in Lightning causes Internal Salesforce.com Error in Apex controller

  • I'm afraid that didn't solved the issue as well. A quick test trial I already did was to Remove the wDataItem[] array parameter from my component. And keeping the namespace__ format and packaged the component and installed in another org and the Lightning Component Tab still loaded with same Internal Server Error on tab load. – VarunC Dec 10 '15 at 5:57

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.