chhorz / oas-generator

Build-Time generation of OpenAPI specification files
https://chhorz.github.io/oas-generator/
Apache License 2.0
3 stars 1 forks source link

Installation leads to error #343

Closed ValeryDubrava closed 1 year ago

ValeryDubrava commented 1 year ago

Describe the bug I've followed the instruction and twice faced with an issue after the installation: 1) If I use maven-compile-plugin installation way I got the follow error: Invalid POM for com.github.chhorz:oas-generator-spring-web:jar:0.2.6, transitive dependencies (if any) will not be available, enable debug logging for more details 2) If I use dependency installation way I got another error: Bad service configuration file, or exception thrown while constructing Processor object: com/github/chhorz/openapi/common/OpenAPIProcessor 3) If I add some dependency I got this error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: com.github.chhorz.openapi.spring.SpringWebOpenApiProcessor Unable to get public no-arg constructor

Sample Code 1) this is a copy from the documentation

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>com.github.chhorz</groupId>
                            <artifactId>oas-generator-spring-web</artifactId>
                            <version>0.2.6</version>
                        </path>
                        <!-- ... more ... -->
                    </annotationProcessorPaths>
                    <annotationProcessors>
                        <annotationProcessor>com.github.chhorz.openapi.spring.SpringWebOpenApiProcessor</annotationProcessor>
                        <!-- ... more ... -->
                    </annotationProcessors>
                </configuration>
            </plugin>
        </plugins>

2)

        <dependency>
            <groupId>com.github.chhorz</groupId>
            <artifactId>oas-generator-spring-web</artifactId>
            <version>${oas-generator.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <scope>compile</scope>
        </dependency>

3)

        <dependency>
            <groupId>com.github.chhorz</groupId>
            <artifactId>oas-generator-common</artifactId>
            <version>${oas-generator.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.github.chhorz</groupId>
            <artifactId>oas-generator-spring-web</artifactId>
            <version>${oas-generator.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <scope>compile</scope>
        </dependency>

For both cases properties were:

    <properties>
        ...
        <oas-generator.version>0.2.6</oas-generator.version>
    </properties>

Expected behavior I've expected that documentation contains correct instruction, but it seems it has wrong information or has been never checked.

chhorz commented 1 year ago

Hello @ValeryDubrava ,

i created a small sample project to test your findings. Indeed the documentation for the first case with the maven-compiler-plugin does not work. But the second one worked for me.

Greetings Christian

ValeryDubrava commented 1 year ago

i created a small sample project to test your findings. Indeed the documentation for the first case with the maven-compiler-plugin does not work. But the second one worked for me.

Hello Christian, thank you for the reply. I'll check all cases with blank spring boot project and will return to you.

ValeryDubrava commented 1 year ago

@chhorz could you please take a look at this: https://github.com/ValeryDubrava/chhorz-oas-generator-test

I've got two errors depends on the way how I build it: by idea it gets me

java: An exception has occurred in the compiler (18.0.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java: java.lang.NoClassDefFoundError: com/github/chhorz/openapi/common/OpenAPIProcessor
java:   at java.base/java.lang.ClassLoader.defineClass1(Native Method)
java:   at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
java:   at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
java:   at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
java:   at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
java:   at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
java:   at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
java:   at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
java:   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
java:   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
java:   at org.jetbrains.jps.javac.LazyClassLoader.findClass(LazyClassLoader.java:58)
java:   at java.base/java.lang.Class.forName0(Native Method)
java:   at java.base/java.lang.Class.forName(Class.java:488)
java:   at java.base/java.lang.Class.forName(Class.java:467)
java:   at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1217)
java:   at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
java:   at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
java:   at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
java:   at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
java:   at org.jetbrains.jps.javac.Iterators$10.hasNext(Iterators.java:207)
java:   at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:886)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
java:   at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:237)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:524)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:587)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:522)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:366)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:291)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:245)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1523)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1153)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1303)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1118)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:889)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:471)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:197)
java:   at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:150)
java:   at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:371)
java:   at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:193)
java:   at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:211)
java:   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java:   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java:   at java.base/java.lang.Thread.run(Thread.java:833)
java: Caused by: java.lang.ClassNotFoundException: com.github.chhorz.openapi.common.OpenAPIProcessor
java:   at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
java:   ... 48 more
java: Compilation failed: internal java compiler error

by maven

[ERROR] Bad service configuration file, or exception thrown while constructing Processor object: com/github/chhorz/openapi/common/OpenAPIProcessor
chhorz commented 1 year ago

Hi, sorry for the long delay.

I cloned your test project and the maven build went fine. The only difference is, that i used an Java 19, because i don`t have an java 18 installed at the moment. The Intellij build and the maven build both worked fine for me.