ArrayIndexOutOfBoundsException at com.objectdb.o.ALS.c(ALS.java:89)

#1

Hi all,

I have created a packet grabber using JNetPcap. It creates a scala actor (java thread) for every packet grabbed which connect to an OpenDB database to add or update relevant entry's. Everything works fine until packets arrive with a time difference in the order of microseconds. Every scala actor opens a connection to the database, does what it needs to do, and then closes the connection. Something like:

emf = Persistence.createEntityManagerFactory("./DB/arp.odb")
em = emf.createEntityManager
var queryString: java.lang.String = "SELECT res FROM LogEntry res WHERE res.spa = '" + Ip.toString(arp.spa) + "'" // Get LogEntry's with same IP
var query: TypedQuery[LogEntry] = em.createQuery(queryString, classOf[LogEntry])
var result: scala.collection.Seq[LogEntry] = query.getResultList.asScala // Convert to scala collection
// Check stuff and log certain events
em.close
emf.close

When the traffic comes in bursts (packets arrive with a time difference in the order of microseconds) an ArrayIndexOutOfBoundsException is thrown at com.objectdb.o.ALS.c(ALS.java:89). See the following stack trace. I have tried to Google the problem but with no success. The value 7 is random. I get several ArrayIndexOutOfBoundsExceptions whit values such as 8, 10 and 11 as well.

scala.actors.Actor$$anon$1@5e2c17f7: caught java.lang.ArrayIndexOutOfBoundsException: 7
java.lang.ArrayIndexOutOfBoundsException: 7
at com.objectdb.o.ALS.c(ALS.java:89)
at com.objectdb.o.EXH.c(EXH.java:46)
at com.objectdb.o.OMF.<init>(OMF.java:158)
at com.objectdb.jpa.EMF.<init>(EMF.java:62)
at com.objectdb.jpa.Provider.newEMF(Provider.java:133)
at com.objectdb.jpa.Provider.createEntityManagerFactory(Provider.java:82)
at com.objectdb.jpa.Provider.createEntityManagerFactory(Provider.java:32)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at com.easyspeedy.ArpMonitor.processFrame(ArpMonitor.scala:16)
at com.easyspeedy.JNetPcapPacketGrabber$$anon$1$$anonfun$nextPacket$1.apply$mcV$sp(JNetPcapPacketGrabber.scala:55)
at scala.actors.Actor$$anon$1.act(Actor.scala:135)
at scala.actors.Reactor$$anonfun$dostart$1.apply(Reactor.scala:222)
at scala.actors.Reactor$$anonfun$dostart$1.apply(Reactor.scala:222)
at scala.actors.ReactorTask.run(ReactorTask.scala:36)
at scala.concurrent.forkjoin.ForkJoinPool$AdaptedRunnable.exec(ForkJoinPool.java:611)
at scala.concurrent.forkjoin.ForkJoinTask.quietlyExec(ForkJoinTask.java:422)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.mainLoop(ForkJoinWorkerThread.java:340)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:325)

Line 16 in ArpMonitor.scala:

val emf: EntityManagerFactory = Persistence.createEntityManagerFactory("./DB/arp.odb")

I have tried to limit the application to only capture 5 packages to ensure that the maximum allowed simultanious connections is not exceeded. Same problem

Can someone please help!

Thanks

 

#2

Thank you for your report. That was a missing synchronized and it should be fixed now in build 2.2.4_02.

Notice however that usually it is more efficient to create a single EntityManagerFactory with multiple EntityManager instances. It is uncommon to create multiple EntityManagerFactory instances as demonstrated by your code.

ObjectDB Support

Reply