2

I'm trying to build a project that depends on io.netty, and it's the one third-party library that doesn't seem to support Java9+ modules since I don't see any module-info.class inside the jars.

When I come to run my project I get the error: Error occurred during initialization of boot layer java.lang.module.FindException: Module io.netty.buffer not found, required by ...

I have seen elsewhere that this can [in theory] be built using jdeps and an alternative third-party Maven plugin, but my question is that I can't believe I'm the first person to ask if module versions of Netty have been built previously, and if so does anyone know if these pre-built module versions already somewhere out there in the ether.

Also, Java9's modules has been out for a while and why aren't the developers behind Netty supporting modules?

Graham Seed
  • 742
  • 3
  • 10
  • 24

1 Answers1

1

The Netty GitHub repo README says this:

Usage with JDK 9+

Netty can be used in modular JDK9+ applications as a collection of automatic modules. The module names follow the reverse-DNS style, and are derived from subproject names rather than root packages due to historical reasons. They are listed below:

io.netty.all
io.netty.buffer
io.netty.codec
io.netty.codec.dns
io.netty.codec.haproxy
io.netty.codec.http
io.netty.codec.http2
io.netty.codec.memcache
io.netty.codec.mqtt
io.netty.codec.redis
io.netty.codec.smtp
io.netty.codec.socks
io.netty.codec.stomp
io.netty.codec.xml
io.netty.common
io.netty.handler
io.netty.handler.proxy
io.netty.resolver
io.netty.resolver.dns
io.netty.transport
io.netty.transport.epoll (native omitted - reserved keyword in Java)
io.netty.transport.kqueue (native omitted - reserved keyword in Java)
io.netty.transport.unix.common (native omitted - reserved keyword in Java)
io.netty.transport.rxtx
io.netty.transport.sctp
io.netty.transport.udt

Automatic modules do not provide any means to declare dependencies, so you need to list each used module separately in your module-info file.
duffymo
  • 305,152
  • 44
  • 369
  • 561
  • Thanks for your reply. If I add the netty jars to my module-info.java such as "requires io.netty.all", "requires io.netty.buffer" etc then when I run the app I get the error: "Error occurred during initialization of boot layer java.lang.module.FindException: Module io.netty.buffer not found, required by ...". If I comment out the netty requires block then the error goes away and I have to find another way of including the netty jars. – Graham Seed Jul 29 '22 at 13:14
  • I don't know if you use Maven, but it sounds like you need to add the Netty JARs as dependencies in your POM and use the Maven plugin to create an executable JAR with dependencies packaged inside. I would recommend it. – duffymo Jul 29 '22 at 13:24
  • Hi - Yes, I am using Maven and have the Netty depends. What I don't understand is that the module-info.java file requires the netty jars but when I come to run the app it says the netty jars are not modules, which makes sense because they are not. But then others say they should be included as automatics, but it fails. – Graham Seed Jul 29 '22 at 13:31
  • I think I worked it out. My module-info.java includes: "requires io.netty.all" but the Maven Netty jars are called for example "netty-all-4.1.43.Final.jar" and that is what Maven will add to the local repo and if you copy over jars for your packaging. The groupId is "io" and the artefactId "netty-all" but the file name is "netty-all-4.1.43.Final.jar". As soon as I renamed this jar to "io.netty-all-4.1.43.jar" it worked. Presumably, if instead I dropped the "io" from the requires then it would also be able to find it. – Graham Seed Jul 29 '22 at 13:48
  • Great work. Glad you figured out a resolution. – duffymo Jul 29 '22 at 13:52
  • 1
    However, I still think my original question is valid, in that if someone else has built module versions of Netty then it would be good to know. Because when you come to use jlink you get: "Error: automatic module cannot be used with jlink: io.netty.all from file:///.../.m2/repository/io/netty/netty-all/4.1.43.Final/netty-all-4.1.43.Final.jar". Thus, in order to package using jlink we need non-auto versions. – Graham Seed Jul 29 '22 at 16:35
  • @GrahamSeed might be good to send this link as an issue in Netty GitHub. They might respond. – duffymo Jul 29 '22 at 16:36
  • Thanks - did as suggested and just posted an issue request: https://github.com/netty/netty/issues/12658 – Graham Seed Jul 29 '22 at 16:45