UnsatisfiedLinkError when calling new World() - java

My error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:130)
Caused by: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D
at org.jbox2d.common.Timer.now(Native Method)
at org.jbox2d.common.Timer.reset(Timer.java:35)
at org.jbox2d.common.Timer.<init>(Timer.java:31)
at org.jbox2d.dynamics.World.<init>(World.java:587)
at org.jbox2d.dynamics.World.<init>(World.java:158)
at org.jbox2d.dynamics.World.<init>(World.java:154)
at org.jbox2d.dynamics.World.<init>(World.java:145)
at com.badlogic.gdx.physics.box2d.World.<init>(World.java:61)
at com.example.blockbunny.states.Play.<init>(Play.java:22)
at com.example.blockbunny.handlers.GameStateManager.getState(GameStateManager.java:36)
at com.example.blockbunny.handlers.GameStateManager.pushState(GameStateManager.java:46)
at com.example.blockbunny.handlers.GameStateManager.<init>(GameStateManager.java:20)
at com.example.blockbunny.main.Game.create(Game.java:33)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:146)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:123)
And this occurs when I do this:
world = new World(new Vector2(0, -9.81f), true);
I have looked online, and some solutions included using this:
import com.badlogic.gdx.utils.GdxNativesLoader;
GdxNativesLoader.load();
However, I don't know where to put this function, and if it even works (I tried putting it in several different places)
How can I fix this issue?
Help will be appreciated, thanks!
As requested, here are my imports:
import static com.example.blockbunny.handlers.B2DVars.PPM;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import com.example.blockbunny.handlers.GameStateManager;
import com.example.blockbunny.main.Game;

I used Box2d several time with libgdx and i never encountered such a problem :
here what i propose t you :
GdxNativesLoader.load();
should be put on the create() method, but that doesn't seem to work with you
also try call it in a static way like this :
static {
GdxNativesLoader.load();
}
but i thin your problem is the extension of the library that you are using
verify that you are using gdx-box2d and not gdx-box2d-gwt which is used only for Html project
Verify that you are using the right (jar file) /(extension library) : gdx-box2d.jar and gdx-box2d-natives.jar (also verify the build path)
also try :
upgrade the box2d version that you're using
those were all the arrows i had ! hope one of it will work
Good luck !!

I came across the same issue, was using the gwt libraries. Updated the Maven dependency artifact from
gdx-box2d-gwt
to
gdx-box2d
and it fixed the error.

Related

Eclipse cannot find JavaFX 11 Legend type

I'm trying to get some java 1.8 code working in Java 11. I've hit what seems to be a common wall, but none of the answers I've found are working.
System: Fedora 33 5.9.8-200.fc33.x86_64
Eclipse Version: 2020-09 (4.17.0) Build id: 20200910-1200
JDK: java-11-openjdk-11.0.9.11-0.fc33.x86_64
JavaFX: OpenFX javafx-sdk-11.0.2
Here's the bit of code that's blocking me.
class MyPie extends PieChart {
public Legend legend;
public MyPie() {
super();
legend = (Legend) getLegend();
}
}
The error is: "Legend cannot be resolved to a type" When I ask Eclipse to auto-generate an import statement, or use the suggestion, it put in this line:
import com.sun.javafx.charts.Legend;
This is a problem, because that doesn't seem to exist and doesn't follow the same pattern as the other JavaFX imports:
import javafx.scene.chart.PieChart;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
I have a second one "com.sun.javafx.css.StyleManager" which I'm guessing will have the same solution.
What am I missing here?
Thanks.

Updated Katalon Studio to version 5.9.1 - ClassNotFoundException

After updating Katalon Studio to 5.9.1, we occasionally get java.lang.ClassNotFoundException: cz.elektLabs.Keywords on our custom keyword class while running tests in Jenkins.
What is weird is that it doesn't happen every time and we are not able to reproduce it. It worked before in 5.7.
Here is beginning of our custom keyword class:
package cz.elektLabs
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import org.openqa.selenium.By
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.util.KeywordUtil
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import groovy.json.JsonSlurper
import groovy.time.TimeCategory
import internal.GlobalVariable
class Keywords {
#Keyword
def boolean checkIfValidImage(String url) {
...
}
...
}
And here is the error we get:
2018-12-14 09:18:53.987 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - ? cz.elektLabs.Keywords
2018-12-14 09:18:53.988 ERROR c.k.katalon.core.main.TestCaseExecutor - ? cz.elektLabs.Keywords.openAndLogin() FAILED.
Reason:
java.lang.ClassNotFoundException: cz.elektLabs.Keywords
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.getCustomKeywordClassAndSetMetaClass(CustomKeywordDelegatingMetaClass.java:98)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:44)
at TestSystem.run(TestSystem:17)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:321)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:312)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:291)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:283)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:222)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:129)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:112)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:81)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:149)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1544775530390.run(TempTestSuite1544775530390.groovy:36)
Is there anything we could do to fix this issue?
edit: We updated Katalon Studio to version 5.10.1 and we are still getting ClassNotFoundException or NoClassDefFoundError every now and then.
Please make sure you have installed Open JDK 1.8 on the machine.

