jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

authenticationType oauth2 is broken in microservice gateway - jhipster 7.9.2 #19380

Closed joe-bookwood closed 2 years ago

joe-bookwood commented 2 years ago
Overview of the issue

After an update to 7.9.2 and I can't login into my Angular gateway app via Keycloak anymore. Then I change one of the jdl sample apps to my settings and generate a fresh microservice application. I start from src/main/docker the new Keycloak 18.0.0 and the jhipster-registry with docker-compose and then the gateway app with ./mvnw. When I click "sign in" in the yellow box on the main page, I would directed to keycloak. After sign in with admin admin I would redirected to the main page and I see the yellow box again, not as expected the green box. After a second try, I wouldn't redirected to Keycloak anymore.

I tried it also at first with a new generated monolithic app and it works as expected. After login I see the green box on the login page.

When I try to login to Jhipster Registry, the login works as expected, so keycloak work as expected.

Motivation for or Use Case

I can not login to a fresh generated Jhipster Microservice Gateway with oauth2 (also an updated app).

Reproduce the error

Take a microservice jdl with a gateway app and generate a fresh Jhipster app. Start the keykloak and jhipster docker-compose containers and the gateway app - try to sign in, It should be impossible.

Related issues

-

Suggest a Fix

no idea

JHipster Version(s)

7.9.0 to 7.9.2

JHipster configuration

Welcome to JHipster v7.9.2

Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
store@0.0.1-SNAPSHOT /tmp/company/store
└── generator-jhipster@7.9.2
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "gateway",
    "applications": {
      "invoice": {
        "applicationIndex": 1,
        "serverPort": "8081"
      },
      "notification": {
        "applicationIndex": 2,
        "serverPort": "8082"
      }
    },
    "authenticationType": "oauth2",
    "baseName": "store",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "angularX",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1660019205583,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": ["Notification", "Shipment", "Invoice", "OrderItem", "ProductOrder", "Customer", "ProductCategory", "Product"],
    "entitySuffix": "",
    "gradleEnterpriseHost": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.2",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en"],
    "lastLiquibaseTimestamp": 1660019685000,
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageFolder": "com/jhipster/demo/store",
    "packageName": "com.jhipster.demo.store",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8080",
    "serviceDiscoveryType": "eureka",
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipUserManagement": true,
    "testFrameworks": ["protractor"],
    "websocket": false,
    "withAdminUi": true
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Notification {
  date Instant required
  details String
  sentDate Instant required
  format NotificationType required
  userId Long required
  productId Long required
}
entity Shipment {
  trackingCode String
  date Instant required
  details String
}
entity Invoice {
  code String required
  date Instant required
  details String
  status InvoiceStatus required
  paymentMethod PaymentMethod required
  paymentDate Instant required
  paymentAmount BigDecimal required
}
entity OrderItem {
  quantity Integer required min(0)
  totalPrice BigDecimal required min(0)
  status OrderItemStatus required
}
entity ProductOrder {
  placedDate Instant required
  status OrderStatus required
  code String required
  invoiceId Long
}
entity Customer {
  firstName String required
  lastName String required
  gender Gender required
  email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
  phone String required
  addressLine1 String required
  addressLine2 String
  city String required
  country String required
}
entity ProductCategory {
  name String required
  description String
}
/**
 * Product sold by the Online store
 */
entity Product {
  name String required
  description String
  price BigDecimal required min(0)
  size Size required
  image ImageBlob
}
enum NotificationType {
  EMAIL,
  SMS,
  PARCEL
}
enum InvoiceStatus {
  PAID,
  ISSUED,
  CANCELLED
}
enum PaymentMethod {
  CREDIT_CARD,
  CASH_ON_DELIVERY,
  PAYPAL
}
enum OrderItemStatus {
  AVAILABLE,
  OUT_OF_STOCK,
  BACK_ORDER
}
enum OrderStatus {
  COMPLETED,
  PENDING,
  CANCELLED
}
enum Gender {
  MALE,
  FEMALE,
  OTHER
}
enum Size {
  S,
  M,
  L,
  XL,
  XXL
}

relationship OneToOne {
  Customer{user(login) required} to User
}
relationship OneToMany {
  Invoice{shipment} to Shipment{invoice(code) required}
  ProductOrder{orderItem} to OrderItem{order(code) required}
  Customer{order} to ProductOrder{customer(email) required}
  ProductCategory{product} to Product{productCategory(name)}
}
relationship ManyToOne {
  OrderItem{product(name) required} to Product
}

