Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass the switch --skip-kotlin-format with jhipster 7.0.1 #279

Closed
dnatag opened this issue Apr 24, 2021 · 10 comments · Fixed by #280
Closed

How to pass the switch --skip-kotlin-format with jhipster 7.0.1 #279

dnatag opened this issue Apr 24, 2021 · 10 comments · Fixed by #280

Comments

@dnatag
Copy link

dnatag commented Apr 24, 2021

Overview of the issue

khipster crashed with --skip-kotlin-format switch

Motivation for or Use Case

Reproduce the error

❯ khipster --skip-kotlin-format
INFO! Using JHipster version installed globally
INFO! No custom sharedOptions found within blueprint: generator-jhipster-kotlin at /.../node_modules/generator-jhipster-kotlin
INFO! No custom commands found within blueprint: generator-jhipster-kotlin at /.../node_modules/generator-jhipster-kotlin
error: unknown option '--skip-kotlin-format'

❯ khipster --version
INFO! Using JHipster version installed globally
INFO! No custom sharedOptions found within blueprint: generator-jhipster-kotlin at /.../node_modules/generator-jhipster-kotlin
INFO! No custom commands found within blueprint: generator-jhipster-kotlin at /.../node_modules/generator-jhipster-kotlin
7.0.1

Related issues

Link to PR (if any)

KHipster Version(s): 1.12.0

  • [] Checking this box is mandatory (this is just to show you read everything)
@sendilkumarn
Copy link
Member

It looks like the generator falls back to main JHipster generator, can you try uninstalling the JHipster before trying it?

@dnatag
Copy link
Author

dnatag commented Apr 25, 2021

Same.

❯ npm list -g --depth 0
/.../v14.16.1/installation/lib
├── generator-jhipster-kotlin@1.12.0
├── npm@6.14.12
└── yo@4.0.0

❯ khipster --skip-kotlin-format
INFO! Using JHipster version installed globally
INFO! No custom sharedOptions found within blueprint: generator-jhipster-kotlin at /.../v14.16.1/installation/lib/node_modules/generator-jhipster-kotlin
INFO! No custom commands found within blueprint: generator-jhipster-kotlin at /.../v14.16.1/installation/lib/node_modules/generator-jhipster-kotlin
error: unknown option '--skip-kotlin-format'

@mraible
Copy link
Contributor

mraible commented Apr 27, 2021

I tried the latest release for the first time today. I tried using the following to generate a microservices architecture.

khipster jdl reactive-ms

I did see the following during the generation process.

> Task :ktlintMainSourceSetFormat
/Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/repository/AuthorityRepository.kt:11:9: Not a valid Kotlin file (11:9 expecting member declaration) (cannot be auto-corrected)
"plain" report written to /Users/mraible/kotlin-reactive/blog/build/reports/ktlint/ktlintMainSourceSetFormat/ktlintMainSourceSetFormat.txt

> Task :ktlintMainSourceSetFormat FAILED
> Task :ktlintTestSourceSetFormatte-fns: sill extract date-fns@^1.27.2 extracted to /Users/mraible/kotlin-reactive/gate

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ktlintMainSourceSetFormat'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.KtLintWorkAction
   > Process 'command '/Users/mraible/.sdkman/candidates/java/11.0.8.hs-adpt/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings
2 actionable tasks: 2 executed

BUILD FAILED in 45s
WARNING! Something went wrong while running ktlint formatter...ipt@4.2.3 extracted to /Users/mraible/kotlin-reactive/ga
WARNING! The generated application could not be committed to Git, as a Git repository could not be initialized.lin-reac

I do have JHipster 7.0.1 installed.

If I cd into the gateway directory and run ./gradlew, it starts. The blog app does not.

> Task :ktlintMainSourceSetFormat FAILED
/Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/repository/AuthorityRepository.kt:11:9: Not a valid Kotlin file (11:9 expecting member declaration) (cannot be auto-corrected)
"plain" report written to /Users/mraible/kotlin-reactive/blog/build/reports/ktlint/ktlintMainSourceSetFormat/ktlintMainSourceSetFormat.txt

The code in this file is:

package com.okta.developer.blog.repository

import com.okta.developer.blog.domain.Authority
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository
import reactor.core.publisher.Flux
/**
* Spring Data Neo4j repository for the {@link Authority} entity.
*/

interface AuthorityRepository : ReactiveNeo4jRepository<Authority, String> {
        <Authority> findAll(): Flux
}

For store, it fails to start too:

> Task :compileKotlin FAILED
e: /Users/mraible/kotlin-reactive/store/src/main/kotlin/com/okta/developer/store/config/SecurityConfiguration.kt: (115, 25): Unresolved reference: extractAuthorityFromClaims

