BodyEditorLoader.jar gives NoSuchMethodError - java

I was just starting to use the BodyEditorLoader.jar library but i got a NoSuchMethodError without any reason. Then i googled it and found a post on stackoverflow which wasn't useful and links were also broken but i came to know that the official library out there is buggy.
How do i fix this? Could not found the updated version of the library. Also some people provided the updated java file but how do i make it a library file as the library file contains the .class file and not the .java file.
Anyways here is the error:
java.lang.NoSuchMethodError: com.badlogic.gdx.utils.JsonReader.parse
and here is the code that gives the error:
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));

From question it's seems you have some buggy BodyEditorLoader class, you can inject gdx-utils jar inside your core module and after that you can access BodyEditorLoader class inside your project, May be it solve your problem.
dependencies {
compile group: 'com.github.itsabhiaryan', name: 'gdx-utils', version: '1.0.1-SNAPSHOT'
}
Don't forget to refresh all of your gradle module.

Related

Scala module requiring specific version of data bind for Spark

I am having issues trying to get Spark to load, read and query a parquet file. The infrastructure seems to be set up (Spark standalone 3.0) and can be seen and will pick up jobs.
The issue I am having is when this line is called
Dataset<Row> parquetFileDF = sparkSession.read().parquet(parquePath);
the following error is thrown
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.10.0 requires Jackson Databind version >= 2.10.0 and < 2.11.0
at com.fasterxml.jackson.module.scala.JacksonModule.setupModule(JacksonModule.scala:61)
I looked into JacksonModule.setupModule and when it gets to context.getMapperVersion the version that is being passed is 2.9.10. It appears to me that the DefaultScalaModule is pulling some older version.
I'm using Gradle to build and have the dependencies set up as such
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.0'
implementation 'org.apache.spark:spark-core_2.12:3.0.0'
implementation 'org.apache.spark:spark-sql_2.12:3.0.0'
implementation 'org.apache.spark:spark-launcher_2.12:3.0.0'
implementation 'org.apache.spark:spark-catalyst_2.12:3.0.0'
implementation 'org.apache.spark:spark-streaming_2.12:3.0.0'
That didn't work, so I tried forcing databind
implementation ('com.fasterxml.jackson.core:jackson-databind') {
version {
strictly '2.10.0'
}
}
I've tried a few different versions and still keep hitting this issue. Maybe I'm missing something super simple, but right now, I can't seem to get past this error.
Any help would be appreciated.
I was able to figure out the issue. I was pulling in jar file from another project. The functionality in the jar file wasn't being used at all, so it wasn't suspect. Unfortunately, that project hadn't been updated and there were some older Spark libraries that were some how being picked up by my current running app. Once I removed that, the error went away. What's interesting is the dependency graph didn't show anything about the libraries the other jar file was using.
I suppose if you run into a similar issue, double check any jar files being imported.

How to choose which library to use in a class (maven)?

I'm started working on an already existing project. In this project there is some JSON-parsing happening with the following exception being thrown by several methods:
JSONException.class
While I was unit-testing these parsers I couldn't import the right org.json.JSONException library.
The maven library used in the codebase was (package org.json.JSONException):
org.json:json:20160810
And the one that was importing in my tests was (package org.json.JSONException):
com.vaadin.external.google:android-json:0.0.20131108.vaadin1
I think the problem lies in both libraries share the same package names. When the test is execute the JSONException is thrown but the test still fails because its probably the other library. Anybody knows why this problem is happening and how to solve it?
Thanks in advance!
I believe you need to updated your pom.xml file and in the dependency section you can exclude a 3rd party dependency from a declared dependency. I guess in your case there is a dependency to json and vaadin, you'll find vaadin is also pulling the different version of json.
You can try removing one of them. As suggested here:
https://github.com/spring-cloud/spring-cloud-deployer-kubernetes/issues/142

Importing missing package (sun.security.pkcs.PKCS10) automatically in Android Studio