How to solve Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE?

I'm trying to upload a file using Selenium web driver. Above error receive. I know code is ok. Most of post saying it is because "dependencies". How can I solve it? I checked there was no same name jar files. Here I have show some screen shot of my jar files. How can I solve this dependencies problem?
Java code:
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class FusekiStart {
public static void main(String[] args) {
/* Selenium config */
String PROXY = "localhost:3030";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);
driver.get("http://localhost:3030/control-panel.tpl");
driver.findElement(By.xpath("//input[#value='Select']")).click();
driver.findElement(By.xpath("//input[#type='file']")).sendKeys("C:\\Users\\user1\\Desktop\\Ontology.owl");
driver.findElement(By.xpath("//input[#value='Upload']")).click();
}
}
Error message:
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init> (DefaultHttpRequestWriterFactory.java:52)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:72)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:84)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:59)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:487)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:147)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:136)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:112)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:68)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:55)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:99)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:82)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
at uom.brts.statisticalmt.FusekiStart.main(FusekiStart.java:39)
Check this link:
Source Code at Grep
You are missing BasicLineFormatter class from org.apache.http.message package.
I would say not this will fix your problem but can you see by including a httpcore 4.2.2 jar file is what your are using currently. Can you try to get the higher one from the Link and replace it with current httpcore 4.2.2 and see what difference it makes ?
I faced the same problem. After a lot of debugging, I found out that there is a CLASSPATH conflict. A jar file already existing in the project
httpclient-osgi-4.2.1.jar
was conflicting with selenium jar files. Fortunately for me, the httpclient-osgi-4.2.1.jar file is not required in the project anymore, so I could safely remove it. After that the problem is gone.
The error message is pathetic. It doesn't help in any way to point out the real problem.

Drools 6.0 dynamically load rules at runtime

I want to load a drl file at runtime. The posts I've found including this one work for version 5.0 but I can't figure out how to do it for drools version 6.0.
In Drools 6, your rules packages are deployed to Maven. A KieScanner is provided, which you can attach to your KieContainer. This polls your repository at a defined interval to see whether a package has been updated and downloads the latest if that's the case.
A full explanation of how to define a KieScanner (including code samples) is provided in the Drools documentation here:
https://docs.jboss.org/drools/release/latest/drools-docs/html/ch04.html
I used info taken from those two docs:
https://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html_single/#d0e109
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/CommonTestMethodBase.java
I've came out with this snippet that loads rules defined in the /drl/file/path file into the stateful session you obtain at the last line.
File path = new File("/drl/file/path");
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newFileResource(path), ResourceType.DRL);
if (kbuilder.hasErrors()) {
throw new RuntimeException("Errors: " + kbuilder.getErrors());
}
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Some methods are deprecated, so, don't expect this solution to be valid in the following releases.
Please, double check the imports, they are all from org.kie, not from drools packages. I admit those imports are too much, but I'm pasting the code from an example I'm trying to develop, so I have more things on my code, sorry for that.
import java.io.File;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
import org.kie.api.builder.KieScanner;
import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.model.KieBaseModel;
import org.kie.api.builder.model.KieModuleModel;
import org.kie.api.builder.model.KieSessionModel;
import org.kie.api.conf.EqualityBehaviorOption;
import org.kie.api.conf.EventProcessingOption;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.conf.ClockTypeOption;
import org.kie.internal.KnowledgeBase;
import org.kie.internal.KnowledgeBaseFactory;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.runtime.StatefulKnowledgeSession;
Hope it helps.

Can the package "org.opencv.core.Mat" be used for a simple Java program?

I'm trying to do some operations with a Matrix in Java using opencv. I'm using Eclipse Kepler IDE.
The problem happens when I try to declare a new matrix with the constructor, then I get the following error in the console:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.opencv.core.Mat.n_Mat(III)J
at org.opencv.core.Mat.n_Mat(Native Method)
at org.opencv.core.Mat.<init>(Mat.java:477)
I'm using OpenCV 2.4.8 for OSX, OSX 10.9.1 and Eclipse Kepler.
Here is my Code:
import java.util.ArrayList;
import java.util.List;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Size;
public class FisherFaces {
public static void main(String[] args) {
Size s = new Size(new double[] {3,3});
Mat g= new Mat(3,3,CvType.CV_8UC1);
}
Is there anything I am doing wrong to cause this error?
I found the problem, I wasn't loading the native libraries, adding the line below fixes it.
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

Categories