Nosuchfielderror Java

NoSuchFieldError Java

This error is typically thrown if you only partially recompile your code. You've got old code that is referencing a field that no longer exists in the recompiled class files.

The solution is to clean out all the class files and compile everything from fresh.

Update: If you still get the same error after recompiling everything, then you're probably compiling against one version of an external library and using another at runtime.

What you need to do now is first identify the class that is causing the problem (it looks like you have done this already) and then run your application with the -verbose:class command line option. It will dump a lot of class loading information on your standard out and you'll be able to find out where the problematic class is exactly loaded from.

How I can resolve exception java.lang.NoSuchFieldError: NOT_ISSUE

It means that the ReportPortalExtension.java source file has a so-called static initializer which is referencing (as in, setting the field, or more likely reading the field) called NOT_ISSUE. As in, there is some code somewhere that e.g. contains:

public static final LocalDate NOT_ISSUE = LocalDate.of(1800, 1, 1);

(It doesn't have to a be a LocalDate, the error doesn't tell you what the type is. All we know is, it can't be a compile time constant, so it's either not a primitive or String type, or it is not being initialized with a constant value), but, the class file of whatever contains that field no longer has it, or doesn't yet have it.

Basically, you've got a version mismatch. That ReportPortalExtension method was written and compiled against a version of whatever contains that field, and you also have that class in your classpath, but a different version that does not have this field.

Class load errors are a bit hard to fully disentangle. It's possible that line 82 of ReportPortalExtension isn't the problem at all, but that this is the first time any code running in the VM touches a class, and that class has the problem. You only get the most detailed error once, so double check your logs for it. Alternatively, just go search-all through your code and find NOT_ISSUE. Then check which class contains this field, and then figure out why you have a version problem there.

java.lang.NoSuchFieldError after changing class

I think the top answer here might help out: NoSuchFieldError Java

But to not depend on a link too much, the general idea is you likely only compiled Foo. As such, Foo's var type does get changed, but Bar's idea of what type var should be does not. So yes, compiled classes do "know" what type of method/variable they're referencing. In this case, Bar still thinks it's looking for a String named var in Foo, but since it can't find one, you're getting this error. Compiling both, I think, should get all your classes on the same page again.

java.lang.NoSuchFieldError: INSTANCE only when running on Tomcat

This problem was caused by an older versions of httpclient-cache on my class path

Apache Spark Scala logging Exception in thread main java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY

By adding a new dependency log4j-api now it works fine with log4j-core version 2.17.2:

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.2</version>
</dependency>

Spring Boot Azure Storage Client yields java.lang.NoSuchFieldError: NOOP_CONFIGURER

Please check below points.

  • NoSuchField, usually means that when linking the target class, the field
    is not there. But when compiling, the class should have that field,
    otherwise the code cann't compile.

i.e; it indicates that an application tries to access or modify an
object’s field, but that field no longer exists.

  • This error can occur during runtime, if the definition of a class
    has incompatibly changed.
  1. The exception as shown is occurring at ChannelPipelineConfigurer in empty configure method which returns NOOP_configurer which is present in reactor netty core under the package reactor.netty

  2. This seems to be caused by version mismatch in reactor-netty jar

ChannelPipelineConfigurer.java

package reactor.netty;

import io.netty.channel.Channel;
import reactor.util.annotation.Nullable;

import java.net.SocketAddress;

import static reactor.netty.ReactorNetty.CompositeChannelPipelineConfigurer.compositeChannelPipelineConfigurer;

@FunctionalInterface
public interface ChannelPipelineConfigurer {
static ChannelPipelineConfigurer emptyConfigurer() {
return ReactorNetty.NOOP_CONFIGURER;
}

So please check if reactor netty core release version incompatibility is the reason or one or more version conflicts occuring & try to upgrade to latest version of the release jar and also check if any incompatible dependencies are present.

To handle/deal with NoSuchFieldError error, try to clean all existing .class files and compile everything from the scratch.so that verify that each referenced class is compiled to its latest version.

However, if the error is still thrown during runtime, then one may have to compile using one version of a library, but use another version at runtime. You must verify that your classpath contains the proper version of the specified library.

  • Reactive Spring Boot - java.lang.NoSuchFieldError:
    DEFAULT_SHUTDOWN_QUIET_PERIOD - Stack Overflow
  • spring-security-{noop}


Related Topics



Leave a reply



Submit