1

I am generating entities using JHipster JDL.

INFO! Using JHipster version installed locally in current project's node_modules 6.10.1

JDL used to generate entities

entity Products{
    name String required
    brand String required
    quantity String required
    messurement String
    description String
}

entity ProductTypes{
    productType String required
    description String
}

relationship ManyToOne{
    Products{productType} to ProductTypes
}

// Set pagination options
paginate all with pagination

// Use Data Transfert Objects (DTO)
dto * with mapstruct

// Set service options to all except few
service all with serviceImpl

// Set an angular suffix
// angularSuffix * with mySuffix

Used below command to run JDL and ran successfully without any errors

$jhipster import-jdl jdl/jhipster-jdl.jdl

Output Summary:

 DONE  Compiled successfully in 23047ms                                              4:15:42 PM

   489 modules
INFO! Congratulations, JHipster execution is complete!

Now when try to start application, getting below error

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster   :: Running Spring Boot 2.2.7.RELEASE ::
:: https://www.jhipster.tech ::

2020-10-24 16:17:09.493  WARN 17105 --- [  restartedMain] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 5001 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).

***

2020-10-24 16:17:17.546 DEBUG 17105 --- [  restartedMain] c.m.l.config.LiquibaseConfiguration      : Configuring Liquibase
2020-10-24 16:17:17.551  WARN 17105 --- [lication-task-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Starting Liquibase asynchronously, your database might not be ready at startup!
2020-10-24 16:17:18.891 DEBUG 17105 --- [  restartedMain] c.m.l.security.jwt.TokenProvider         : Using a Base64-encoded JWT secret key
2020-10-24 16:17:20.312 ERROR 17105 --- [lication-task-1] liquibase.changelog.ChangeSet            : Change Set config/liquibase/changelog/20201008101647_added_entity_constraints_Products.xml::20201008101647-2::jhipster failed.  Error: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]
2020-10-24 16:17:20.320 ERROR 17105 --- [lication-task-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Liquibase could not start correctly, your database is NOT ready: Migration failed for change set config/liquibase/changelog/20201008101647_added_entity_constraints_Products.xml::20201008101647-2::jhipster:
     Reason: liquibase.exception.DatabaseException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]

liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20201008101647_added_entity_constraints_Products.xml::20201008101647-2::jhipster:
     Reason: liquibase.exception.DatabaseException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:646)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:83)
    at liquibase.Liquibase.update(Liquibase.java:202)
    at liquibase.Liquibase.update(Liquibase.java:179)
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:366)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:314)
    at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
    at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
    at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:93)
    at io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:78)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: liquibase.exception.DatabaseException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200] [Failed SQL: (42122) ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id)]
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:402)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:59)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:131)
    at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1276)
    at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1258)
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:609)
    ... 13 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "PRODUCT_TYPE_ID" not found; SQL statement:
ALTER TABLE PUBLIC.products ADD CONSTRAINT fk_products_product_type_id FOREIGN KEY (product_type_id) REFERENCES PUBLIC.product_types (id) [42122-200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
    at org.h2.message.DbException.get(DbException.java:205)
    at org.h2.message.DbException.get(DbException.java:181)
    at org.h2.table.Table.getColumn(Table.java:703)
    at org.h2.table.IndexColumn.mapColumns(IndexColumn.java:115)
    at org.h2.command.ddl.AlterTableAddConstraint.tryUpdate(AlterTableAddConstraint.java:216)
    at org.h2.command.ddl.AlterTableAddConstraint.update(AlterTableAddConstraint.java:78)
    at org.h2.command.CommandContainer.update(CommandContainer.java:198)
    at org.h2.command.Command.executeUpdate(Command.java:251)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:398)
    ... 18 common frames omitted

2020-10-24 16:17:20.750 DEBUG 17105 --- [  restartedMain] c.m.l.config.DatabaseConfiguration       : H2 database is available on port 18080
2020-10-24 16:17:31.364 DEBUG 17105 --- [  restartedMain] i.g.j.c.apidoc.SwaggerAutoConfiguration  : Starting Swagger
2020-10-24 16:17:31.372 DEBUG 17105 --- [  restartedMain] i.g.j.c.apidoc.SwaggerAutoConfiguration  : Started Swagger in 7 ms
2020-10-24 16:17:37.031  INFO 17105 --- [  restartedMain] com.mv.localshops.BaseapplicationApp     : Started BaseapplicationApp in 43.019 seconds (JVM running for 43.521)
2020-10-24 16:17:42.040  INFO 17105 --- [  restartedMain] com.mv.localshops.BaseapplicationApp     : 
----------------------------------------------------------
    Application 'baseapplication' is running! Access URLs:
    Local:      http://localhost:8080/
    External:   http://192.168.1.11:8080/
    Profile(s):     [dev, swagger]
----------------------------------------------------------

Can you please help me to understand why this error is thrown. Am I using JHipster entity generator in correct way?

Any help is appreciated.

Mahesh Vemula
  • 145
  • 2
  • 14
  • I tried to reproduce but it worked fine for me using JHipster 6.10.4. Please try upgrading to latest version. Start a new project in an empty directory so that you don't get old version from local node_modules – Gaël Marziou Oct 24 '20 at 13:12
  • @GaëlMarziou Instead of starting new project, can I upgrade existing? – Mahesh Vemula Oct 25 '20 at 05:24
  • 1
    Yes you can but your project seemed to be only at the beginning, so it was simpler and also the idea was just to confirm that it works for you also in 6.10.4. You can follow the doc: https://www.jhipster.tech/upgrading-an-application/ – Gaël Marziou Oct 25 '20 at 11:01
  • Upgrade failing with error : ERROR! Something went wrong while installing generator-jhipster! npm ERR! code EINVALIDPACKAGENAME npm ERR! Invalid package name "__ngcc_entry_points__.json": name cannot start with an underscore – Mahesh Vemula Oct 26 '20 at 07:35
  • error in above comment got resolved after using commands: `rm -rf node_modules` `npm install ` – Mahesh Vemula Oct 26 '20 at 08:08
  • @GaëlMarziou, quick question. What is - Unify blueprints configurations? – Mahesh Vemula Oct 26 '20 at 08:26
  • It's a badly explained upgrade step that read all blueprint configuration and unify into generator-jhipster namespace, so basically just an internal change in configuration format. It should be better worded for sure. – Gaël Marziou Oct 26 '20 at 08:46

1 Answers1

0

Issue got resolved after upgrading JHipster from 6.10.1 to 6.10.4

Used below command for upgrade and worked like charm

jhipster upgrade

Two things I followed:

  1. I had to delete and reinstall node module using
rm -rf node_modules 
npm install
  1. While upgrade it asked one question below. I just clicked entered and it took default option I guess
git rev-parse -q --abbrev-ref HEAD
master
? Unify blueprints configurations?

git rev-parse -q --abbrev-ref HEAD
master
? Unify blueprints configurations? Yes
     info Skipping config upgrade, config generated with jhipster version: 6.10.1
git rev-parse -q --verify jhipster_upgrade
git checkout --orphan jhipster_upgrade
Switched to a new branch 'jhipster_upgrade'
✔ Created branch jhipster_upgrade
Mahesh Vemula
  • 145
  • 2
  • 14