AWS Java SDK Error - java.lang.NoSuchMethodError - java

I've seen this type of error over here for exceptions that are thrown by various classes, though I haven't found the right solution for mine just yet.
I'm trying to get AWS Java SDK work locally so I can write a test application that reads data from a Kinesis stream.
Problem is, when I run the init() static method I encounter the following error:
Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.http.impl.conn.DefaultClientConnectionOperator.<init>
(Lorg/apache/http/conn/scheme/SchemeRegistry;Lorg/apache/http/conn/DnsResolver;)V
Now, this is not the first error I've been thrown. I've been thrown four or five exceptions prior to this one, and the solution to all of them was just importing some jar's into the project. e.g.:
apache-httpcomponents-httpclient.jar
com.fasterxml.jackson.databind.jar
commons-codec-1.9.jar / commons-codec-1.9-javadoc.jar / commons-codec-1.9-sources.jar
httpclient-4.2.jar
httpcore-4.0.1.jar
I've seen in other threads around here that it could be the version of the httpcore library, however I imported the latest one.
Any ideas how I can resolve this? I'm thinking about starting over, as my project seems to be a heap of imports I'm not sure I'll actually utilize. Furthermore, I can't debug the binary imports of the AWS SDK (or can't I?).
Cheers.

Problem solved, I gradually added the missing libraries to the project and when the apache httpclient jar should be version 4.0 or later, and without any previous version to contradict.
I imported httpclient-4.2.jar and it worked.
Other than that, I just solved the exception that followed by importing joda-time-2.4.jar and it's all up and running.

Related

Exception in thread "main" java.lang.NoSuchMethodError: 'boolean com.google.api.client.http.HttpTransport.isMtls()'

I need help with CalendarQuickstart for java. I have followed the java quickstart steps except using gradle as we won't be using it.
When, I run the file it gives the following error:
Exception in thread "main" java.lang.NoSuchMethodError: 'boolean com.google.api.client.http.HttpTransport.isMtls()'
at com.google.api.services.calendar.Calendar$Builder.chooseEndpoint(Calendar.java:6974)
at com.google.api.services.calendar.Calendar$Builder.<init>(Calendar.java:7007)
at calendarquickstart.CalendarQuickstart.main(CalendarQuickstart.java:71)
C:\Users\User\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\User\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:94: Java returned: 1
BUILD FAILED (total time: 2 seconds)
My line 71:
Calendar service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
.setApplicationName(APPLICATION_NAME)
.build();
Java Quickstart steps and source code: link
The libraries I've imported:
I'm using Netbeans 12.4 and Java JDK 16. The program runs on the other laptop without error. I also tried to look for answer online, they said something about changing POM.xml file but I could not find it anywhere. The java project was created with Ant not gradle or maven. Hope this info helps, and thank you for helping me as I've been stuck for hours with this error.
You have imported many libraries in different versions.
When you do that and assuming the different versions of a library define the same package/classes names, only one will be loaded and there's no guarantee of which one.
This often create a mess as for instance a method added on later version of the library will not be available if a former version has been loaded first.
Bottom line: remove all libraries duplicate, keep only one version of each library (probably the latest but that might depends what each other library is depending on, that why dependency management tool exists by the way..).
Edit: on your case the issue is likely because of the 3 google-http-client libraries you have imported.

Which java class issues warning on catalina.out

I' am currently debugging why a legacy Maven web application compiled in Java 1.8 that we deploy on a Tomcat 8.5 is sending all the time following message:
Warning: Could not get charToByteConverterClass!
Curiously enough, when launching it on my local Tomcat instance, I see the warning in the console, but not in the catalina.out file.
My guess so far is that this is caused by some dependency, as we have no such warning inside our code.
The problem is that we have very old dependencies and also lot of them, so before getting into trying to upgrade them I would like to know if there is any way to:
see the printing "call stack".
or at least see which class is printing that.
Things I have tried so far:
Setting application log level to info.
Setting Tomcat's logging level to All.
You need to upgrade xalan due to a fixed issue since 2.7 release:
issue is now resolved as being fixed in the Xalan-J 2.7 release. As the issue reporter please confirm the code no longer has this problem so that we can close this issue down.
Actually the code that had the problem is totally gone, haha! Through XALANJ-2087 the dependancy on CharToByteConverter was removed plus a number of bugs were fixed due to an incorrect algorithm.
If anyone encounters this problem. xalan 2.7 did not eliminate the message. Adding the following stub class to your build will silence the error message:
package sun.io;
public class CharToByteConverter {
public static CharToByteConverter getConverter(String encoding) {
return new CharToByteConverter();
}
}

Error parsing emitter LibGDX ParticleEffects

I am using LibGDX 1.9.8 and attempting to add ParticleEffects made with the ParticleEditor.
I try to load a new effect with:
torchFX.load(Gdx.files.internal("effects/torch.p"), Gdx.files.internal("effects"));
But I am getting the below error
Exception in thread "LWJGL Application" java.lang.RuntimeException: Error parsing emitter: torch
at com.badlogic.gdx.graphics.g2d.ParticleEmitter.load(ParticleEmitter.java:1160)
at com.badlogic.gdx.graphics.g2d.ParticleEmitter.<init>(ParticleEmitter.java:103)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.newEmitter(ParticleEffect.java:227)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.loadEmitters(ParticleEffect.java:173)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.load(ParticleEffect.java:153)
at com.bbg.dc.AssetLoader.getTorchFX(AssetLoader.java:92)
at com.bbg.dc.scenes.GameScene.setupMap(GameScene.java:202)
at com.bbg.dc.scenes.GameScene.switchMap(GameScene.java:159)
at com.bbg.dc.scenes.GameScene.start(GameScene.java:139)
at com.bbg.dc.DCGame.changeScene(DCGame.java:160)
at com.bbg.dc.scenes.MainMenu.buttonPressed(MainMenu.java:33)
at com.bbg.dc.iface.Button.update(Button.java:98)
at com.bbg.dc.iface.Scene.update(Scene.java:180)
at com.bbg.dc.scenes.MainMenu.update(MainMenu.java:49)
at com.bbg.dc.DCGame.render(DCGame.java:129)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:225)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)
Caused by: java.lang.IllegalArgumentException: No enum constant com.badlogic.gdx.graphics.g2d.ParticleEmitter.SpawnShape.false
at java.lang.Enum.valueOf(Enum.java:238)
at com.badlogic.gdx.graphics.g2d.ParticleEmitter$SpawnShape.valueOf(ParticleEmitter.java:1637)
at com.badlogic.gdx.graphics.g2d.ParticleEmitter$SpawnShapeValue.load(ParticleEmitter.java:1622)
at com.badlogic.gdx.graphics.g2d.ParticleEmitter.load(ParticleEmitter.java:1107)
... 16 more
I have already made sure to have the particle.png in the effects directory. I have tried it with my own custom particle effect as well as the ParticleEditor default. I have tried altering the SpawnShape to no avail. I have been coming to SO for answers for years and this is the first problem I couldn't solve by searching. I have also just updated all my jars to latest 1.9.8 and latest version of ParticleEditor. Any ideas?
I solved this by running ParticleEditor from the same gdx-tools.jar as my project uses. I assumed the runnable jar in the runnables folder in the libgdx repo was identical, but it is not. You must use the same tools.jar for both.
I had a very similar issue, looking at an older file which worked and a newer file I noticed there were a number of entries in the newer one which was not present in the working file.
Namely the line;
independent: false
Deleting all instances on this seemed to do the trick for me.
I assume it's an updated feature not present in the current stable version of libgdx (1.9.8 at the time of writing). It may be available in the nightly version.
Looks like a property that's been added to the tweens on each individual property.
It would be useful if the older builds of the tools were more easily accessible.

