Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1245

Consider Kotlin metadata annotation for Kotlin class kind retrieval

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2 (Kay SR2)
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows 10, JDK 9.0.4, Kotlin 1.2.20, Spring Data Kay-SR2

      Description

      After upgrading from Kotlin 1.2.10 to 1.2.20 I'm getting the error log below. My own class DbConfig (because of TLS connection w/ MongoDB) is derived from org.springframework.data.mongodb.config.AbstractMongoConfiguration, and just inherits mappingMongoConverter() which invokes org.springframework.data.mongodb.config.MongoConfigurationSupport.mongoMappingContext(). I'll attach my own files DbConfig.kt and DbReactiveConfig.kt.

      The error log:

      2018-01-17 13:16:14.518 WARN 16544 — [ restartedMain] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpHandler' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration$AnnotationConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.http.server.reactive.HttpHandler]: Factory method 'httpHandler' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$EnableWebFluxConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration': Unsatisfied dependency expressed through field 'reactiveUserDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customUserDetailsService' defined in file [C:\Users\ziju0001\IdeaProjects\kunde\build\classes\kotlin\main\de\hska\kunde\config\security\CustomUserDetailsService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customUserDetailsRepository': Cannot resolve reference to bean 'reactiveMongoTemplate' while setting bean property 'reactiveMongoOperations'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'reactiveMongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'reactiveMongoTemplate' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingMongoConverter' defined in class path resource [de/hska/kunde/config/DbReactiveConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.convert.MappingMongoConverter]: Factory method 'mappingMongoConverter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext' defined in class path resource [de/hska/kunde/config/DbConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/jvm/internal/impl/load/kotlin/reflect/ReflectKotlinClass

      1. DbConfig.kt
        3 kB
        Juergen Zimmermann
      2. DbReactiveConfig.kt
        9 kB
        Juergen Zimmermann

        Activity

        Hide
        mp911de Mark Paluch added a comment -

        We're using Kotlin internals to determine whether a particular class type is supported or not. In particular, we only support regular classes (no facades/SAM classes/multi-file classes). This check is required as unsupported classes cause exceptions within Kotlin libraries so we're basically guarding all code from Kotlin bugs.

        Kotlin changed its internals and moved around packages.

        Show
        mp911de Mark Paluch added a comment - We're using Kotlin internals to determine whether a particular class type is supported or not. In particular, we only support regular classes (no facades/SAM classes/multi-file classes). This check is required as unsupported classes cause exceptions within Kotlin libraries so we're basically guarding all code from Kotlin bugs. Kotlin changed its internals and moved around packages.
        Hide
        mp911de Mark Paluch added a comment -

        Moved to Spring Data Commons and changed this ticket to a task adopting to Kotlin 1.2.20

        Show
        mp911de Mark Paluch added a comment - Moved to Spring Data Commons and changed this ticket to a task adopting to Kotlin 1.2.20
        Hide
        mp911de Mark Paluch added a comment -

        I pushed a change to the DATACMNS-1245 branch that picks up Kotlin's changes. Care to give 2.1.0.DATACMNS-1245-SNAPSHOT a spin?

        <dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-commons</artifactId>
          <version>2.1.0.DATACMNS-1245-SNAPSHOT</version>
        </dependency>
         
        <repository>
          <id>spring-libs-snapshot</id>
          <name>Spring Snapshot Repository</name>
          <url>http://repo.spring.io/libs-snapshot</url>
        </repository>
        

        Show
        mp911de Mark Paluch added a comment - I pushed a change to the DATACMNS-1245 branch that picks up Kotlin's changes. Care to give 2.1.0. DATACMNS-1245 -SNAPSHOT a spin? < dependency > < groupId >org.springframework.data</ groupId > < artifactId >spring-data-commons</ artifactId > < version >2.1.0.DATACMNS-1245-SNAPSHOT</ version > </ dependency >   < repository > < id >spring-libs-snapshot</ id > < name >Spring Snapshot Repository</ name > < url >http://repo.spring.io/libs-snapshot</ url > </ repository >
        Hide
        juergen.zimmermann Juergen Zimmermann added a comment -

        The issue is gone after I added org.springframework.data:spring-data-commons:2.1.0.DATACMNS-1245-SNAPSHOT in build.gradle.

        Show
        juergen.zimmermann Juergen Zimmermann added a comment - The issue is gone after I added org.springframework.data:spring-data-commons:2.1.0. DATACMNS-1245 -SNAPSHOT in build.gradle.
        Hide
        mp911de Mark Paluch added a comment -

        Changed the pull request to evaluate Kotlin's `@Metadata` annotation after feedback from Jetbrains.

        Show
        mp911de Mark Paluch added a comment - Changed the pull request to evaluate Kotlin's `@Metadata` annotation after feedback from Jetbrains.
        Hide
        juergen.zimmermann Juergen Zimmermann added a comment -

        @mp911de What is the implication after your PR is declined? Can I test something different?

        Show
        juergen.zimmermann Juergen Zimmermann added a comment - @mp911de What is the implication after your PR is declined? Can I test something different?
        Hide
        mp911de Mark Paluch added a comment -

        No worries, the PR isn't declined, the code is merged. GitHub expects the same commit hash in the target branch to consider a pull request merged. We use cherry-picking to bring our commits from a feature branch into master and service-release branches. That said, you can use 2.0.3 and 2.1.0 snapshots that already contain the fix.

        Show
        mp911de Mark Paluch added a comment - No worries, the PR isn't declined, the code is merged . GitHub expects the same commit hash in the target branch to consider a pull request merged. We use cherry-picking to bring our commits from a feature branch into master and service-release branches. That said, you can use 2.0.3 and 2.1.0 snapshots that already contain the fix.

          People

          • Assignee:
            mp911de Mark Paluch
            Reporter:
            juergen.zimmermann Juergen Zimmermann
            Last updater:
            Mark Paluch
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: