Hi, so far I've been able to get ObjectDb to persist objects from many JVM languages, eg.: Java/Groovy/Scala/Kotlin.
However, I can't seem to get Fantom to work.
Anyone tried this yet?
Dave
Hi, so far I've been able to get ObjectDb to persist objects from many JVM languages, eg.: Java/Groovy/Scala/Kotlin.
However, I can't seem to get Fantom to work.
Anyone tried this yet?
Dave
Please post a sample project, instructions on how to run it and details about the problems that you found.
Here is the example I posted on the Fantom discussion board:
Groovy
import javax.persistence.* Persistence .createEntityManagerFactory ("./db1.odb") .createEntityManager() .with { transaction.begin() persist(new Address(street:"Groovy")) transaction.commit() } @Entity class Address{ String street }
Fantom
using [java] javax.persistence class OdbTest { Void main() { Persistence .createEntityManagerFactory ("./db1.odb") .createEntityManager .with { getTransaction.begin persist(Address {street = "Fantom"}) getTransaction.commit } } } @Entity class Address{ Str? street }
Result
Groovy version works fine, using the ObjectDb ObjectExplorer the Address objects pops up in the database.
However, unlike in Java/Groovy/Scala/Kotlin, Fantom throws this runtime error (I have not tried this in other JVM languages such as JRuby, Clojure or Jython):
sys::Err: com.objectdb.o._RollbackException: Failed to commit transaction: Failed to get reference value of field field fan.FodbTest.Address.street using enhanced method com.objectdb.o.JPE.g (JPE.java:89) com.objectdb.o.ERR.f (ERR.java:59) com.objectdb.o.OBC.onObjectDBError (OBC.java:1501) com.objectdb.jpa.EMImpl.commit (EMImpl.java:279) FodbTest::OdbTest.main (OdbTest.fan:12) fan.sys.FanObj.with (FanObj.java:159) FodbTest::OdbTest.main (OdbTest.fan:9) java.lang.reflect.Method.invoke (Method.java:597) fan.sys.Method.invoke (Method.java:558) fan.sys.Method$MethodFunc.callOn (Method.java:230) fan.sys.Method.callOn (Method.java:139) fanx.tools.Fan.callMain (Fan.java:175) fanx.tools.Fan.executeType (Fan.java:140) fanx.tools.Fan.execute (Fan.java:41) fanx.tools.Fan.run (Fan.java:298) fanx.tools.Fan.main (Fan.java:336)
An attempt to run this example using the Eclipse/F4 IDE has failed on earlier problems:
The Eclipse/F4 project is attached. Could you please help in fixing it?
Will take a look.
Have been discussing this issue on the Fantom
forum: https://fantom.org/forum/topic/1851#c12606
Dave
hmm, so this is strange.
First time I ran the project (after setting java build path for the objectdb.jar), it worked perfectly!
See attached database file.
After that, it threw this error every time:
sys::Err: com.objectdb.o._RollbackException: Failed to commit transaction: Failed to get reference value of field field fan.OdbTest.Address.street using enhanced method com.objectdb.o.JPE.g (JPE.java:89) com.objectdb.o.ERR.f (ERR.java:59) com.objectdb.o.OBC.onObjectDBError (OBC.java:1501) com.objectdb.jpa.EMImpl.commit (EMImpl.java:279) OdbTest::OdbTest.main (OdbTest.fan:12) fan.sys.FanObj.with (FanObj.java:159) OdbTest::OdbTest.main (OdbTest.fan:9) java.lang.reflect.Method.invoke (Method.java:597) fan.sys.Method.invoke (Method.java:558) fan.sys.Method$MethodFunc.callOn (Method.java:230) fan.sys.Method.callOn (Method.java:139) fanx.tools.Fan.callMain (Fan.java:175) fanx.tools.Fan.executeType (Fan.java:140) fanx.tools.Fan.execute (Fan.java:41) fanx.tools.Fan.run (Fan.java:298) fanx.tools.Fan.main (Fan.java:336)
I am still not there. I keep getting the errors in #4 on F4 - Fantom IDE version 1.0.
Also after upgrading the sys.jar file to version 1.0.62.
Are you using the same ide?
I'm using F4 from xored.
In that IDE you need to add the objectdb.jar to the javaclasspath.
Alternatively, you can put the objectdb.jar file into:
[FANTOM_HOME]/lib/java (I think)
Same IDE. See attached screenshot.
objectdb.jar is in the Java Build Path. I also added it to [FANTOM_HOME]/lib/java.
Ilan, response I got from the Fantom guy (Brian) is:
"Like I said, don't use Eclipse. Just use the core Fantom distribution which is how we are going to test any fix anyways."
In that case, please package the example in an executable jar and provide an explanation for a non Fantom user - what exactly to run from the console and how.
It may be easier to examine this example using old known Java class files.