A missing or mismatched TYPE_ID causes NullPointerException when executing BQL query

A missing or mismatched TYPE_ID causes NullPointerException when executing BQL query

book

Article ID: KB0081257

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition 5.5.0

Description

A NullPointerExeption is thrown when a BQL query is executed and TIBCO BusinessEvents (BE) engine tries to serialize the returned data.

<timestamp> query Error [SnapshotQueryManager-3] - [query.stream] [<agentName>] 
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
    at com.tibco.cep.runtime.managed.EximHelper.translate(EximHelper.java:87)
    at com.tibco.cep.runtime.model.serializers.as.AbstractTupleAdaptor.extractValue(AbstractTupleAdaptor.java:50)
    at com.tibco.cep.runtime.model.serializers.as.AbstractTupleAdaptor.extractValue(AbstractTupleAdaptor.java:26)
    at com.tibco.cep.as.kit.map.SpaceMapEntryIterator$MapEntryAdapter.getValue(SpaceMapEntryIterator.java:151)
    at com.tibco.cep.query.stream.impl.rete.integ.EntityLoaderImpl.resumeOrStartBatchLoad(EntityLoaderImpl.java:93)
    at com.tibco.cep.query.stream.impl.rete.service.SnapshotQueryFeeder$FeederJob.run(SnapshotQueryFeeder.java:251)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at com.tibco.cep.query.stream.monitor.CustomDaemonThreadFactory$FactoryDaemonThread.run(CustomDaemonThreadFactory.java:65)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
    at com.tibco.cep.runtime.model.serializers.as.AbstractTupleAdaptor$AsEximHelper.transform(AbstractTupleAdaptor.java:73)
    at com.tibco.cep.runtime.model.serializers.as.AbstractTupleAdaptor$AsEximHelper.transform(AbstractTupleAdaptor.java:60)
    at com.tibco.cep.runtime.managed.EximHelper.translate(EximHelper.java:66)
    ... 10 more
Caused by: java.lang.NullPointerException
    at com.tibco.cep.runtime.model.serializers.as.AsPortablePojo.toPojo(AsPortablePojo.java:118)
    at com.tibco.cep.runtime.model.serializers.as.AbstractTupleAdaptor$AsEximHelper.transform(AbstractTupleAdaptor.java:70)
    ... 12 more

Issue/Introduction

A missing or mismatched TYPE_ID causes NullPointerException when executing BQL query

Environment

All Operating Systems

Resolution

The issue is related to an incorrect or missing type_id for concept(s) returned by the BQL query. The missing or mis-matched type_id causes the serialization issue in BE engine.

To fix the issue it is required to validate, which records in cache have an incorrect type_id.
You can validation this by connecting to the metaspace corresponding to the project, check type_id and delete corrupted records.
 
Connect to as-admin (check *_as.log for metaspacename and discoveryURL):
AS_HOME/bin/as-admin -metaspace "<metaspacename>" -discovery "<discoveryURL>"

show spaces
# now copy the Space (<spacename>) used to store the entity data from the list of spaces that you get when you execute show spaces command.

join space "<spacename>"
# check for valid typeID (return first 20 records)
show space "<spacename>" entries query_limit 20

# another option is to use a filter string with an extId/id for an entity that could be loaded
show space "<spacename>" entries filter "id=<idnumber>"

# now copy the valid typeID and validate that for that concept with an incorrect typeID (normally this filter query should always return 0 records)
eg.: typeId=1010
show space "<spacename>" entries filter "typeId__<> 1010"

# check for null
show space "<spacename>" entries filter "typeId__<> 1010"

# When above filters returns values, some data are corrupt in the Space and you have to remove them from space using below as-admin command.

eg. (typeID=1010)
clear space "<spacename>" filter "typeId__ <> 1010"
clear space "<spacename>" filter "typeId__ is null"


Note:
Use caution when executing the actions listed in this article. If not done properly they can corrupt the AS Cache. You should only delete concepts when they are not defined as reference- or contained concepts. Here some other Spaces are involved. It might be possible/required to cleanup the AS cache (depending on number of corrupted records). We recommend reaching out to TIBCO Support if you have any questions to avoid any issues.
For projects with SharedNothing as persistence policy objectTable is not used. It is required to delete the entities in objectTable space (objectTableCache-<perstype>-<clustername>--ObjectTableExtIds
objectTableCache-<perstype>-<clustername>--ObjectTableIds) as well for other persistence types (eg. SharedAll).

Additional Information

BQL, typeId