microservice Notification with notification
microservice Shipment, Invoice with invoice
clientRootFolder Notification with notification
clientRootFolder Shipment, Invoice with invoice
paginate Shipment, Invoice, OrderItem, ProductOrder, Customer, Product with pagination
service Shipment, Invoice, OrderItem, ProductOrder, Customer, ProductCategory, Product with serviceClass

Environment and Tools

openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment 11.0.15_p10-r1 (build 11.0.15+10) OpenJDK 64-Bit Server VM 11.0.15_p10-r1 (build 11.0.15+10, mixed mode, sharing)

git version 2.35.1

node: v18.6.0

npm: 8.13.2

Docker version 20.10.12, build e91ed5707e

docker-compose version 1.29.2, build unknown

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete! Sponsored with ❤️ by @oktadev.

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

Gentoo Linux 5.15.41-gentoo-x86_64 #1 SMP Sat May 21 16:19:10 CEST 2022 x86_64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz GenuineIntel GNU/Linux Firefox 91.11.0esr (64-Bit)

mraible commented 2 years ago

I've done this a lot over the last few days and it's worked fine for me. Do you see any errors in your browser's console or your app's logs? Also, do you have a JDL file that can be used to create everything?

joe-bookwood commented 2 years ago

There is no error. I saved the network tab from my developer window in firefox as har file:

localhost_Archive.har.gz

You can view it in text editor or you can import it in firefox to see the network communication.

Here is my modified jdl sample from the example above:

/*
 * This is a microservice e-commerce store sample with Gateway and two microservice applications
 * This uses JHipster registry for service discovery
 */

application {
  config {
    baseName store,
    applicationType gateway,
    packageName com.jhipster.demo.store,
    serviceDiscoveryType eureka,
    authenticationType oauth2,
    prodDatabaseType postgresql,
    buildTool maven,
    clientFramework angularX,
    testFrameworks [protractor]
  }
  entities *
}

application {
  config {
    baseName invoice,
    applicationType microservice,
    packageName com.jhipster.demo.invoice,
    serviceDiscoveryType eureka,
    authenticationType oauth2,
    prodDatabaseType postgresql,
    buildTool maven,
    serverPort 8081,
    skipUserManagement true
  }
  entities Invoice, Shipment
}

application {
  config {
    baseName notification,
    applicationType microservice,
    packageName com.jhipster.demo.notification,
    serviceDiscoveryType eureka,
    authenticationType oauth2,
    databaseType mongodb,
    prodDatabaseType mongodb,
    devDatabaseType mongodb,
    cacheProvider no,
    enableHibernateCache false,
    buildTool maven,
    serverPort 8082,
    skipUserManagement true
  }
  entities Notification
}

/* Entities for Store Gateway */

/** Product sold by the Online store */
entity Product {
    name String required
    description String
    price BigDecimal required min(0)
    size Size required
    image ImageBlob
}

enum Size {
    S, M, L, XL, XXL
}

entity ProductCategory {
    name String required
    description String
}

entity Customer {
    firstName String required
    lastName String required
    gender Gender required
    email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
    phone String required
    addressLine1 String required
    addressLine2 String
    city String required
    country String required
}

enum Gender {
    MALE, FEMALE, OTHER
}

entity ProductOrder {
    placedDate Instant required
    status OrderStatus required
    code String required
    invoiceId Long
}

enum OrderStatus {
    COMPLETED, PENDING, CANCELLED
}

entity OrderItem {
    quantity Integer required min(0)
    totalPrice BigDecimal required min(0)
    status OrderItemStatus required
}

enum OrderItemStatus {
    AVAILABLE, OUT_OF_STOCK, BACK_ORDER
}

relationship OneToOne {
    Customer{user(login) required} to User
}

relationship ManyToOne {
    OrderItem{product(name) required} to Product
}

relationship OneToMany {
   Customer{order} to ProductOrder{customer(email) required},
   ProductOrder{orderItem} to OrderItem{order(code) required} ,
   ProductCategory{product} to Product{productCategory(name)}
}

service Product, ProductCategory, Customer, ProductOrder, OrderItem with serviceClass
paginate Product, Customer, ProductOrder, OrderItem with pagination

