aadarchi icon indicating copy to clipboard operation
aadarchi copied to clipboard

Unable to read components in packages XXXXX of container YYYYYY

Open jrevillard opened this issue 4 years ago • 3 comments

Hello,

I'm really interested in your project and I'm trying to use both the Maven and the Spring enhancers on a multi-module maven project. Unfortunately I cannot shore the source code but I have the following issue:

mai 11, 2021 2:19:41 PM org.ndx.agile.architecture.inferer.spring.SpringComponentDetector startVisit
AVERTISSEMENT: Unable to read components in packages XXXXXXX of container YYYYYYYYY
java.lang.NullPointerException
	at com.structurizr.model.Container.lambda$getComponentOfType$1(Container.java:177)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
	at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
	at com.structurizr.model.Container.getComponentOfType(Container.java:177)
	at com.structurizr.analysis.AbstractComponentFinderStrategy.findComponent(AbstractComponentFinderStrategy.java:147)
	at com.structurizr.analysis.AbstractComponentFinderStrategy.findSupportingTypes(AbstractComponentFinderStrategy.java:91)
	at org.ndx.agile.architecture.inferer.spring.AdaptableSpringComponentFinderStrategy.afterFindComponents(AdaptableSpringComponentFinderStrategy.java:126)
	at com.structurizr.analysis.ComponentFinder.findComponents(ComponentFinder.java:81)
	at org.ndx.agile.architecture.inferer.spring.SpringComponentDetector.startVisit(SpringComponentDetector.java:48)
	at org.ndx.agile.architecture.inferer.spring.SpringComponentDetector$Proxy$_$$_WeldClientProxy.startVisit(Unknown Source)
	at org.ndx.agile.architecture.base.ArchitectureEnhancer.lambda$enhancerVisitSystem$12(ArchitectureEnhancer.java:119)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)

What could cause this ?

Also, there is something that I do not understand: what should be the result in term of components when you use the two connectors (Spring and Maven) ? It seems that only the components extracted from the Spring connector appears into the final diagram, is it normal ?

Best, Jerome

jrevillard avatar May 11 '21 13:05 jrevillard

oh fuck, I never saw your issue, sorry. I'll take a look at that soon

Riduidel avatar Jun 22 '21 08:06 Riduidel

OK, so, first thing is to understand what can happen. agile-architecture-documentation-system uses maven to detect the various containers, assuming each maven module is a distinct container. Then I delegate detection of Spring components to structurizr analysis component, which has some code to locate spring-annotated classes (@Service, @Repository, and so on) and consider them as components.

So, in your code, the SpringComponentDetector is invoked on a maven module in which we have detected some Spring classes (that's the role of this detection line where the technology has been determined by scanning maven dependencies).

But there is even more. In most of Spring projects, there are interfaces/implementations dualities : one declare a IUserService interface with only one implementation, the UserServiceImpl. But Structurizr has good reasons to prefer the classes as components. So I have that class AdaptableSpringComponentFinderStrategy which role is to revert the linking, provided a property has been set to true on module, which is the default value. And this class will run a call to com.structurizr.analysis.AbstractComponentFinderStrategy.findSupportingTypes(Set<Component>) to detect all components.

And this call fails.

I'm pretty sure the fail is in this line

Optional<Component> component = components.stream().filter(c -> type.equals(c.getType().getType())).findFirst();

and is due to the fact that some component has a null type information.

I would love to see the code that exposes this bug. Do you think we could collaborate on that ?

Riduidel avatar Sep 02 '21 13:09 Riduidel

You can contact me on Twitter (https://twitter.com/riduidel) or by mail (my mail address is used in all commits of this repository). So feel free to send me a message.

Riduidel avatar Sep 02 '21 13:09 Riduidel

Any progress on this subject @jrevillard ?

Riduidel avatar Oct 11 '22 07:10 Riduidel

Sorry @Riduidel ... I did not continue the work on this topic and cannot do that anymore. With all the refactoring that you did I think that I will have to test again from scratch at some point.

Best, Jerome

jrevillard avatar Nov 14 '22 11:11 jrevillard

Sorry to read that. If there is something I can do to help you onboard "again", let me know. Can we close that issue ?

Riduidel avatar Nov 14 '22 13:11 Riduidel

Yes please close. As I said, I will restart from scratch on this topic I think.

jrevillard avatar Nov 14 '22 16:11 jrevillard