I have checked out the SWI-Prolog JPL library, and I am trying to add some functionality. Right now, I am just trying to get the tests to work in the TestJUnit test. However, I am getting the following error:
SWI-Prolog: [FATAL ERROR:
Could not open resource database "../../src/swipl.prc": No error]
I have looked at the code, and I know that path is coming from this declaration:
public static final String startup =
(System.getenv("SWIPL_BOOT_FILE") == null ? "../../src/swipl.prc" :
System.getenv("SWIPL_BOOT_FILE"));
It is looking for a an environment variable %SWIPL_BOOT_FILE%, so I could see how this might fix the problem. However, I don't know which file I should add as the boot file.
I have tried the swipl-win.exe, but that doesn't work.
Any ideas?
Related
I am working on an AEM site and I am trying to get the page property teaserImage I have the follow in my Java class, but when I do a build I get a cannot find symbol error.
public String getTeaserImg() {
return this.getPageManager().getPage(url).getProperties().get("teaserImage").value;
}
But if I put a breakpoint on this similar function
public Page getPage() {
return this.getPageManager().getPage(url);
}
And then execute this.getPageManager().getPage(url).getProperties().get("teaserImage").value in an Evulate expression window it gives me the property, so I'm not sure why on build it doesnt work when it works in this scenario.
Cannot find symbol error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn't understand.
What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?
In your example you are trying to get a property. If you can get that when you are debugging the code, that maybe means you forgot to add that property when you are trying to build the application.
I faced a very confusing problem today where my email service, I am using simple-java-mail, stopped sending all in a sudden.. and an exception was raised:
Exception in thread "pool-3-thread-1" java.lang.NoSuchMethodError: com.sun.mail.util.TraceInputStream.(Ljava/io/InputStream;Lcom/sun/mail/util/MailLogger;)V
I was going insane as nothing affecting emails was added, I tried to use maven enforcer plugin to discover what was going on but with no clue.
The question was how can I discover which jar or library does a class at runtime come from?
With this snippet you can figure out from where this class is coming from, and so find the source of a class immediately:
Class klass = Class.forName("javax.mail.Service");
URL location = klass.getResource('/' + klass.getName().replace('.', '/') + ".class");
System.out.println(location);
Now you can know javax.mail.Service resides in which JAR.
I am using kryo lib to serialize objects. I get error:
Unable to find class: java.util.ArrayLisoSerialization
and teammates reproduce that error... It seems that java class name from Kryo was changed (ArrayListSerialization -> ArrayLisoSerialization). That was tested at 2 computers (linux and windows, both jdk7) and problem appears only on my computer (linux). I tried to change Java version from jdk7 (build 67) to jdk8, but problem still appears.
Any ideas why it happens?
Bigger part of error trace:
com.esotericsoftware.kryo.KryoException: Unable to find class: java.util.ArrayLisoSerialization trace:messages at com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:138) at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:115) at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:666) at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:99) at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:528) at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:682)...
That looks like a typo somewhere in kryo or in a configuration file in your project.
I would do a string search on your project file first.
On second glance, this is going wrong:
String className = input.readString();
....
type = Class.forName(className, false, kryo.getClassLoader());
The problem is in your data it sees. Your serialized content contains, as className, the wrong class you mention.
I don't know how this could've been caused to write like this, as I would assume that a java.util.ArrayListSerialization was originally written but got corrupted somehow.
I'm not too familiar with Kryo however. Is this written to a human readable text file? if so this might've been an accidental replacement while reading the file by hand. (with vi, notepad, or something else). From what I can see, the inputstream is simply read, and a string is opened.
I would open the data file and see if the string java.util.ArrayLisoSerialization is present there.
I assume this should be changed to java.util.ArrayListSerialization.
HOWEVER make a backup of any data you are modifying. Changing serialized data should always be done with the safety of being able to revert back to the original data.
I'm tackling to use kyotocabinet in Playframework.
and following error occurred.
I'm using Eclipse and playframework-1.2.3.
and kyotocabinet is native library so I'm using its Java-Binding.
the reproduce code is simple.
in controller:
public static void somePage() {
DB db = new DB();//error occurred
render();
}
Internal Server Error (500) for request GET /
Execution exception (In /app/controllers/TestApp.java around line 45)
NoClassDefFoundError occured : Could not initialize class kyotocabinet.DB
play.exceptions.JavaExecutionException: Could not initialize class kyotocabinet.DB
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class kyotocabinet.DB
at controllers.TestApp.somePage(TestApp.java:45)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159)
... 1 more
build in Eclipse was completed but error occured at runtime.
I guess it is because kyotocabinet.dll is missing.(only jkyotocabinet.jar was found)
I configured the location of kyotocabinet.dll to Java Build Path > Source > Native Library Location of my playframework project.
and it was good in other projects.
How to use native library in playframework?
any example or tutorial?
Play.getFile and System.load didn't work.
package controllers;
import play.Play;
import play.jobs.*;
#OnApplicationStart
public class Bootstrap extends Job {
public void doJob() {
String path = "D:/MyProject/lib/jkyotocabinet.dll";
Play.getFile(path);
//System.load(path); if this was enabled, following error occurred: "Native Library D:\MyProject\lib\jkyotocabinet.dll already loaded in another classloader". so I guess the dll was loaded.
System.out.println("bootstrap loaded");//this is displayed.
}
}
UnsatisfiedLinkError occured : no jkyotocabinet in java.library.path
this Japanese blog tells Play!Framework cannot load native library.
http://d.hatena.ne.jp/hjym_u/20110702/1309609277
I already tried these: Absolute path, Relative path, System.load, System.loadLibrary, Play.getFile.
as conclusive approach, I put jkyotocabinet.dll to current directory(D:/MyProejct/), and wrote this code.
public static void somePage(){
File f = Play.getFile("jkyotocabinet.dll");
if(f != null && f.isFile() && f.canRead() && f.canExecute()){//true
DB db = new DB();//error occured. it reached here.
}
render();
}
Execution exception
NoClassDefFoundError occured : Could not initialize class kyotocabinet.DB
Play.getFile found the path "jkyotocabinet.dll" so jkyotocabinet.dll is in current directory so jvm should find it automatically.
anyone can use JNI in playframework?
finally, I could use kyotocabinet as PROD mode but not DEV mode.
Project/conf/application.conf
#application.mode=dev
application.mode=prod
I assume you just need to load the dll into Java via System.load
If you place the ddl on your project, you may load it via Play.getFile inside your #OnApplicationStart controller. This should make it available to your application while the JVM is alive.
EDIT:
#KenichiYamamoto Play.getFile gets files from the application path. You are trying to use a full path in there.
Read this about loading the file in a container. It may be that (due to Play compile-reload system) you are hitting the "already loaded" error. Try to follow the example by adding the System.load inside a static block in your #OnApplicationStart
Do as pere says but use the relative path from your application root. Not the absolute path. I.e. Play.getFile("lib\myfile.dll")
Google analytics posted on their blog about an example Java program to extract data and output to a CSV using the analytics api, im trying to compile this program to run it in eclipse but running into problems
http://code.google.com/p/ga-api-java-samples/source/browse/trunk/src/v2/DataOverTime/src/example/MainDemo.java
i have changed out the variables in here to my own:
// User configurations.
private static final String USERNAME = "INSERT_YOUR_GOOGLE_ACCOUNT_LOGIN";
private static final String PASSWORD = "INSERT_YOUR_GOOGLE_ACCOUNT_PASSWORD";
private static final String TABLE_ID = "INSERT_YOUR_TABLE_ID";
i'm unsure on the next step, when i try to run the program i get this error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at MainDemo.main(main.java:51)
update:
ok, its says when using the google analytics API i need to reference some .jar files:
gdata-core-1.0.jar
gdata-client-meta-1.0.jar
gdata-client-1.0.jar
gdata-analytics-meta-2.0.jar
gdata-analytics-2.0.jar
google-collect-1.0-rc1.jar
jsr305.jar
i put these in but its still not working i get the following error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Results cannot be resolved to a type
The method getData(DataQuery) from the type DataOverTime refers to the missing type Results
Is your directory structure correct? It should look somewhat like the url of the example.
The file has to be './example/MainDemo.java' and compile it from '.'
I got the answer in this forum: http://code.google.com/apis/analytics/groups/exportApiGroup.html?place=topic%2Fgoogle-analytics-data-export-api%2FwpDmftjYFio%2Fdiscussion