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.47k stars 4.02k forks source link

Can't run integration tests on JHipster v7 #19649

Closed jdbuys closed 2 years ago

jdbuys commented 2 years ago
Overview of the issue

Here's the stacktrace that I get when I run the integration tests. [ERROR] com.mycompany.myapp.CassandraKeyspaceIT Time elapsed: 21.612 s <<< ERROR! java.lang.NoClassDefFoundError: Could not initialize class io.netty.channel.DefaultChannelId at io.netty.channel.AbstractChannel.newId(AbstractChannel.java:113) at io.netty.channel.AbstractChannel.<init>(AbstractChannel.java:73) at io.netty.bootstrap.FailedChannel.<init>(FailedChannel.java:33) at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:320) at io.netty.bootstrap.Bootstrap.doResolveAndConnect(Bootstrap.java:155) at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:139) at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:199) at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:167) at com.datastax.oss.driver.internal.core.channel.ChannelFactory.connect(ChannelFactory.java:148) at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.connect(ControlConnection.java:365) at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.init(ControlConnection.java:303) at com.datastax.oss.driver.internal.core.control.ControlConnection$SingleThreaded.access$1100(ControlConnection.java:243) at com.datastax.oss.driver.internal.core.control.ControlConnection.lambda$init$0(ControlConnection.java:122) at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:106) at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

Motivation for or Use Case

I have an application in jhipster 6.8 but I want to update it but currently it is impossible because I am getting the same issue with all the versions except the latest one which gives a different issue when I run the integration tests. It's a bug because I can't run integration tests and I have tested with all the v7 options.

Reproduce the error

Clean install Ubuntu npm install -g generator-jhipster@7.1.0 Run jhipster, with cassandra as db, and spring with webflux enabled, and an admin UI. ./mvnw clean verify Then the error happens.

Related issues

I have searched but I could not find any similar issues.

JHipster Version(s)

7.1.0

JHipster configuration

`##### JHipster Version(s)

sample@0.0.1-SNAPSHOT /tmp/sample
ā””ā”€ā”€ generator-jhipster@7.1.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "baseName": "sample",
    "jhipsterVersion": "7.1.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": ["gatling", "cucumber"],
    "blueprints": [],
    "otherModules": [],
    "pages": [],
    "creationTimestamp": 1662408308830,
    "serviceDiscoveryType": false,
    "reactive": true,
    "authenticationType": "jwt",
    "packageName": "com.mycompany.myapp",
    "serverPort": "8080",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "databaseType": "cassandra",
    "buildTool": "maven",
    "serverSideOptions": ["enableSwaggerCodegen:true"],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": true,
    "clientFramework": "react",
    "withAdminUi": true,
    "clientTheme": "none",
    "enableTranslation": false,
    "nativeLanguage": "en",
    "packageFolder": "com/mycompany/myapp",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "devDatabaseType": "cassandra",
    "prodDatabaseType": "cassandra",
    "devServerPort": 9060,
    "clientPackageManager": "npm",
    "clientThemeVariant": "",
    "languages": ["en", "fr"]
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

git version 2.30.2

node: v16.15.1

npm: 8.11.0

Docker version 19.03.3, build a872fc2f86

docker-compose version 1.25.0, build unknown`

Browsers and Operating System

Ubuntu 21.04

mraible commented 2 years ago

I tried creating an app using your .yo-rc.json with JHipster 7.9.3 (the latest release). I tested it with mvn verify and everything passes.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  44.512 s
[INFO] Finished at: 2022-09-05T15:36:26-06:00
[INFO] ------------------------------------------------------------------------
Execution time: 45 s.
jdbuys commented 2 years ago

If I run it on the latest version I get the following issue: java.lang.IllegalMonitorStateException at java.base/java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:149) at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1302) at java.base/java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:439) at java.base/java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:465) at java.base/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1053) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

jdbuys commented 2 years ago

I traced the error to io.netty.util.NetUtil where the file /proc/sys/net/core/somaxconn is read, which when it is read then throws a Blocking call! java.io.FileInputStream#readBytes and then I get the java.lang.NoClassDefFoundError: Could not initialize class io.netty.channel.DefaultChannelId exception.

I fixed it by adding builder.allowBlockingCallsInside("io.netty.util.NetUtil", "<clinit>"); to JHipsterBlockHoundIntegration.java.

mraible commented 2 years ago

@jdbuys Can you please create a PR to fix this so we can verify it doesn't break any tests?

jdbuys commented 2 years ago

@mraible I created the PR. In my tests the issue only happened if the DB was Cassandra.

Tcharl commented 2 years ago

Accepted the fix when CI will pass https://github.com/jhipster/generator-jhipster/pull/19661 Thank you very much for it! Reactive Cassandra, what a stack, I hope you'll enjoy ^^

mshima commented 2 years ago

Looks like we don't have cassandra + webflux test in our ci related to https://github.com/jhipster/generator-jhipster/issues/18747.