Scanner SubTypesScanner was not configured
Hey, first of all your jsonschema-generator is really great thing! I love it!
I am jusing maven to generate json schemas out of my Pojo classes. this works like a charm when using it like this:
<classNames>
<className>model.entity.user.User</className>
<className>model.entity.group.Group</className>
</classNames>
if i want to use it like this:
<packageNames>
<packageName>mode</packageName>
</packageNames>
i get an exception from
org.reflections
Caused by: org.reflections.ReflectionsException: Scanner SubTypesScanner was not configured
Can you explain how to configure the SubTypesScanner via maven? Regards and Dankeschön Clem
Hi Clem,
I will try to reproduce your problem and come up with a solution.
Regards,
Jan
Hi Clem,
I have found and solved the issue. It was related to the setting of the proper classpath.
I will make a branch with the fix and discuss with Carsten about releasing.
Regards,
Jan
Hey coool! Thanks for that quick support! Hope the branch is merged soon and the plugin available on Central.
Another thing/feature: Have you thought about include- and exclude (Regex/glob) pattern for further filtering? Regards and thank you Clem
- @JanLabrie thanks for taking this on. I wouldn't have had time for it.
- @clemi2408 Jan's fix has been merged v4.12.1 has been released. It may take a few hours until it has been propagated through the various Maven repositories.
- We're open to additional ideas. Feel free to create a PR for Jan and me to take a look.
Issue still not fixed :(
Failed to execute goal com.github.victools:jsonschema-maven-plugin:4.12.1:generate (default) on project schemafuck: Execution default of goal com.github.victools:jsonschema-maven-plugin:4.12.1:generate failed: Scanner SubTypesScanner was not configured
Mmmmm...not good. It worked for me. :-)
I will investigate and get back to you.
Clem,
I retried with the official release 4.12.1 and in my project I am able to generate schema's for a package.
Would it possible to share your setup, so I can examine it?
Jan
Hey Jan, sorry for the late response - had to switch out the device over the weekend :-/ Here is the part of my maven pom:
<plugin>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-maven-plugin</artifactId>
<version>${victool-json-schema-generator-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- <packageNames>
<packageName>model.dto</packageName>
</packageNames>-->
<classNames>
<className>model.entity.group.Group</className>
<className>model.entity.user.User</className>
</classNames>
<schemaVersion>DRAFT_2019_09</schemaVersion>
<schemaFileName>{0}.json</schemaFileName>
<schemaFilePath>${schema.json.folder}</schemaFilePath>
<options>
<enabled>
<option>DEFINITIONS_FOR_ALL_OBJECTS</option>
<option>NULLABLE_FIELDS_BY_DEFAULT</option>
<option>FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT</option>
<option>ADDITIONAL_FIXED_TYPES</option>
<option>DEFINITIONS_FOR_ALL_OBJECTS</option>
<option>PLAIN_DEFINITION_KEYS</option>
<option>ALLOF_CLEANUP_AT_THE_END</option>
</enabled>
</options>
<modules>
<module>
<name>Jackson</name>
<options>
<option>FLATTENED_ENUMS_FROM_JSONVALUE</option>
</options>
</module>
<module>
<name>JavaxValidation</name>
</module>
<module>
<name>Swagger15</name>
</module>
</modules>
</configuration>
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax-validation.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.annotations.version}</version>
</dependency>
</dependencies>
</plugin>
U need something else? Regards Clem
Thanks for the content. I will have a look at it.
Hi Clem,
I discovered that the Reflections library gives the error you mentioned in case it can not find any classes on the specified path.
Can it be that you do not have any class files in the model.dto package?
It is difficult to understand the error message. I will investigate whether it can be made friendlier.
Regards,
Jan
There are files in that path. But these files are in the target folder because they are generated out of xsds. If i reference them directly by class name they are resolvable. But maybe there is an issue in class path scanning in relation to the target folder?
How can i support you?
This might just be a timing issue then. Can you check in what Maven build phase the code generation occurs? If that happens only after the schema generation, you know why it’s not finding anything.
Might be possible but to be honest i dont believe in that assumption. This is based on the fact that its working using this:
<classNames>
<className>model.entity.user.User</className>
</classNames>
Fair enough. Might still be a classloader issue when we look-up packages, that it somehow ignores generated class files.
@clemi2408 if you have the capacity, it'd be great to have a minimal sample project somewhere to allow us to reproduce this locally while playing around with potential solutions.
A reproduction set will definitly help. The classloader that is used to load individual classes is also used for loading packages. So we should investigate further to find the difference.
Besides the reproduction set it would be good if you could try to use the class mechanism to one of your classes in model.dto i.e:
This way we know whether it is a generic classloader thing, i.e. model.dto is not in the classpath, or that it is specifically related to the package loading.
Regards,
Jan
Op vr 5 jun. 2020 16:02 schreef Carsten Wickner [email protected]:
Fair enough. Might still be a classloader issue when we look-up packages, that it somehow ignores generated class files.
@clemi2408 https://github.com/clemi2408 if you have the capacity, it'd be great to have a minimal sample project somewhere to allow us to reproduce this locally while playing around with potential solutions.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/victools/jsonschema-generator/issues/102#issuecomment-639503968, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPRADAOC4TYBC4LK5JGBIDRVD3GJANCNFSM4NNEICFQ . [image: image.gif]
Hi guys, have created github repo and invited you two. Dont be scared, i try to do some stunts with that project:
Input:
- XSD
- OpenApi def (without datatypes)
Output:
- Json Schema
- Complete OpenAPI file
Its WIP regards Clem
Hi Clem,
Thank you for providing the reproduction repo.
It indeed builds successfully by default, and when I enable the <packageNames> it starts failing.
I am looking for the model.dto package that you mention in the pom. But I can not find it in the target folder, and neither are there any class files for the model.dto package.
In the commented java code you write:
import model.dto.UserDTO
Which can not be resolved.
Can you please clarify where the model.dto classes are?
Thank you!
Jan
hey, look, if i execute mvn compile they get stored here:

Aha...When I remove the <packageNames> element, the model.dto classes are generated.
This means it is an ordering issue. The json schema generator is invoked before the model.dto classes are generated.
This is where we must look for the solution. Either generate the model.dto classes earlier, or the schema later.
Jan