aoudiamoncef / apollo-client-maven-plugin

Generate a Java/Kotlin GraphQL client based on introspection data and predefined queries.
MIT License
92 stars 28 forks source link

lateinit property services has not been initialized #50

Closed mac2000 closed 2 years ago

mac2000 commented 3 years ago

did tried to clone repository, open apollo-client-maven-plugin-tests in idea, comment some unnecessary parts from pox.xml and define plugin version to 4.0.4 as suggested in readme

after trying to perform apollo-client:generate maven task retrieving lateinit property services has not been initialized

full log
C:\Users\mac\.jdks\adopt-openjdk-14.0.2\bin\java.exe -Dmaven.multiModuleProjectDirectory=C:\Users\mac\Downloads\apollo-client-maven-plugin -Dmaven.home=C:\Users\mac\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4746.92\plugins\maven\lib\maven3 -Dclassworlds.conf=C:\Users\mac\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4746.92\plugins\maven\lib\maven3\bin\m2.conf -Dmaven.ext.class.path=C:\Users\mac\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4746.92\plugins\maven\lib\maven-event-listener.jar -javaagent:C:\Users\mac\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4746.92\lib\idea_rt.jar=61317:C:\Users\mac\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4746.92\bin -Dfile.encoding=UTF-8 -classpath C:\Users\mac\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4746.92\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Users\mac\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4746.92\plugins\maven\lib\maven3\boot\plexus-classworlds.license org.codehaus.classworlds.Launcher -Didea.version=2021.2 apollo-client:generate -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] ------< com.github.aoudiamoncef:apollo-client-maven-plugin-tests >------
[INFO] Building apollo-client-maven-plugin-tests 4.0.4
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- apollo-client-maven-plugin:4.0.4:generate (default-cli) @ apollo-client-maven-plugin-tests ---
[INFO] Apollo GraphQL Client code generation task started
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.680 s
[INFO] Finished at: 2021-08-19T14:13:15+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.4:generate (default-cli) on project apollo-client-maven-plugin-tests: Execution default-cli of goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.4:generate failed: lateinit property services has not been initialized -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.4:generate (default-cli) on project apollo-client-maven-plugin-tests: Execution default-cli of goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.4:generate failed: lateinit property services has not been initialized
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.4:generate failed: lateinit property services has not been initialized
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property services has not been initialized
    at com.github.aoudiamoncef.apollo.plugin.GraphQLClientMojo.execute (GraphQLClientMojo.kt:63)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Process finished with exit code 1

initially got the same on selenide project but decided to test everything in your test example

feel free to ask for any additional details will be happy to provide everything needed

aoudiamoncef commented 3 years ago

Hi @mac2000

It's a configuration error. please could you share your actual configuration ?

mac2000 commented 3 years ago

Hm, it was taken from sample

and the only things I have changed were:

comment out parent project

image

provide concrete version

image

here is full file

