Execution Error when change the SATSolver from SAT4J to MiniSAT - alloy

In my Java code, when i change the SATSolver from SAT4J to MiniSatJNI or MiniSatProverJNI in:
A4Options options = new A4Options();
options.solver = A4Options.SatSolver.SAT4J;
For instance, to:
A4Options options = new A4Options();
options.solver = A4Options.SatSolver.MiniSatProverJNI;
And then call:
A4Solution currentAns = TranslateAlloyToKodkod.execute_command(null,
javaMetamodel.getAllReachableSigs(), command, options);
I receive the following execution error:
Fatal error:
The required JNI library cannot be found: java.lang.UnsatisfiedLinkError: no minisatproverx5 in java.library.path
at edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod.execute_command(TranslateAlloyToKodkod.java:390)
at ejdolly.JDollyImp.initializeAlloyAnalyzer(JDollyImp.java:128)
at ejdolly.JDolly.hasNext(JDolly.java:181)
at org.testorrery.ForLoopIterator.hasNext(ForLoopIterator.java:40)
at refactoringTest.RefactoringTest.runTests(RefactoringTest.java:145)
at refactoringTest.MainRunner.main(MainRunner.java:83)
Caused by: java.lang.UnsatisfiedLinkError: no minisatproverx5 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at kodkod.engine.satlab.NativeSolver.loadLibrary(NativeSolver.java:73)
at kodkod.engine.satlab.MiniSatProver.<clinit>(MiniSatProver.java:148)
at kodkod.engine.satlab.SATFactory$5.instance(SATFactory.java:106)
at kodkod.engine.fol2sat.Bool2CNFTranslator.translate(Bool2CNFTranslator.java:55)
at kodkod.engine.fol2sat.Translator.toCNF(Translator.java:426)
at kodkod.engine.fol2sat.Translator.generateSBP(Translator.java:365)
at kodkod.engine.fol2sat.Translator.toBoolean(Translator.java:343)
at kodkod.engine.fol2sat.Translator.translate(Translator.java:189)
at kodkod.engine.fol2sat.Translator.translate(Translator.java:143)
at kodkod.engine.Solver$SolutionIterator.next(Solver.java:495)
at kodkod.engine.Solver$SolutionIterator.next(Solver.java:1)
at edu.mit.csail.sdg.alloy4compiler.translator.A4Solution$Peeker.<init>(A4Solution.java:719)
at edu.mit.csail.sdg.alloy4compiler.translator.A4Solution$Peeker.<init>(A4Solution.java:709)
at edu.mit.csail.sdg.alloy4compiler.translator.A4Solution.solve(A4Solution.java:941)
at edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod.execute_command(TranslateAlloyToKodkod.java:388)
... 5 more
java.lang.NullPointerException
at ejdolly.JDolly.hasNext(JDolly.java:182)
at org.testorrery.ForLoopIterator.hasNext(ForLoopIterator.java:40)
at refactoringTest.RefactoringTest.runTests(RefactoringTest.java:145)
at refactoringTest.MainRunner.main(MainRunner.java:83)
Any help?

The solution pointed by #Aleksandar in:
Alloy API resulting in java.lang.UnsatisfiedLinkError
worked for me on linux!!! But it does not work on windows.
Thank you for all the help !

Alloy invokes native solvers (such as MiniSAT) by using JNDI/JNI. That means that the native libraries must be correctly configured before. If you do not have the library correclty configured, Java will produce a "java.lang.UnsatisfiedLinkError" exception.
The Alloy distributable jar includes correctly configured libraries for Windows "x86" and for Linux and Mac in "x86" and "x64". That means that the jar will work in Windows, without any additional configuration, if you are using the Java 32 bits, but not with Java 64 bits. In the other operating systems you can use both Java versions (32 and 64 bits).
You may check other questions in StackOverflow for the same explanation.

Related

Cannot deploy weblogic server application that contains log4j 2.9.x

I am not able to start application it gives below exception :
Java.lang.IllegalArgumentException
At com.bea.objectweb.asm.ClassReader.(Unknownsource)com.bea.objectweb.asm.ClassReader.(Unknown source)
Application got started after replacing below jars
Log4j-1.2-api-2.9.1.jar
Log4j-api-2.9.1.jar
Log4j-core-2.9.1.jar
Log4j-slf4j-impl-2.10.0.jar
With
Log4j-1.2-api-2.8.2.jar
Log4j-api-2.8.2jar
Log4j-core-2.8.2.jar
Log4j-slf4j-impl-2.8.2.jar
Since version 2.9.0 there are classes compiled in java 9.
One workaround is to remove them from log4j-api-2.x.y.jar

JxBrowser on Linux throws NoSuchMethodException: getWindow