/* Entities for Invoice microservice */
entity Invoice {
    code String required
    date Instant required
    details String
    status InvoiceStatus required
    paymentMethod PaymentMethod required
    paymentDate Instant required
    paymentAmount BigDecimal required
}

enum InvoiceStatus {
    PAID, ISSUED, CANCELLED
}

entity Shipment {
    trackingCode String
    date Instant required
    details String
}

enum PaymentMethod {
    CREDIT_CARD, CASH_ON_DELIVERY, PAYPAL
}

relationship OneToMany {
    Invoice{shipment} to Shipment{invoice(code) required}
}

service Invoice, Shipment with serviceClass
paginate Invoice, Shipment with pagination
microservice Invoice, Shipment with invoice

/* Entities for notification microservice */

entity Notification {
    date Instant required
    details String
    sentDate Instant required
    format NotificationType required
    userId Long required
    productId Long required
}

enum NotificationType {
    EMAIL, SMS, PARCEL
}

microservice Notification with notification
mraible commented 2 years ago

I tried creating a new microservices architecture with the JDL above. I started the Docker containers the store app depends on. Then, I tried starting the store with ./mvnw. It fails because of Protractor:

[INFO] [12:53:48] I/config_source - curl -o/Users/mraible/Downloads/19380/store/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
[INFO] [12:53:48] I/downloader - curl -o/Users/mraible/Downloads/19380/store/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
[INFO] node:events:505
[INFO]       throw er; // Unhandled 'error' event
[INFO]       ^
[INFO]
[INFO] Error: read ECONNRESET
[INFO]     at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
[INFO] Emitted 'error' event on Request instance at:
[INFO]     at Request.onRequestError (/Users/mraible/Downloads/19380/store/node_modules/request/request.js:877:8)
[INFO]     at ClientRequest.emit (node:events:539:35)
[INFO]     at TLSSocket.socketErrorListener (node:_http_client:454:9)
[INFO]     at TLSSocket.emit (node:events:527:28)
[INFO]     at emitErrorNT (node:internal/streams/destroy:157:8)
[INFO]     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
[INFO]     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
[INFO]   errno: -54,
[INFO]   code: 'ECONNRESET',
[INFO]   syscall: 'read'
[INFO] }
[INFO] npm ERR! code 1
[INFO] npm ERR! path /Users/mraible/Downloads/19380/store
[INFO] npm ERR! command failed
[INFO] npm ERR! command bash /var/folders/f7/5x4rvsr5599ffnfckn487nzm0000gn/T/postinstall-adb3a464.sh
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     /Users/mraible/.npm/_logs/2022-08-10T18_53_43_314Z-debug-0.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.356 s
[INFO] Finished at: 2022-08-10T12:53:49-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.1:npm (npm install) on project store: Failed to run task: 'npm install' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

I tried npm i to fix it, followed by ./mvnw again. This time, it started up.

I'm able to reproduce your issue. It's quite strange. It seems the /api/account request hangs when everything looks fine on the server.

Client with pending account request:

Screen Shot 2022-08-10 at 12 59 23

Server with the successful account retrieval:

Screen Shot 2022-08-10 at 12 59 06
mraible commented 2 years ago

This appears to be an issue with H2. There's the following error on startup in the store.

