eclipse-basyx / basyx-java-components

java-components
MIT License
25 stars 31 forks source link

MongoDBAASAggregator::init is invoked in Ctor - setRegistry not respected for existing AAS/Submodels #11

Closed pneuschwander closed 2 years ago

pneuschwander commented 2 years ago

Hi team, I think I discovered a bug. MongoDBAASAggregator Ctor invokes the init-Method. The init-Method loads all existing AssetAdministrationShells from the database and creates the MultiSubmodelProvider for them. In this step, the value of the registry attribute of the MongoDBAASAggregator instance is used to construct the MultiSubmodelProvider instances. But the registry attribute is not yet configured (and therefore equals to null).

setRegistry is called in AASServerComponent after the MongoDBAASAggregator has been constructed. This is too late for being considered by the init logic that is triggered in the constructor of the MongoDBAASAggregator.

Therefore, at runtime, the registry is only known to newly added AAS. But AAS loaded from database (e.g. after a restart of the AAS-Server component) will not have the registry reference.

I noticed this when I tried to access a Edge-located Submodel by sending HTTP request to the AAS-Server. With newly added AAS, this works fine and the AAS-Server takes care of talking with the Edge-located Submodel for me. But after restarting the AAS-Server, it stopped working ("Submodel ... cannot be resolved locally, but no registry is passed").

FrankSchnicke commented 2 years ago

Many thanks for pointing this out. We will take a look at it and come back with further details.

FrankSchnicke commented 2 years ago

This issue is fixed with the latest commit in Bugfix branch. The fix will be included in the next release of BaSyx (1.0.2).