Failed to export application fails with error templates for application null

Document ID : KB000071387
Last Modified Date : 20/02/2018
Show Technical Document Details
Issue:
When trying to export an application you will get failure to do so and get below errors.

2017-12-26 11:54:06,525 [http-nio-8080-exec-111] ERROR (com.nolio.releasecenter.designer.services.DesignerExportImportService:412) - Failed to export templates for application null (null)
java.lang.NullPointerException
                at com.nolio.releasecenter.services.export.RCExportServiceImpl$XMLExporter.visitStepInDeployTemplateStage(RCExportServiceImpl.java:2803)
                at com.nolio.releasecenter.services.export.RCExportServiceImpl$XMLExporter.visit(RCExportServiceImpl.java:2743)
                at com.nolio.releasecenter.services.export.RCExportServiceImpl$XMLExporter.visit(RCExportServiceImpl.java:2456)

On ROC UI the error will be something like below.

Application export fails

 

Environment:
DB : Oracle Database 12c Enterprise Edition 12.1.0.2.0 - 64bit
Release Automation: 6.4
Cause:
The problem faced above is due to some db corruption, which resulted in lost of default stages from specific deployment template for example ( Default Category \ Default Template )

To facilitate findings, below are some query can help you in identifying the corrupted templates.

Query to find the template which have some corruption in terms of missing stages.
SELECT a.APP_NAME, dt.NAME AS DEPLOY_TEMPLATE_NAME, t.* FROM RC_TEMPLATES t INNER JOIN RC_DEPLOY_TEMPLATE dt ON t.ID = dt.TEMPLATEID
INNER JOIN APPLICATIONS a ON
t.APPLICATION = a.ID  WHERE dt.ID NOT IN(SELECT dts.DEPLOYMENTTEMPLATEID FROM RC_DEPLOY_TEMPATE_STAGES dts) AND t.ARCHIVED = 0 AND dt.ARCHIVED = 0;

Query to find all template which have one or more missing stages.
SELECT count(dts.DEPLOYMENTTEMPLATEID),DEPLOYMENTTEMPLATEID FROM RC_DEPLOY_TEMPATE_STAGES dts GROUP BY dts.DEPLOYMENTTEMPLATEID HAVING count(dts.DEPLOYMENTTEMPLATEID) < 4
Resolution:
In order to fix the problem faced we need to correct the data corruption in database for that respective templates. Please find below listed queries to achieve same.

Note: The id highlighted below is the id of your template identified by above query.
 
Insert into RC_DEPLOY_TEMPATE_STAGES (ID,DEPLOYMENTTEMPLATEID,MUSTSUCCEED,RUNANYWAY,STAGETYPE,STARTAUTOMATICALLY) values (hibernate_sequence.nextval,<template-id>,0,0,'PREPARE',1);
Insert into RC_DEPLOY_TEMPATE_STAGES (ID,DEPLOYMENTTEMPLATEID,MUSTSUCCEED,RUNANYWAY,STAGETYPE,STARTAUTOMATICALLY) values (hibernate_sequence.nextval,<template-id>,0,0,'INIT_RELEASE_CANDIDATE',1);
Insert into RC_DEPLOY_TEMPATE_STAGES (ID,DEPLOYMENTTEMPLATEID,MUSTSUCCEED,RUNANYWAY,STAGETYPE,STARTAUTOMATICALLY) values (hibernate_sequence.nextval,<template-id>,0,0,'RUN',1);
Insert into RC_DEPLOY_TEMPATE_STAGES (ID,DEPLOYMENTTEMPLATEID,MUSTSUCCEED,RUNANYWAY,STAGETYPE,STARTAUTOMATICALLY) values (hibernate_sequence.nextval,<template-id>,0,0,'POST_DEPLOYMENT',1);
Additional Information:
In order to verify the issue been fixed with above query, just navigate to  ROC ->Release - Templates-> Default Category-> [Problematic Template] and try to save this as XML. If you are able to save it without any error the issue had been fixed. Now it should be fine to export the application.