NoSuchMethodError with Camel RouteDefinition class

I am trying to debug a Java / Maven project with a lot of depencies on various libraries.
When I run it on a Linux server the program starts up fine, but when I try to run it in Eclipse it throws the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.camel.model.RouteDefinition.getErrorHandlerBuilder()Lorg/apache/camel/ErrorHandlerFactory;
at org.apache.camel.spring.spi.SpringTransactionPolicy.wrap(SpringTransactionPolicy.java:69)
at org.apache.camel.model.PolicyDefinition.createProcessor(PolicyDefinition.java:133)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:437)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:183)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:817)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:697)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1654)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1441)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1338)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1316)
Now, I can see that the RouteDefinition class is in the camel-core-2.9.3,jar and I can see that this library is imported. So how come it doesn't see that method?
How do I go about debugging this?
Could I get info from the process running on the Linux server? For example can I get the list of Jars that are imported and the order in which they are imported?
Many thanks!
The error that you're getting is caused by Maven pulling in the wrong version. Try deleting all versions out of your local repo, add it explicitly to your pom, clean out all of your builds, pray to the eclipse gods, etc. If it still gives you the error, check your local repo to see which wrong versions it pulled in, figure out what depends on them, and add explicit ignores for them while keeping the explicit include.

NO java.lang.NoClassDefFoundError error in Eclipse

I have a project in eclipse which was working fine untile a few minutes ago. I added a JDBC driver ad tried to run it, now even previous runnable file are giving me
Exception in thread "main" java.lang.NoClassDefFoundError: sample
Does anyone have any idea why it is happening does it have anything to do with the jar?
I have even removed the jar.
Try following, one by one
If you are using libraries, check whether everything is included to the project properly.
Rebuild the project
'worked few minutes ago' means it used to work. Did you add any new code? Then the error is there, check whether those codes call other classes, and whether they are available
Restart IDE
Once I used the following to solve the same issue
http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-in.html
If all above failed, that may be due to crash in JVM. I have experienced that as well.

Categories