Component parse failure when using @liaAddScript

SOLVED

Hi,

 

I am getting the following error thrown when submitting a plugin to staging via the SDK....

 

Failure Code: COMPONENT_PARSE_FAILURE
Failure Rule: CUSTOM_RULE
Failure Message: A component file in the plugin has a possible issue.
Failure Details: Detailed error is: No object of type lithium.web.javascript.tapestry.services.LithiumJavaScriptSupport is available from the Environment..

 

This is happening for every component that uses the @liaAddScript directive.

 

Does anybody have any idea what could be causing this?

 

Any help is much appreciated!

 

Thanks

James

 

EDIT: Sorry, here is an example code snippet that is failing

 

<@liaAddScript>
;(function($){
setTimeout(function() {

jQuery('.lia-category-community-management').after('<li class="board-dropdown-item community-admin-link"><a href="/t5/bizapps/bizappspage/tab/community%3Aadmin" id="communityAdmin" class="lia-link-navigation lia-component-admin-widget-admin">Community Admin</a></li><li class="board-dropdown-item plugin-editor-link"><a href="/t5/bizapps/bizappspage/tab/community%3Astudio" id="lithiumStudio" class="lia-link-navigation lia-component-lithiumstudio-action-lithium-studio">Studio</a></li>');
},1000);
})(LITHIUM.jQuery);
</@liaAddScript>

 

Message 1 of 8
7 REPLIES
Web Design
Web Development

@james_whiteley

 

This might be a long shot but the namespace for JQuery is already mapped to $ so you could try modifying the line beginning jQuery as follows:

 

<@liaAddScript>
;(function($){
setTimeout(function() {

$('.lia-category-community-management').after('<li class="board-dropdown-item community-admin-link"><a href="/t5/bizapps/bizappspage/tab/community%3Aadmin" id="communityAdmin" class="lia-link-navigation lia-component-admin-widget-admin">Community Admin</a></li><li class="board-dropdown-item plugin-editor-link"><a href="/t5/bizapps/bizappspage/tab/community%3Astudio" id="lithiumStudio" class="lia-link-navigation lia-component-lithiumstudio-action-lithium-studio">Studio</a></li>');
},1000);
})(LITHIUM.jQuery);
</@liaAddScript>

Let us know if this works.

Robert
Lithium Certified Developer

Click the Kudos button below if you find my posts helpful. If I've answered your query please click the Mark Solution button to help others find the same answer.
Message 2 of 8

Hi @RobertT,

 

Thanks for your reply!

 

It fails even if I take that line out unfortunately. There's 9 components in total that contain a @liaAddScript directive and each of them are failing with the same error.

 

Thanks for your help

James

Message 3 of 8
Highlighted
Web Design
Web Development
Solution

@james_whiteley,

 

There is one more thing you can try, it involves modifying the server.conf.json file in the root of your SDK folder to change the following lines or add them if they are missing.

 

"strictMode": false,
"skipTemplateValidation": true

This needs to be added before the closing } in the file. What you're doing is effectively turning off validation on files before uploading them to studio. 

 

 

 

Robert
Lithium Certified Developer

Click the Kudos button below if you find my posts helpful. If I've answered your query please click the Mark Solution button to help others find the same answer.
Message 4 of 8

Hi @RobertT,

 

Thanks again for your reply.

 

It will still fail validation on production though, I would have thought.

 

James

Message 5 of 8
Web Design
Web Development

@james_whiteley, it shouldn't fail if you know the code has run before.

 

What you may want to do is create the component in Studio first and test it with the same code, Studio will always override the SDK, but if you create the same component in Studio and paste in the code to test it should confirm if there is a problem with validation.

Robert
Lithium Certified Developer

Click the Kudos button below if you find my posts helpful. If I've answered your query please click the Mark Solution button to help others find the same answer.
Message 6 of 8

Hi @RobertT,

 

I've managed to get it working and live on production. Thanks very much for your help, I will accept your suggestion to modify the server.conf.json as the solution.

 

James

Message 7 of 8
Web Design
Web Development

Epic, 

 

Glad it's sorted for you Smiley Happy

Robert
Lithium Certified Developer

Click the Kudos button below if you find my posts helpful. If I've answered your query please click the Mark Solution button to help others find the same answer.
Message 8 of 8