I am running some unit tests on a headless linux machine, but with Xvfb server started.
The Browser gets created but seems that it has problems displaying it - see the exception.
03:53:39 INFO: OS name: Linux
03:53:39 INFO: JRE version: 1.8.0_31 64-bit
03:53:39 INFO: JxBrowser version: 6.4
03:53:39 INFO: JxBrowser type: HEAVYWEIGHT
My code looks similar to this
Frame frame = new JFrame("myFrame");
Browser browser = new Browser();
BrowserView view = new BrowserView(browser);
frame.add(view, BorderLayout.CENTER);
frame.setVisible(true);
On Windows environment works fine, but on Linux I get the following error
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: getWindow
at com.teamdev.jxbrowser.chromium.internal.ReflectionUtil.invokeMethod(Unknown Source)
at com.teamdev.jxbrowser.chromium.swing.internal.NativeLinux.getWindowHandle(Unknown Source)
at com.teamdev.jxbrowser.chromium.swing.internal.HeavyWeightWidget.a(Unknown Source)
at com.teamdev.jxbrowser.chromium.swing.internal.HeavyWeightWidget.b(Unknown Source)
at com.teamdev.jxbrowser.chromium.swing.internal.HeavyWeightWidget$d.hierarchyChanged(Unknown Source)
at java.awt.Component.processHierarchyEvent(Component.java:6692)
at java.awt.Component.processEvent(Component.java:6311)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.Component.createHierarchyEvents(Component.java:5541)
at java.awt.Container.createHierarchyEvents(Container.java:1443)
at java.awt.Container.createHierarchyEvents(Container.java:1439)
at java.awt.Container.createHierarchyEvents(Container.java:1439)
at java.awt.Container.createHierarchyEvents(Container.java:1439)
at java.awt.Container.createHierarchyEvents(Container.java:1439)
at java.awt.Container.createHierarchyEvents(Container.java:1439)
at java.awt.Component.show(Component.java:1622)
at java.awt.Window.show(Window.java:1042)
I have in my lib folder the following
jxbrowser-6.4.jar
jxbrowser-linux64-6.4.jar
jxbrowser-mac-6.4.jar
jxbrowser-win-6.4.jar
and in the build.xml of my tests this
<fileset dir="${myproject.dir}/lib">
<include name="**/*.jar"/>
<exclude name="**/jxbrowser-mac*.jar"/>
<exclude name="**/jxbrowser-win*.jar"/>
</fileset>
Any suggestions?
By default JxBrowser is run in the heavyweight rendering mode. In this mode we embed a native window into your Java application window and configure Chromium engine to render content into this native window using GPU. In order to embed a native window we need to get a handle of the top-level window in your Java application. The exception you see indicates that JxBrowser failed to get that handle. What Linux distribution you use?
You mentioned that you use JxBrowser in a headless Linux environment. In this case you don't need to create a BrowserView instance and embed it into a JFrame, so that should resolve the issue.
Also, you can use JxBrowser in the lightweight rendering mode that does not require a window handle:
Browser browser = new Browser(BrowserType.LIGHTWEIGHT);

Provider is not supported, or was incorrectly entered

I have installed gerrit server setup in localhost. And after making the successful connection the Web UI has been launched. There i have registered with my gmail id in "Sign in with a Launchpad ID" option.
Its worked earlier, but now it shows the error "Provider is not supported, or was incorrectly entered." when i try to login. I had searched a lot and found some solution regarding the security issues in the installed java in the system. I have Oracle Jdk8 not OpenJdk in my system. so should i have to switch to Open Jdk. Here is my error log messages from log file.
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:90)
at sun.security.validator.Validator.getInstance(Validator.java:179)
at sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:312)
at sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:171)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:184)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
... 66 more
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)
at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:88)
... 78 more
Issue Fixed !
As i have been using Oracle Java 8, i have installed Open Jdk 7 with the following commnad.
sudo apt-get install ca-certificates-java
But issue resolved only when i have changed java home variable in gerrit.config file.
javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
Now the issues fixed for me..

unable to run j2me app in emulator

i am trying to run j2me app in emulator using eclipse but when i run the app i am getting following error
Error installing IMlet. See logs for details.
i tried to explore different thread but could not get definite answer.it asks to download IMlet Suite but i didnt find a place from where i can download it.
i am using windows 8 64bit machine
i am pretty new to this so please guide accordingly.
when i m trying to run following command
C:\WTK22\bin>emulator.bat
it shows following error
C:\WTK22\bin>C:\PROGRA~2\Java\JRE18~1.0_3\bin\java.exe -Dkvem.home=C:\WTK22 -Dja
va.library.path=C:\WTK22/bin -Dsun.java2d.ddlock=true -Dsun.java2d.gdiblit=false
-cp C:\WTK22/wtklib/kenv.zip;C:\WTK22/wtklib/ktools.zip;C:\WTK22/wtklib/customj
mf.jar com.sun.kvem.environment.EmulatorWrapper
Exception in thread "main" java.lang.IllegalStateException: KeepAliveConnection
not initialized
at com.sun.kvem.environment.KeepAliveConnection.run(Unknown Source)
at com.sun.kvem.environment.EmulatorWrapper.main(Unknown Source)

Does groovy run on jamvm?

I wanted to run groovy on jamvm in an embedded hardware. The following is what I have tried, but nothing works.
1)
$GROOVY_HOME/bin/groovy ...
It complains that JAVA_HOME is not set. Since JamVm is a standalone executable, how, if possible, to set JAVA_HOME in JamVM? If the problem reduces to setting that, it's easy to solve.
2)
jamvm -cp $GROOVY_HOME/embedded/embeddable/groovy-all-2.0.5.jar:. TestClass
I ran the example in http://groovy.codehaus.org/Embedding+Groovy ('full example' part) and got the following exception. I ran the same example on Mac, it was fine.
Exception in thread "main" BUG! exception in phase 'semantic analysis' in source unit '/root/test/Tester.groovy' 0
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:907)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:566)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:515)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:185)
at TestClass.main(TestClass.java:8)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.codehaus.groovy.vmplugin.v5.Java5.makeParameters(Java5.java:396)
3) I tried
java -cp ../groovy-2.0.5/embeddable/groovy-all-2.0.5.jar groovy.lang.GroovyShe
ll <script.groovy>
didn't work, got the following
java.lang.ExceptionInInitializerError
at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:107)
Please suggest a way to run groovy on jamvm. Thanks!
JAVA_HOME is an environment variable. You can set this one by using the command "export". ExceptionInInitializerError means it could not create a class. To actually know the problem, we would need the embedded exception

Resources