I have to use PKCS10 class into my project. I tried to import sun.security.pkcs.PKCS10; into my activity code but studio shows "Cannot resolve symbol PKCS10" at both places where I have imported it and where I want to instantiat it.
Note: I haven't added any dependency or library (like .jar) to my project.
I want to know whether can it be automatically?
The class sun.security.pkcs10.PKCS10 was removed from the JDK. Using a class that was internal and already removed from the JDK is going a step beyond just using an internal API.
Put this into your build.gradle file.
compileJava {
options.forkOptions.javaHome = file(System.properties['java.home'])
}
And if this does not work, put this into you build.gradle(app) dependencies.
compile group: 'com.sun', name: 'rt', version: '1.5.0_06'

AWS Lambda can't find dependent library

This is my first time deploying to AWS Lambda and am getting a little stuck.
I have a large maven project called Helpers which has many submodules, many of them dependent on each other. In there I have one Helper called Alerts. I have a parent directory and everything builds and compiles successfully. So, that's good.
In Alerts there's a class called PaymentAlerts which has the line
import com.mywebsite.messages.Doers
where messages.Doers is found in the dependencies.
But, when I do a mvn package on the whole project and I find alerts-1.0.jar and upload it to AWS Lambda and I set my handler as com.mywebsite.alerts.PaymentAlerts::doAlert I get the following error:
{
com.mywebsite.alerts.PaymentAlerts: com/mywebsite/messaging/Doers",
"errorType": "java.lang.NoClassDefFoundError"
"errorMessage": "Error loading class
}
How do I reconfigure this so that it finds all the necessary files?
Any and all help is appreciated!
AWS Lambda can't find dependent library
Except mvn, you can do with simple library dependency by putting all jars in one, Where your MANIFEST file contains like Class-Path: libs/xyz.jar libs/abc.jar ...
Hope this process can resolve your "errorType": "java.lang.NoClassDefFoundError"
From here I was able to find out about maven-shade-plugin which jarred everything together nicely and solved the problem.

Websocket Client Could not find an implementation class

I will preface this with I am not using any maven dependencies, yet I know that I am missing a jar file wls-api.jar (at least that is what I have read).
To remedy this I downloaded the oracle-weblogic-7.9.jar but the problem persists.
The exception is thrown at this line
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
Can anyone tell me why this line continuously fails?
UPDATE: upon further reading the examples I see use this dependency
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
I have javax.websocket-api.jar in the build path of the server and the client as it is required. What am I missing here?
Other update: I forgot to include the error thrown!
Exception in thread "main" java.lang.RuntimeException: Could not find an implementation class.
at javax.websocket.ContainerProvider.getWebSocketContainer(ContainerProvider.java:73)
at connect.<init>(connect.java:21)
at test.main(test.java:11)
javax.websocket api is only the specification don't have full implementation you may need to take the jar file tyrus-standalone-client-1.9.jar and try the same example that should solve your problem. i tested with my example and it is working fine.
hope this will help you.
I think the RuntimeException you are experiencing is fortunately not generated by any direct coding fault of your own.
The method getWebSocketContainer(), as described here, simply tries to load other classes and get the static instance of the ContainerProvider in the server.
The method looks for the ContainerProvider implementation class in the order listed in the META-INF/services/javax.websocket.ContainerProvider file, returning the WebSocketContainer implementation from the ContainerProvider implementation that is not null.
This, unfortunately, means that your project is not configured correctly. Double check to make sure this file is included in your project's build path.
If other projects you are looking at are using the Maven dependency you described, I would try to set up your project to do the same.
Hope this helped!
Adding
// https://mvnrepository.com/artifact/org.glassfish.tyrus.bundles/tyrus-standalone-client
compile group: 'org.glassfish.tyrus.bundles', name: 'tyrus-standalone-client', version: '1.9'
to my build.gradle file worked for me.

Categories