@mraible
Copy link
Contributor

mraible commented Apr 27, 2021

If I try to log in to the gateway app, it fails too:

2021-04-27 16:30:59.424 DEBUG 16985 --- [ctor-http-nio-9] c.o.d.gateway.service.UserService        : Exit: getUserFromAuthentication() with result = MonoFlatMap
2021-04-27 16:30:59.430 ERROR 16985 --- [ctor-http-nio-9] o.z.problem.spring.common.AdviceTraits   : Internal Server Error

org.springframework.dao.TransientDataAccessResourceException: Failed to update table [jhi_user]. Row with Id [4c973896-5761-41fc-8217-07c5d13a004b] does not exist.
        at org.springframework.data.r2dbc.core.R2dbcEntityTemplate.lambda$doUpdate$14(R2dbcEntityTemplate.java:706)
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
        |_ checkpoint ⇢ Handler com.okta.developer.gateway.web.rest.AccountResource#getAccount(Principal) [DispatcherHandler]
Stack trace:
                at org.springframework.data.r2dbc.core.R2dbcEntityTemplate.lambda$doUpdate$14(R2dbcEntityTemplate.java:706)

I just tested 7.0.1 with my reactive microservices post and everything works. I'm updating the post now and was hoping to change the Kotlin section to reference the KHipster 1.12.0 release. Maybe that's not a good idea?

@mraible
Copy link
Contributor

mraible commented Apr 28, 2021

The SecurityConfiguration is missing an import. Adding the following fixes it.

import com.okta.developer.store.security.extractAuthorityFromClaims

To fix AuthorityRepository, I changed it to:

interface AuthorityRepository : ReactiveNeo4jRepository<Authority, String> {
    override fun findAll(): Flux<Authority>
}

Then, I got a bunch of additional errors:

e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/domain/Post.kt: (50, 5): This annotation is not repeatable
e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/domain/Tag.kt: (33, 5): This annotation is not repeatable
e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/domain/User.kt: (55, 28): Unresolved reference: createdBy
e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/domain/User.kt: (55, 39): Unresolved reference: createdDate
e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/domain/User.kt: (55, 52): Unresolved reference: lastModifiedBy
e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/domain/User.kt: (55, 68): Unresolved reference: lastModifiedDate
e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/repository/AuthorityRepository.kt: (11, 9): 'findAll' hides member of supertype 'ReactiveNeo4jRepository' and needs 'override' modifier
e: /Users/mraible/kotlin-reactive/blog/src/main/kotlin/com/okta/developer/blog/repository/UserRepository.kt: (18, 9): 'findAll' hides member of supertype 'ReactiveNeo4jRepository' and needs 'override' modifier

The repeatable are about code that looks like:

    @Relationship("HAS_TAG")
    @JsonIgnoreProperties(
        value = [
            "posts"
        ],
        allowSetters = true
    )
    @Relationship("HAS_TAG")
    var tags: MutableSet<Tag>? = mutableSetOf(),

@mraible
Copy link
Contributor

mraible commented Apr 28, 2021

I added a $300 bug bounty in hopes of getting reactive microservices fixed so khipster jdl reactive-ms compiles, runs, and e2e tests pass.

@sendilkumarn
Copy link
Member

sendilkumarn commented Apr 28, 2021

@dnatag interesting I will check this (might be due to recent blueprint changes in the generator).

I tried the reactive blog, but did not try this one. I will take a look this weekend. Thanks @mraible for the detailed issue.

meanwhile if someone is interested please feel free to comment here 👍🏽

@sendilkumarn
Copy link
Member

Fixed all the generator issues, so the code now compiles and run.

But there is one more issue, after authenticating, when we try to create an User, the application throws the following error

 org.springframework.dao.TransientDataAccessResourceException: Failed to update table [jhi_user]. Row with Id [4c973896-5761-41fc-8217-07c5d13a004b] does not exist.
gateway_1             |         at org.springframework.data.r2dbc.core.R2dbcEntityTemplate.lambda$doUpdate$14(R2dbcEntityTemplate.java:706)
gateway_1             |         Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
gateway_1             | Error has been observed at the following site(s):
gateway_1             |         |_ checkpoint ⇢ Handler com.okta.developer.gateway.web.rest.AccountResource#getAccount(Principal) [DispatcherHandler]

It looks like a spring-r2dbc issue, we are trying to save an entity with id. Spring R2DBC automatically tries to update the entity and thus fails. @mraible Does the main generator work?

@mraible
Copy link
Contributor

mraible commented May 1, 2021

Yes. The main generator works. I haven't seen this issue there.

@sendilkumarn
Copy link
Member

Found the issue. Fixed it 👍🏽 It should be working now. I will cut a new release today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants