276 words

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

2011-05-11 08:24

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

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!



tuec's picture
Joined on 2011-05-10
User Post #1
2011-05-11 21:25

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support's picture
Joined on 2010-05-03
User Post #261

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Maximum file size: 32 MB