pom.xml

    4.0.0

    
        com.github.aoudiamoncef
        apollo-client-maven-plugin-parent
        4.0.4

    

    apollo-client-maven-plugin-tests
    jar
    apollo-client-maven-plugin-tests
    Test for maven plugin
    https://github.com/aoudiamoncef/apollo-client-maven-plugin

    
        true
        true
    

    
        
            com.apollographql.apollo
            apollo-runtime
        
        
            org.jetbrains
            annotations
        
        
            com.fasterxml.jackson.core
            jackson-databind
            test
        
        
            com.graphql-java
            graphql-java-tools
            test
        
        
            com.graphql-java
            graphql-java-servlet
            test
        
        
            io.undertow
            undertow-core
            test
        
        
            io.undertow
            undertow-servlet
            test
        
        
            org.assertj
            assertj-core
            test
        
        
            org.junit.jupiter
            junit-jupiter
            test
        
        
            org.slf4j
            slf4j-simple
            test
        
    

    
        src/test/kotlin
        
            
                com.github.aoudiamoncef
                apollo-client-maven-plugin
                4.0.4
                
                    
                        
                            generate
                        
                        
                            
                                
                                    true
                                    true
                                    ${project.basedir}/src/main/graphql/books
                                    ${project.basedir}/src/main/graphql/books/schema.json
                                    
                                        **/*.graphql
                                        **/*.gql
                                        **/*.json
                                        **/*.sdl"
                                    
                                    
                                        **/*.kakah
                                    

                                    
                                        books
                                        
                                            ${project.build.directory}/generated-sources/graphql-client/books/
                                        
                                        true
                                        
                                            ${project.build.directory}/generated/operationOutput/apollo/books/operationOutput.json
                                        

                                        
                                            
                                                ${project.basedir}/src/main/graphql/books/
                                            
                                            true
                                            true
                                            false
                                            true
                                            
                                                java.lang.Long
                                            
                                            
                                                com.apollographql.apollo.compiler.OperationIdGenerator$Sha256
                                            
                                            false
                                            true
                                            ANNOTATED
                                            true
                                            false
                                            true
                                            com.lahzouz.apollo.graphql.client
                                            
                                            false
                                            
                                            true
                                            
                                                ${project.build.directory}/generated/metadata/apollo/books/metadata.json
                                            
                                            
                                            false
                                        
                                    

                                    
                                        false
                                        
                                        
                                        ${project.basedir}/src/main/graphql/books/schema.json
                                        10
                                        10
                                        10
                                        false
                                        false
                                        false
                                    
                                
                            
                        
                    
                
            
            
                org.jetbrains.kotlin
                kotlin-maven-plugin
                
                    ${java.version}
                
                
                    
                        compile
                        process-sources
                        
                            compile
                        
                    
                    
                        test-compile
                        test-compile
                        
                            test-compile
                        
                    
                
            
            
                org.apache.maven.plugins
                maven-surefire-plugin
                
                    false
                
            
        
    

aoudiamoncef commented 3 years ago
        <!--Auto configuration-->
        <books-api></books-api>

There is an error in plugin configuration which makes the binding between XML and Objects configuration impossible.

mac2000 commented 3 years ago

So, attempt number one - minimal configuration without cleaning up m2 cache - same results

Second attempt was, close idea, delete m2, reopen idea and rerun maven task unfortunately results are also the same

image

As you can see from screenshot idea did download everything from scratch but error still occurred

What is even worse now I totally confused with empty config we should not have problems with mapping mojos

aoudiamoncef commented 3 years ago

Try to use JDK 8 and Kotlin 1.4 and rebuild. Test dependencies are old, I'll improve tests with the release of Apollo complier 3.0 soon.

chrisociepa commented 3 years ago

Any update on this issue? I have the same problem after update from 3.3.1 to 4.0.4. With the former version I didn't have this problem. I use OpenJDK 11.

Just in case I am attaching the full stacktrace:

[ERROR] Failed to execute goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.3:generate (default) on project my-connector: Execution default of goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.3:generate failed: lateinit property services has not been initialized -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.3:generate (default) on project my-connector: Execution default of goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.3:generate failed: lateinit property services has not been initialized
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.3:generate failed: lateinit property services has not been initialized
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    ... 20 more
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property services has not been initialized
    at com.github.aoudiamoncef.apollo.plugin.GraphQLClientMojo.execute(GraphQLClientMojo.kt:63)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    ... 21 more
aoudiamoncef commented 3 years ago

Hi @chrisociepa,

When you got this error, it's a configuration issue, please find the new configuration here.

There are breaking changes between 3.x.x and 4.x.x. A new version based on Apollo 3.x.x will be release ASAP with breaking changes, so you could wait if you want to have it.

shavenG commented 2 years ago

test https://github.com/aoudiamoncef/spring-boot-apollo-graphql

I have the same problem

Failed to execute goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.5:generate (default-cli) on project spring-boot-apollo-client: Execution default-cli of goal com.github.aoudiamoncef:apollo-client-maven-plugin:4.0.5:generate failed: lateinit property services has not been initialized

shavenG commented 2 years ago

@aoudiamoncef below plugin config is ok

<plugin>
                <groupId>com.github.sparow199</groupId>
                <artifactId>apollo-client-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>

                        </configuration>
                    </execution>
                </executions>
            </plugin>