Home » Support » Forum » java.lang.NullPointerException when using ORDER BY

java.lang.NullPointerException when using ORDER BY

#1

We are using ObjectDB 2.5.1_04. The following query causes an internal null pointer exception:

SELECT r FROM RecordingMetaData AS r WHERE ((r.mapToCli != '192.168.10.200:9085' AND r.callDirection == 0)) ORDER BY r.startDateTime DESC

If we remove the ORDER BY part, the query completes OK and returns the records from the DB, but obviously not in order.

Here is the stack trace of the exception:

Caused by: java.lang.IllegalStateException: com.objectdb.o.InternalException: Unexpected internal exception  
        at com.arunta.base.db.RecordingMetaDataDAO.getResultList(RecordingMetaDataDAO.java:925)              
        at com.arunta.app.services.RecordingService.getResultList(RecordingService.java:373)                 
        ... 16 more                                                                                          
Caused by: com.objectdb.o.InternalException: Unexpected internal exception                                   
        at com.objectdb.o.JPE.h(JPE.java:165)                                                                
        at com.objectdb.o.ERR.f(ERR.java:70)                                                                 
        at com.objectdb.o.OBC.onObjectDBError(OBC.java:1484)                                                 
        at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:695)                                        
        at com.arunta.base.db.RecordingMetaDataDAO.getResultList(RecordingMetaDataDAO.java:904)              
        ... 17 more                                                                                          
Caused by: java.lang.NullPointerException                                                                    
        at com.objectdb.o.VOB.l(VOB.java:237)                                                                
        at com.objectdb.o.NFL.Uv(NFL.java:89)                                                                
        at com.objectdb.o.SBI.u(SBI.java:109)                                                                
        at com.objectdb.o.OBI.w(OBI.java:479)                                                                
        at com.objectdb.o.OBI.s(OBI.java:346)                                                                
        at com.objectdb.o.OBI.r(OBI.java:273)                                                                
        at com.objectdb.o.SBI.r(SBI.java:82)                                                                 
        at com.objectdb.o.OBI.Vk(OBI.java:239)                                                               
        at com.objectdb.o.BQI.Vt(BQI.java:150)                                                               
        at com.objectdb.o.SQI.Uu(SQI.java:118)                                                               
        at com.objectdb.o.PRG.ag(PRG.java:679)                                                               
        at com.objectdb.o.PRG.af(PRG.java:553)                                                               
        at com.objectdb.o.QRM.U6(QRM.java:265)                                                               
        at com.objectdb.o.MST.U6(MST.java:933)                                                               
        at com.objectdb.o.WRA.U6(WRA.java:293)                                                               
        at com.objectdb.o.WSM.U6(WSM.java:113)                                                               
        at com.objectdb.o.QRR.g(QRR.java:244)                                                                
        at com.objectdb.o.QRR.f(QRR.java:153)                                                                
        at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:686)                                        
        ... 18 more

 

The fields that participate in the query are defined in RecordingMetaData as follows:

    private Date startDateTime;     // Time stamp: start of recording in local time zone
    :
    private String mapToCli;
    :
    private Integer callDirection;

 

Any ideas on how to avoid the exception?

Thank you

Emil

#2

Same problem in 2.5.4_03.

#3

Please post the stack trace that you get with version 2.5.4_03.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#4

Here is the stack trace as printed by your DB explorer tool when running the query:

 

[ObjectDB 2.5.4_03] Unexpected exception (Error 990)                                                        
  Generated by Java HotSpot(TM) 64-Bit Server VM 1.7.0_11 (on Linux 2.6.32-279.9.1.el6.x86_64).             
