Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting nullPointerException randomly #199

Closed
arunmittal21 opened this issue May 13, 2014 · 3 comments
Closed

Getting nullPointerException randomly #199

arunmittal21 opened this issue May 13, 2014 · 3 comments

Comments

@arunmittal21
Copy link

Hello,

We are using mybatis-3.1.0. Recently we got one strange error (only once so far) from mybatis code while executing a query that gets executed successfully many times during the day.

Below is the stacktrace:

Caused by: java.lang.NullPointerException
    at org.apache.ibatis.ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:119)
    at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
    at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.ASTChain.getValueBody(ASTChain.java:109)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)
    at org.apache.ibatis.builder.xml.dynamic.OgnlCache.getValue(OgnlCache.java:42)
    at org.apache.ibatis.builder.xml.dynamic.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    at org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply(IfSqlNode.java:30)
    at org.apache.ibatis.builder.xml.dynamic.ChooseSqlNode.apply(ChooseSqlNode.java:31)
    at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:29)
    at org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:37)
    at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:241)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:71)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)

Below is the query that we are executing (from the stacktrace it appears that error is happening during - "workflowExecQue.prevWorkflowExecQueSid != null" check).

    <select id="areAllParentTasksForLabelSuccessfullOrCancelled" resultType="java.lang.Integer">


                SELECT COUNT(*) FROM #SCHEMA_NAME#.dmf_workflow_to_task_reln WTR ,#SCHEMA_NAME#.dmf_task_mstr TM
                  WHERE WTR.WORKFLOW_UNIQ_NM                             = #{workflowExecQue.dmfWorkflowMstr.workflowUniqNm}
                  AND WTR.TASK_UNIQ_NM                                   = TM.TASK_UNIQ_NM
<!--                  AND (NVL(WTR.SUCCESS_GOTO_LABLE, TM.SUCCESS_GOTO_LABLE) = #{successTaskLabel} OR NVL(WTR.CANCEL_GOTO_LABLE, TM.CANCEL_GOTO_LABLE) = #{successTaskLabel}) -->
                  AND REGEXP_LIKE (NVL(WTR.SUCCESS_GOTO_LABLE, TM.SUCCESS_GOTO_LABLE) || ';' || NVL(WTR.CANCEL_GOTO_LABLE, TM.CANCEL_GOTO_LABLE) , 
                      '^(|(.*[;,]))[ ]*' || #{successTaskLabel} || '[ ]*(([;,][ ]*.*)|)$' )
                    <if test="restrictToTaskLables != null">
                        and NVL(Wtr.Task_Lable, Nvl(Tm.Task_Lable,Tm.Task_Uniq_Nm)) IN 
                        <foreach item="item" index="index" collection="restrictToTaskLables" open="(" separator="," close=")">
                            #{item,jdbcType=VARCHAR}
                        </foreach>
                    </if>
                  AND WTR.WORKFLOW_TO_TASK_RELN_ID NOT IN (
                        SELECT  TEQ.WORKFLOW_TO_TASK_RELN_ID FROM #SCHEMA_NAME#.DMF_TASK_EXEC_QUE TEQ
                            WHERE TEQ.WORKFLOW_EXEC_QUE_SID IN (
                            <choose>
                                <when test="workflowExecQue.prevWorkflowExecQueSid != null">
                                    Select Workflow_Exec_Que_Sid From Dmf_Workflow_Exec_Que 
                                    Start With Workflow_Exec_Que_Sid = #{workflowExecQue.workflowExecQueSid}
                                    connect by Workflow_Exec_Que_Sid = prior prev_Workflow_Exec_Que_Sid 
                                </when>
                                <otherwise>
                                    #{workflowExecQue.workflowExecQueSid}
                                </otherwise>
                            </choose>
                            )AND TEQ.EXEC_STATUS IN ('SUCCESS','CANCELLED'))
<!--                            #{workflowExecQue.workflowExecQueSid}
                              <if test="workflowExecQue.prevWorkflowExecQueSid != null"> ,#{workflowExecQue.prevWorkflowExecQueSid} </if> )
 -->
    </select>

The data object that we pass has following structure

Hashmap with below keys
-workflowExecQue (object that has a property name getWorkflowExecQueSid returns bigdecimal)
-successTaskLabel (string)
-restrictToTaskLables (string)

Any help to find root cause of above error will be greatly appreciated.

@emacarron
Copy link
Member

I am afraid this one will be difficult to find.

The problem's root seems to be here (ASTProperty.java:92). It does this call

property = getProperty(context, source);

property becomes null and that causes the NPE afterwards. That variable will hold the property name, not is value. The name in this case is "prevWorkflowExecQueSid".

I cannot see any call in that logic that is calling back MyBatis so I am afraid the bug must be in OGNL.

I am afraid you will need to debug it and get detailed information. Also I would open a ticket in Apache's OGNL. Those guys know OGNL internals and may know where to look at.

@arunmittal21
Copy link
Author

Thanks emacarron,

Please let me know if you need me to do any detailed testing, however this bug is not repeatable (it has happened only once so far among 100s of execution every day)

Also, would appreciate if you could give me the link to the ticket you will open for OGNL.

Thanks again,
-Arun

@emacarron
Copy link
Member

Hi again Arun,

This bug is probably the same than #224 and will be fixed in 3.3.0.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants