java.lang.NoSuchFieldException: producerIndex

I am running into this exception when I run my obfuscated jar.
.jar -conf local/<myconf.json>

14:32:11,944 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]

14:32:11,944 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/Users/rangand/Desktop/Dilip/Testing2/ocular-api-server/dht-tardis-ocular-api/dd/dht-tardis-ocular-api.jar!/logback.xml]

14:32:11,951 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@78e94dcf - URL [jar:file:/Users/rangand/Desktop/Dilip/Testing2/ocular-api-server/dht-tardis-ocular-api/dd/dht-tardis-ocular-api.jar!/logback.xml] is not of type file

14:32:11,988 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set

14:32:11,988 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]

14:32:11,992 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]

14:32:12,010 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.

14:32:12,010 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.

14:32:12,010 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also Logback Error Codes for details

14:32:12,010 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.roche.dht.*] to DEBUG

14:32:12,010 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.roche.dht.*] to false

14:32:12,010 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.roche.dht.*]

14:32:12,011 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR

14:32:12,011 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]

14:32:12,011 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO

14:32:12,011 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]

14:32:12,011 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.

14:32:12,011 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@233fe9b6 - Registering current configuration as safe fallback point

Exception in thread “main” java.lang.ExceptionInInitializerError

at io.netty.util.internal.PlatformDependent$Mpsc.a(SourceFile:982)

at io.netty.util.internal.PlatformDependent.newMpscQueue(SourceFile:993)

at io.netty.channel.nio.NioEventLoop.a(SourceFile:279)

at io.netty.channel.nio.NioEventLoop.a(SourceFile:150)

at io.netty.channel.nio.NioEventLoop.(SourceFile:138)

at io.netty.channel.nio.NioEventLoopGroup.newChild(SourceFile:183)

at io.netty.channel.nio.NioEventLoopGroup.newChild(SourceFile:38)

at io.netty.util.concurrent.MultithreadEventExecutorGroup.(SourceFile:84)

at io.netty.util.concurrent.MultithreadEventExecutorGroup.(SourceFile:60)

at io.netty.util.concurrent.MultithreadEventExecutorGroup.(SourceFile:49)

at io.netty.channel.MultithreadEventLoopGroup.(SourceFile:59)

at io.netty.channel.nio.NioEventLoopGroup.(SourceFile:87)

at io.netty.channel.nio.NioEventLoopGroup.(SourceFile:82)

at io.netty.channel.nio.NioEventLoopGroup.(SourceFile:69)

at io.vertx.core.net.impl.transport.Transport.eventLoopGroup(SourceFile:153)

at io.vertx.core.impl.VertxImpl.(SourceFile:155)

at io.vertx.core.impl.VertxImpl.a(SourceFile:98)

at io.vertx.core.impl.VertxFactoryImpl.vertx(SourceFile:40)

at io.vertx.core.impl.VertxFactoryImpl.vertx(SourceFile:32)

at io.vertx.core.Vertx.vertx(SourceFile:85)

at io.vertx.core.impl.launcher.commands.ClasspathHandler.create(SourceFile:113)

at io.vertx.core.impl.launcher.commands.BareCommand.startVertx(SourceFile:278)

at io.vertx.core.impl.launcher.commands.BareCommand.run(SourceFile:192)

at io.vertx.core.impl.launcher.commands.RunCommand.run(SourceFile:249)

at io.vertx.core.impl.launcher.VertxCommandLauncher.execute(SourceFile:248)

at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(SourceFile:402)

at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(SourceFile:346)

at io.vertx.core.Launcher.main(SourceFile:45)

Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: producerIndex

at io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess.fieldOffset(SourceFile:111)

at io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields.(SourceFile:55)

… 28 more

Caused by: java.lang.NoSuchFieldException: producerIndex

at java.lang.Class.getDeclaredField(Class.java:2070)

at io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess.fieldOffset(SourceFile:107)

… 29 more

Hi @dilipcrangan ,

The reason the field producerIndex cannot be found is that ProGuard either removed it as part of the shrinking step, or the field name is obfuscated while accessed through reflection.

The solution to issues like these is to create a -keep rule preserving the field. The -keep rule needed will look similar to the example below. Please note I’m not aware of what class contains this field nor its type, hence you need to adjust the classpath and type.

-keepclassmembers class com.example.MyClass {
    int producerIndex;
}

Please note ProGuard’s -addconfigurationdebugging option may be able to assist you in setting up configuration rules like these. Please read more on this topic, here.

Best regards,

Jonas