Please report this error on http://www.objectdb.com/database/issue/new                                      
com.objectdb.o.InternalException: java.lang.NullPointerException: null                                      
java.lang.NullPointerException                                                                              
        at com.objectdb.o.VOB.l(VOB.java:237)                                                               
        at com.objectdb.o.NFL.Uv(NFL.java:91)                                                               
        at com.objectdb.o.SBI.u(SBI.java:109)                                                               
        at com.objectdb.o.OBI.w(OBI.java:481)                                                               
        at com.objectdb.o.OBI.s(OBI.java:348)                                                               
        at com.objectdb.o.OBI.r(OBI.java:275)                                                               
        at com.objectdb.o.SBI.r(SBI.java:82)                                                                
        at com.objectdb.o.OBI.Vp(OBI.java:241)                                                              
        at com.objectdb.o.BQI.Vz(BQI.java:151)                                                              
        at com.objectdb.o.SQI.Uu(SQI.java:119)                                                              
        at com.objectdb.o.PRG.ag(PRG.java:679)                                                              
        at com.objectdb.o.PRG.af(PRG.java:553)                                                              
        at com.objectdb.o.QRM.Vb(QRM.java:285)                                                              
        at com.objectdb.o.MST.Vb(MST.java:949)
        at com.objectdb.o.WRA.Vb(WRA.java:311)
        at com.objectdb.o.WSM.Vb(WSM.java:115)
        at com.objectdb.o.QRR.g(QRR.java:244)
        at com.objectdb.o.QRR.f(QRR.java:153)
        at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:716)
        at com.objectdb.o.QRP.L(QRP.java:259)
        at com.objectdb.o.QRP.T(QRP.java:723)
        at com.objectdb.o.QRP.actionPerformed(QRP.java:686)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
        at java.awt.Component.processMouseEvent(Component.java:6505)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
        at java.awt.Component.processEvent(Component.java:6270)
        at java.awt.Container.processEvent(Container.java:2229)
        at java.awt.Component.dispatchEventImpl(Component.java:4861)
        at java.awt.Container.dispatchEventImpl(Container.java:2287)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
        at java.awt.Container.dispatchEventImpl(Container.java:2273)
        at java.awt.Window.dispatchEventImpl(Window.java:2719)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:682)
        at java.awt.EventQueue$3.run(EventQueue.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.awt.EventQueue$4.run(EventQueue.java:696)
        at java.awt.EventQueue$4.run(EventQueue.java:694)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
#5

This may be related to your other report, i.e. using the composite index with the unexpected entry, so both issues may be solved together.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#6

I am not sure if this problem is related to the other as the query works if you remove the order by part. That is this query works:

SELECT r FROM RecordingMetaData AS r WHERE ((r.mapToCli != '192.168.10.200:9085' AND r.callDirection == 0))

Both mapToCli and callDirection are part of composite indices. mapToCli can be set to NULL while callDirection always has a value. Same applies to startDateTime which is used in the order by part, it always has a value.

Anyway, we tried fixing the indices with the Doctor tool and it did not help. We also deleted the DB file and re-created the DB from scratch, but the problem persists.

Finally, we tried queries like the following and all work:

SELECT r FROM RecordingMetaData AS r WHERE ((r.mapToCli != '192.168.10.200:9085' AND r.callDirection ==  0)) order by r.callDirection
SELECT r FROM RecordingMetaData AS r WHERE ((r.mapToCli != '192.168.10.200:9085' AND r.callDirection ==  0)) order by r.mapToCli
SELECT r FROM RecordingMetaData AS r WHERE ((r.mapToCli != '192.168.10.200:9085' AND r.callDirection ==  0)) order by r.startDate

Only when we try to use "order by r.startDateTime" we get the NullPointerException. Note that r.startDate is also a Date member like r.startDateTime.

 

#7

As I was writing the previous post it occurred to me try ORDER BY with a field that is not part of any index. I can reproduce the problem if a run a query where the ORDER BY filed is not a member of any index. It just happens that startDateTime is not a member of any index while startDate, callDirection and mapToCli are members of (different) composite indices.

Is it a rule that we must use fields that are part of an index in the ORDER BY?

 

 

#8

Thank you for the details. Please try build 2.5.4_04, which may solve this issue.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#9

I can confirm that 2.5.4_04 fixes the problem. Thank you.


Post Reply

To post a reply and/or subscribe to update notifications - please login