tylervz commented on issue #15149:
URL: https://github.com/apache/grails-core/issues/15149#issuecomment-3433579388
I encountered a very similar bug in a Grails 7.0.0 application created using
Grails Forge with the Micronaut HTTP Client additional feature.
The `io.micronaut.http.client.HttpClient.create(@Nullable URL url)` method
threw an exception in my integration test:
```
java.lang.NoClassDefFoundError: io/netty/channel/MultiThreadIoEventLoopGroup
at
io.micronaut.http.client.netty.ConnectionManager.createEventLoopGroup(ConnectionManager.java:277)
at
io.micronaut.http.client.netty.ConnectionManager.<init>(ConnectionManager.java:234)
at
io.micronaut.http.client.netty.DefaultHttpClient.<init>(DefaultHttpClient.java:424)
at
io.micronaut.http.client.netty.DefaultHttpClientBuilder.build(DefaultHttpClientBuilder.java:283)
at
io.micronaut.http.client.netty.NettyHttpClientFactory.createNettyClient(NettyHttpClientFactory.java:141)
at
io.micronaut.http.client.netty.NettyHttpClientFactory.createNettyClient(NettyHttpClientFactory.java:126)
at
io.micronaut.http.client.netty.NettyHttpClientFactory.createClient(NettyHttpClientFactory.java:57)
at io.micronaut.http.client.HttpClient.create(HttpClient.java:251)
at
com.example.HelloControllerIntegrationSpec.$tt__init(HelloControllerIntegrationSpec.groovy:24)
at
com.example.HelloControllerIntegrationSpec.init_closure1(HelloControllerIntegrationSpec.groovy)
at groovy.lang.Closure.call(Closure.java:433)
at groovy.lang.Closure.call(Closure.java:422)
at
grails.gorm.transactions.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:98)
at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at
grails.gorm.transactions.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:95)
at
org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:187)
at
org.spockframework.runtime.model.MethodInfo.lambda$new$0(MethodInfo.java:49)
at
org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at
org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:102)
at
org.grails.testing.spock.RunOnceInterceptor.interceptSetupMethod(RunOnceInterceptor.groovy:36)
at
org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:30)
at
org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:101)
at
org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at
org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:102)
at
org.spockframework.spring.SpringInterceptor.interceptSetupMethod(SpringInterceptor.java:55)
at
org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:30)
at
org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:101)
at
org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at
org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at
org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:156)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException:
io.netty.channel.MultiThreadIoEventLoopGroup
at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
... 32 more
```
This is because Micronaut platform version (4.9.2) expects Netty 4.2.x, but
Spring Boot 3.5.6 (from Grails BOM) forces Netty 4.1.x. And the
`io.netty.channel.MultiThreadIoEventLoopGroup` class was introduced in Netty
4.2.x.
I created a sample application to demonstrate the issue:
https://github.com/tylervz/grails700_micronaut_http_bug
Following the suggestion of an LLM (because I didn't see any messages about
`java.lang.NoClassDefFoundError: io/netty/channel/MultiThreadIoEventLoopGroup`
in the [Grails Slack channel](https://www.linen.dev/s/grails/c/questions)), I
was able to resolve the issue by downgrading the Micronaut platform version,
specified in `gradle.properties`, from 4.9.2 to 4.7.6 which is compatible with
Netty 4.1.x. Micronaut platforms 4.8+ moved to Netty 4.2.x.
I'd like to help fix this bug, my work schedule permitting, but I don't know
where in the Grails code base the `micronautPlatformVersion` value for
`gradle.properties` is defined for `grails-forge-cli create-app` commands that
include the `micronaut-http-client` feature such as this: `grails-forge-cli
create-app --servlet=tomcat --jdk=17 --gorm=hibernate --test=spock
--features=micronaut-http-client com.example.sample`
I'm thinking the `micronautPlatformVersion` should be lowered to 4.7.x and
an integration test should be added to ensure the `micronaut-http-client` runs
properly when upgrades are made to the `micronautPlatformVersion` or the Grails
BOM.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]