Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Deployment View cannot be generated in c4plantuml when using workspace inclusion #18

Closed
plgregoire opened this issue Jul 8, 2022 · 2 comments

Comments

@plgregoire
Copy link

Hi,

I'm trying to separate my workspace in multiple files but I have encountered an issue with the deployment view generation. I have put together a small example that reproduce the issue.

parent_workspace.dsl

workspace {

    model {
        softwareSystem = softwareSystem "Software System"{
            database = container "Core Container" "" "Database"
        }
    }
}

workspace.dsl

!include parent_workspace.dsl
workspace {

    model {
        !ref softwareSystem {
            service = container "service"
        }
        service -> database "Reads from"


        deploymentEnvironment "OnPremise" {
            deploymentNode "Database Server" {
                containerInstance database
            }

            deploymentNode "Other server"{
                containerInstance service
            }
        }
    }
    
    views {
        deployment * OnPremise "OnPremise"  {
            include *
        }
    }
}

The generation will produce this error message

Exporting workspace from workspace.dsl
 - loading workspace from DSL
 - using C4PlantUMLExporter
java.lang.NullPointerException: Cannot invoke "com.structurizr.model.Relationship.getTags()" because the return value of "com.structurizr.model.Model.getRelationship(String)" is null
        at com.structurizr.export.plantuml.C4PlantUMLExporter.tagsOf(C4PlantUMLExporter.java:270)
        at com.structurizr.export.plantuml.C4PlantUMLExporter.writeRelationship(C4PlantUMLExporter.java:306)
        at com.structurizr.export.AbstractDiagramExporter.writeRelationships(AbstractDiagramExporter.java:553)
        at com.structurizr.export.AbstractDiagramExporter.export(AbstractDiagramExporter.java:462)
        at com.structurizr.export.AbstractDiagramExporter.export(AbstractDiagramExporter.java:439)
        at com.structurizr.export.AbstractDiagramExporter.export(AbstractDiagramExporter.java:71)
        at com.structurizr.cli.ExportCommand.run(ExportCommand.java:181)
        at com.structurizr.cli.StructurizrCliApplication.run(StructurizrCliApplication.java:36)
        at com.structurizr.cli.StructurizrCliApplication.main(StructurizrCliApplication.java:81)


One last thing to mention.
If the service and the database were in the same deploymentNode then it would work

@simonbrowndotje
Copy link
Contributor

!include simply inlines the referenced file, so you have two workspace definitions, which is likely to be causing the problem you’re seeing. See https://github.com/structurizr/dsl/blob/master/docs/language-reference.md#includes for more.

@plgregoire
Copy link
Author

Oh! So I should have something that looks more like this.

parent_workspace.dsl

model {
    softwareSystem = softwareSystem "Software System"{
        database = container "Core Container" "" "Database"
    }
}

workspace.dsl

workspace {

    !include parent_workspace.dsl
    
    model {

        !ref softwareSystem {
            service = container "service"
        }
        service -> database "Reads from"


        deploymentEnvironment "OnPremise" {
            deploymentNode "Database Server" {
                containerInstance database
            }

            deploymentNode "Other server"{
                containerInstance service
            }
        }
    }
    
    views {
        deployment * OnPremise "OnPremise"  {
            include *
        }
    }
}

It is strange that I had no problem with the other diagram types and only with the deployment. Anyway, It works with this syntax.
Thank you for you help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants