I was following BAELDUNG download with binary. So I was figuring out,
import static org.springframework.http.HttpHeaders.CONTENT_LENGTH;
It will work with this dependency,
implementation 'org.springframework:spring-webflux:5.1.9.RELEASE'
In the dependencies list, it will not even show the dependency but errors will go away, the problem is that if I run, I will have this error,
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$WebFluxConfig.configureResourceCaching(WebFluxAutoConfiguration.java:212)
The following method did not exist:
org.springframework.web.reactive.config.ResourceHandlerRegistration.setUseLastModified(Z)Lorg/springframework/web/reactive/config/ResourceHandlerRegistration;
The calling method's class, org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$WebFluxConfig, was loaded from the following location:
jar:file:/C:/Users (not exist)
Do I have to download that jar/HttpHeaders manually to work?
Related
https://github.com/ignacy2000/springangularblog.git
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
io.jsonwebtoken.security.Keys.secretKeyFor(Keys.java:136)
The following method did not exist:
io/jsonwebtoken/lang/Classes.invokeStatic(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;
The calling method's class, io.jsonwebtoken.security.Keys, was loaded from the following location:
jar:file:/C:/Users/ignac/.m2/repository/io/jsonwebtoken/jjwt-api/0.11.2/jjwt-api-0.11.2.jar!/io/jsonwebtoken/security/Keys.class
The called method's class, io.jsonwebtoken.lang.Classes, is available from the following locations:
jar:file:/C:/Users/ignac/.m2/repository/io/jsonwebtoken/jjwt/0.2/jjwt-0.2.jar!/io/jsonwebtoken/lang/Classes.class
jar:file:/C:/Users/ignac/.m2/repository/io/jsonwebtoken/jjwt-api/0.11.2/jjwt-api-0.11.2.jar!/io/jsonwebtoken/lang/Classes.class
The called method's class hierarchy was loaded from the following locations:
io.jsonwebtoken.lang.Classes: file:/C:/Users/ignac/.m2/repository/io/jsonwebtoken/jjwt/0.2/jjwt-0.2.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes io.jsonwebtoken.security.Keys and io.jsonwebtoken.lang.Classes
This is the Google Guice calling code:
public static ContainerRunner forInjector(Injector injector) {
return (ContainerRunner)injector.getInstancefaultContainerRunner.class);
}
public static ContainerRunner forModules(Iterable<? extends Module> modules) {
return forInjector(Guice.createInjector(modules));
}
And this the exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.inject.internal.Initializer.requestInjection(Lcom/google/inject/internal/InjectorImpl;Ljava/lang/Object;Lcom/google/inject/Binding;Ljava/lang/Object;Ljava/util/Set;)Lcom/google/inject/internal/Initializable;
at com.google.inject.internal.BindingProcessor$1.visit(BindingProcessor.java:108)
at com.google.inject.internal.BindingProcessor$1.visit(BindingProcessor.java:70)
at com.google.inject.internal.ProviderInstanceBindingImpl.acceptTargetVisitor(ProviderInstanceBindingImpl.java:62)
at com.google.inject.internal.BindingProcessor.visit(BindingProcessor.java:70)
at com.google.inject.internal.BindingProcessor.visit(BindingProcessor.java:43)
at com.google.inject.internal.BindingImpl.acceptVisitor(BindingImpl.java:93)
at com.google.inject.internal.AbstractProcessor.process(AbstractProcessor.java:56)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:186)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.baml.gmt.xasf.container.ContainerRunners.forModules(ContainerRunners.java:39)
My problem is that the message does not tell me which particular method is missing. Is there a good way to debug this? Can this be a Maven transitive dependency issue?
It tells you exactly what method is missing. It's:
package com.google.inject.internal.Initializer
Initializable requestInjection(InjectorImpl, Object, Binding, Object, Set)
Considering that method signature was last changed Five years ago, you almost certainly have some sort of build issue that is making the method not be in your classpath somehow. You haven't given us enough information to be able to debug further.
It turns out that, when I executed in Unix environment, there were permission issue with the files in lib directory. As soon as I changed the permission, it got past this Guice error. This Guice error, from my paste experience, is almost always due to dependency issues, one way or the other. But Guice does not give you a more specific, more descriptive error message.
I'm trying to run a package that has dependencies on several hundred packages and I keep getting the following error:
Caused by: java.lang.NoSuchMethodError: com.company.jacksonion.JoiObjectMapper.setSerializationInclusion(Lorg/codehaus/jackson/map/annotate/JsonSerialize$Inclusion;)Lorg/codehaus/jackson/map/ObjectMapper;
at com.company.raft.utils.IonUtil.createJacksonIonMapper(IonUtil.java:33)
at com.company.raft.utils.IonUtil.<clinit>(IonUtil.java:40)
at com.company.raft.i18n.MarketplaceManager.loadFromFile(MarketplaceManager.java:96)
at com.company.raft.i18n.MarketplaceManager.loadAllConfigs(MarketplaceManager.java:55)
at com.company.raft.env.EnvManager.<init>(EnvManager.java:118)
at com.company.raft.env.EnvManager.instance(EnvManager.java:147)
at com.company.raft.bases.AbstractTestBase.<init>(AbstractTestBase.java:49)
at com.company.product.peekaboo.test.bases.PeekabooTestBase.<init>(PeekabooTestBase.java:38)
at com.company.product.engine.peekaboo.tests.GetAddressOfDeviceTests.<init>(GetAddressOfDeviceTests.java:21)
I didn't write the above packages but according to the internal codebase they are the latest stable changes and when I look at the actual file com.company.raft.utils.IonUtil.createJacksonIonMapper:
JoiObjectMapper mapper = new JoiObjectMapper();
mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
the method setSerializationInclusion is in JoiObjectMapper's superclass' superclass. So why is it unable to find the method?
I have this code:
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
String msg = getString(R.string.common_google_play_services_update_text);
Log.e(TAG, msg);
Dialog errDlg = googleAPI.getErrorDialog(MyActivity.this, result, 1111, listener);
When this runs, the String common_google_play_services_update_text is correctly written to LogCat, but getErrorDialog() throws this Exception:
java.lang.NoSuchFieldError: No static field
common_google_play_services_update_text of type I in class
Lcom/google/android/gms/R$string; or its superclasses (declaration of
'com.google.android.gms.R$string' appears in
/data/app/com.mygame-1/base.apk)
How can I fix this?
The error NoSuchFieldError means that the class doesn't have a field of a specified name. It is thrown if an application tries to access or modify a specified field of an object, and that object no longer has that field. Normally, this error is caught by the compiler and can only occur at run time if the definition of a class has incompatibly changed.
Also, maybe you've got old code that is referencing a field that no longer exists in the recompiled class files. You may check it here.
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.
Hope this helps!
I have the following class signature:
public BlockstemRequester(RateLimiter throttler,
String url, List<String> payloadsToBeRequested, List<String> objRef) {
.
.
.
}
And I'm using that constructor at this following code:
threads.add(new BlockstemRequester(RateLimiter.create(1.0),
String.format("url...", apiKey),
chunks.get(index),
chunksObjRef.get(index)))
where:
RateLimiter is from import com.google.common.util.concurrent.RateLimiter
chunks is defined as val chunks:util.List[util.List[String]] = new util.Vector[util.List[String]]
chunksObjRef is defined as val chunksObjRef:util.List[util.List[String]] = new util.Vector[util.List[String]]
But, unfortunately I'm getting an error telling me that class constructor was not found or defined:
java.lang.NoSuchMethodError: BlockstemRequester.<init>(Lcom/google/common/util/concurrent/RateLimiter;Ljava/lang/String;Ljava/util/List;Ljava/util/List;)
Basically, I'm using this class defined in Scala at my java code project, and I did defined the scala class to use List from java to avoid any problem of incompatible types between the languages.
At runtime I'm getting this following types according to my debug process:
chunks is a Vector[Collections$SynchronizedRandomAccessList]
chunksObjRef is a Vector[Collections$SynchronizedRandomAccessList]
I appreciate any kind of help towards this problem. Thank you!
As per Java docs:
Thrown if an application tries to call a specified method of a class
(either static or instance), and that class no longer has a definition
of that method. Normally, this error is caught by the compiler; this
error can only occur at run time if the definition of a class has
incompatibly changed.
From you question it is not clear if you are getting this at compile time or run time but looks like you are having issue at run time. So, use a Java decompiler and check the .class of this class whether this method is present or not.
Most probable root cause of this issue is that library used at compile time have such a method but library used at runtime doesn't have it, and hence NoSuchMethodError.
Use decompiler and check .class file of the class.
Just solved the problem. So this was the scenario: I have a project X and using a library Y. So both X and Y have different definition of the class BlockstemRequester, both with different constructor signatures. I had to change that class name of my project and refactor my code. So, at runtime the constructor pointed out it was that one from my project X and not from that one defined in the library Y
I appreciate any advise if there is any way to approach this problem better than just renaming/refactoring my local classes
I think that the problem is with your 'typed' list.
If you change the signature to
public BlockstemRequester(RateLimiter throttler,
String url, List payloadsToBeRequested, List objRef)
Or
public BlockstemRequester(RateLimiter throttler,
String url, List<?> payloadsToBeRequested, List<?> objRef)
This will work.