Generator-jhipster: Using h2db in prod profile breaks after upgrade to jhipster 5.1.0

Created on 19 Jul 2018  ·  6Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

Using h2db in prod profile breaks after upgrade to jhipster 5.1.0 (was runable in 4.x)

Error message:


APPLICATION FAILED TO START


Description:

Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:

Property: driverclassname
Value: org.h2.Driver
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class org.h2.Driver in either of HikariConfig class loader or Thread context classloader

Action:

Update your application's configuration

Motivation for or Use Case


I don't really have the need for a db and so using h2db as a file on my prod system was suitable. After upgrading my application from 4.x to 5.1.0 the prod package breaks.

Reproduce the error
  1. generate new jhipster project using h2db in dev and mariadb in prod.
  2. Copy db part from application-dev.yml to application-prod.yml
  3. run ./mvnw -Pprod
datasource:
        type: com.zaxxer.hikari.HikariDataSource
        url: jdbc:h2:file:.target/h2db/db/test;DB_CLOSE_DELAY=-1
        username: ab
        password:c
    h2:
        console:
            enabled: false
    jpa:
        database-platform: io.github.jhipster.domain.util.FixedH2Dialect
        database: H2
        show-sql: true
        properties:
            hibernate.id.new_generator_mappings: true
            hibernate.cache.use_second_level_cache: false
            hibernate.cache.use_query_cache: false
            hibernate.generate_statistics: true
    liquibase:
        contexts: prod
Related issues
Suggest a Fix
JHipster Version(s)
##### **JHipster configuration**

Welcome to the JHipster Information Sub-Generator

##### **JHipster Version(s)**

/Gitlab/test
└── [email protected]

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.biao.bascha"
    },
    "jhipsterVersion": "5.1.0",
    "applicationType": "monolith",
    "baseName": "bascha",
    "packageName": "com.biao.bascha",
    "packageFolder": "com/biao/bascha",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mariadb",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}
</pre>
</details>


##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>

</pre>
</details>


##### **Environment and Tools**

java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

git version 2.14.3

node: v8.11.3

npm: 6.2.0

yeoman: 2.0.1

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


MacOS

  • [ x ] Checking this box is mandatory (this is just to show you read everything)

Most helpful comment

@napindc sure
Just add the driver to the prod profile in your pom.xml

...
<profile>
            <id>prod</id>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-undertow</artifactId>
                </dependency>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                </dependency>
            </dependencies>
....

All 6 comments

We don't support H2 in prod profile, so there's no guarantee this should work from our side.
But yes I already saw this issue, I think the driver was left by mistake in 4.x, and now we remove it in 5.x. That's supposed to be an improvement, as people normally don't need this :-)
You should just put the driver back in your pom.xml.
And of course I don't recommend at all to do this in production!

Thank you mate 👍
put the driver back in and now it works again

Awesome :-)

Can you tell me how you added that driver into the pom.xml file?

@napindc sure
Just add the driver to the prod profile in your pom.xml

...
<profile>
            <id>prod</id>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-undertow</artifactId>
                </dependency>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                </dependency>
            </dependencies>
....

Thanks so much! @Simsal

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abhinav910 picture abhinav910  ·  50Comments

deepu105 picture deepu105  ·  81Comments

deepu105 picture deepu105  ·  53Comments

lordlothar99 picture lordlothar99  ·  76Comments

hdurix picture hdurix  ·  58Comments