java.lang.NoSuchMethodError: org.h2.engine.ConnectionInfo.<init>(Ljava/lang/String;Ljava/util/Properties;Ljava/lang/String;Ljava/lang/Object;)V
    at io.r2dbc.h2.H2ConnectionFactory.getConnectionInfo(H2ConnectionFactory.java:154)
    at io.r2dbc.h2.H2ConnectionFactory.getSessionClient(H2ConnectionFactory.java:117)
    at io.r2dbc.h2.H2ConnectionFactory.lambda$new$0(H2ConnectionFactory.java:53)
    at reactor.core.publisher.MonoSupplier.subscribe(MonoSupplier.java:57)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4397)
    at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onComplete(FluxConcatArray.java:258)
    at reactor.core.publisher.FluxConcatArray.subscribe(FluxConcatArray.java:78)
    at reactor.core.publisher.Flux.subscribe(Flux.java:8466)
    at reactor.core.publisher.Flux.subscribeWith(Flux.java:8639)
    at reactor.core.publisher.Flux.subscribe(Flux.java:8436)
    at reactor.core.publisher.Flux.subscribe(Flux.java:8360)
    at reactor.pool.SimpleDequePool.drainLoop(SimpleDequePool.java:453)
    at reactor.pool.SimpleDequePool.pendingOffer(SimpleDequePool.java:600)
    at reactor.pool.SimpleDequePool.doAcquire(SimpleDequePool.java:296)
    at reactor.pool.AbstractPool$Borrower.request(AbstractPool.java:430)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:110)
    at reactor.pool.SimpleDequePool$QueueBorrowerMono.subscribe(SimpleDequePool.java:720)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.FluxRetry$RetrySubscriber.resubscribe(FluxRetry.java:117)
    at reactor.core.publisher.MonoRetry.subscribeOrReturn(MonoRetry.java:50)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4382)
    at reactor.core.publisher.MonoUsingWhen.subscribe(MonoUsingWhen.java:96)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4397)
    at reactor.core.publisher.Mono.block(Mono.java:1706)
    at org.springframework.cloud.netflix.eureka.EurekaHealthCheckHandler.processContributor(EurekaHealthCheckHandler.java:174)
    at org.springframework.cloud.netflix.eureka.EurekaHealthCheckHandler.getStatus(EurekaHealthCheckHandler.java:151)
    at org.springframework.cloud.netflix.eureka.EurekaHealthCheckHandler.getHealthStatus(EurekaHealthCheckHandler.java:141)
    at org.springframework.cloud.netflix.eureka.EurekaHealthCheckHandler.getStatus(EurekaHealthCheckHandler.java:130)
    at com.netflix.discovery.DiscoveryClient.refreshInstanceInfo(DiscoveryClient.java:1440)
    at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:117)
    at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:101)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

If I try with PostgreSQL, using ./mvnw -Pprod, it works:

Screen Shot 2022-08-10 at 14 59 22

I tried changing the H2 version to 2.1.210 in the pom.xml, but that just results in more errors on startup.

2022-08-10 15:02:18.357 ERROR 56950 --- [   store-task-1] t.j.c.liquibase.AsyncSpringLiquibase     : Liquibase could not start correctly, your database is NOT ready: liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20220810205439_added_entity_constraints_OrderItem.xml::20220810205439-2::jhipster:
     Reason: liquibase.exception.DatabaseException: Referential integrity constraint violation: "FK_ORDER_ITEM__PRODUCT_ID: PUBLIC.ORDER_ITEM FOREIGN KEY(PRODUCT_ID) REFERENCES PUBLIC.PRODUCT(ID)"; SQL statement:
ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id) [23506-210] [Failed SQL: (23506) ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id)]

liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20220810205439_added_entity_constraints_OrderItem.xml::20220810205439-2::jhipster:
     Reason: liquibase.exception.DatabaseException: Referential integrity constraint violation: "FK_ORDER_ITEM__PRODUCT_ID: PUBLIC.ORDER_ITEM FOREIGN KEY(PRODUCT_ID) REFERENCES PUBLIC.PRODUCT(ID)"; SQL statement:
ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id) [23506-210] [Failed SQL: (23506) ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id)]
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:126)
    at liquibase.Liquibase.lambda$null$0(Liquibase.java:265)
    at liquibase.Scope.lambda$child$0(Scope.java:180)
    at liquibase.Scope.child(Scope.java:189)
    at liquibase.Scope.child(Scope.java:179)
    at liquibase.Scope.child(Scope.java:158)
    at liquibase.Scope.child(Scope.java:243)
    at liquibase.Liquibase.lambda$update$1(Liquibase.java:264)
    at liquibase.Scope.lambda$child$0(Scope.java:180)
    at liquibase.Scope.child(Scope.java:189)
    at liquibase.Scope.child(Scope.java:179)
    at liquibase.Scope.child(Scope.java:158)
    at liquibase.Liquibase.runInScope(Liquibase.java:2405)
    at liquibase.Liquibase.update(Liquibase.java:211)
    at liquibase.Liquibase.update(Liquibase.java:197)
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269)
    at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
    at tech.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
    at tech.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:93)
    at tech.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:79)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20220810205439_added_entity_constraints_OrderItem.xml::20220810205439-2::jhipster:
     Reason: liquibase.exception.DatabaseException: Referential integrity constraint violation: "FK_ORDER_ITEM__PRODUCT_ID: PUBLIC.ORDER_ITEM FOREIGN KEY(PRODUCT_ID) REFERENCES PUBLIC.PRODUCT(ID)"; SQL statement:
ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id) [23506-210] [Failed SQL: (23506) ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id)]
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:696)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:56)
    at liquibase.changelog.ChangeLogIterator$2.lambda$null$0(ChangeLogIterator.java:113)
    at liquibase.Scope.lambda$child$0(Scope.java:180)
    at liquibase.Scope.child(Scope.java:189)
    at liquibase.Scope.child(Scope.java:179)
    at liquibase.Scope.child(Scope.java:158)
    at liquibase.changelog.ChangeLogIterator$2.lambda$run$1(ChangeLogIterator.java:112)
    at liquibase.Scope.lambda$child$0(Scope.java:180)
    at liquibase.Scope.child(Scope.java:189)
    at liquibase.Scope.child(Scope.java:179)
    at liquibase.Scope.child(Scope.java:158)
    at liquibase.Scope.child(Scope.java:243)
    at liquibase.changelog.ChangeLogIterator$2.run(ChangeLogIterator.java:93)
    at liquibase.Scope.lambda$child$0(Scope.java:180)
    at liquibase.Scope.child(Scope.java:189)
    at liquibase.Scope.child(Scope.java:179)
    at liquibase.Scope.child(Scope.java:158)
    at liquibase.Scope.child(Scope.java:243)
    at liquibase.Scope.child(Scope.java:247)
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:65)
    ... 23 common frames omitted
Caused by: liquibase.exception.DatabaseException: Referential integrity constraint violation: "FK_ORDER_ITEM__PRODUCT_ID: PUBLIC.ORDER_ITEM FOREIGN KEY(PRODUCT_ID) REFERENCES PUBLIC.PRODUCT(ID)"; SQL statement:
ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id) [23506-210] [Failed SQL: (23506) ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id)]
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:434)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:77)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:160)
    at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1296)
    at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1278)
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:661)
    ... 43 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity constraint violation: "FK_ORDER_ITEM__PRODUCT_ID: PUBLIC.ORDER_ITEM FOREIGN KEY(PRODUCT_ID) REFERENCES PUBLIC.PRODUCT(ID)"; SQL statement:
ALTER TABLE PUBLIC.order_item ADD CONSTRAINT fk_order_item__product_id FOREIGN KEY (product_id) REFERENCES PUBLIC.product (id) [23506-210]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:527)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
    at org.h2.message.DbException.get(DbException.java:227)
    at org.h2.message.DbException.get(DbException.java:203)
    at org.h2.constraint.ConstraintReferential.checkExistingData(ConstraintReferential.java:612)
    at org.h2.command.ddl.AlterTableAddConstraint.tryUpdate(AlterTableAddConstraint.java:287)
    at org.h2.command.ddl.AlterTableAddConstraint.update(AlterTableAddConstraint.java:72)
    at org.h2.command.ddl.AlterTable.update(AlterTable.java:46)
    at org.h2.command.CommandContainer.update(CommandContainer.java:174)
    at org.h2.command.Command.executeUpdate(Command.java:252)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:252)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223)
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94)
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:430)
    ... 48 common frames omitted
mraible commented 2 years ago

I should add that even though there's a Liquibase issue on startup with H2 v2.1.210, fake data does get loaded and authentication works.

Screen Shot 2022-08-10 at 15 03 49

I'll add a bug bounty to get this fixed because I'm not sure of the correct solution.

mshima commented 2 years ago

May be fixed by https://github.com/jhipster/generator-jhipster/pull/19388

joe-bookwood commented 2 years ago

I had also big problems with my real project after the upgrade from 7.8.1 to 7.9.x, because one of my columns where named "value". I had no problems with with H2 v2.1.200 with the "value" named column. So I decided to rename that column after the upgrade. One of the pitfalls - but is a H2 problem, not related to jhipster.

mshima commented 2 years ago

The fix is to revert to h2 v1. It still have problems.

mraible commented 2 years ago

@mshima I can confirm that adding the version to r2dbc-h2 does fix the problem.

<dependency>
    <groupId>io.r2dbc</groupId>
    <artifactId>r2dbc-h2</artifactId>
    <version>${h2-r2dbc.version}</version>
 </dependency>
mraible commented 2 years ago

Fixed by https://github.com/jhipster/generator-jhipster/pull/19388. @mshima Please collect the bounty.

mshima commented 2 years ago

@DanielFran bounty claimed https://opencollective.com/generator-jhipster/expenses/90548

DanielFran commented 2 years ago

@mshima approved