Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MVEL表达式:java.lang.ClassCastException:[B不能强制转换为java.lang.Object_Java_Mvel - Fatal编程技术网

MVEL表达式:java.lang.ClassCastException:[B不能强制转换为java.lang.Object

MVEL表达式:java.lang.ClassCastException:[B不能强制转换为java.lang.Object,java,mvel,Java,Mvel,我正在编写一些MVEL表达式“$input.get('RESULT').array()[1]”where$input.get('RESULT')返回一个ByteBuffer,所以我使用array()将其转换为数组,然后尝试获取索引1的值。其中数组有16个属性 但是当Mvel执行这个表达式时,我得到 java.lang.ClassCastException: [B cannot be cast to java.lang.Object 我正在使用下面的代码 MVEL.executeExpress

我正在编写一些MVEL表达式
“$input.get('RESULT').array()[1]”
where
$input.get('RESULT')
返回一个
ByteBuffer
,所以我使用
array()
将其转换为数组,然后尝试获取索引1的值。其中数组有16个属性

但是当Mvel执行这个表达式时,我得到

 java.lang.ClassCastException: [B cannot be cast to java.lang.Object
我正在使用下面的代码

MVEL.executeExpression(statement, fieldContext.getContext(), fieldContext.getVariables());
我还写了其他的表达式,它工作得很好,我得到了字节1的这个错误

这里的任何帮助都将不胜感激

更新: 当我使用
ByteBuffer
get方法时,我得到了下面的错误,所以我想尝试一下
array

java.lang.IllegalAccessError: tried to access class java.nio.HeapByteBuffer from class ASMAccessorImpl_2330495751530608772190
    at ASMAccessorImpl_2330495751530608772190.getValue(Unknown Source)
    at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:79)
    at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)
    at org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
    at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
    at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
    at org.mvel2.MVEL.executeExpression(MVEL.java:922)`

您不必使用
array()
转换为
byte[]
,它应该足以

$input.get('RESULT').get(1)
根据方法文件:

公共抽象字节获取​(国际索引)

绝对get方法。读取给定索引处的字节


最初我使用的是get方法,但是get
java.lang.IllegalAccessError:尝试访问类java.nio.HeapByteBuffer
错误,因此认为可以尝试使用数组。请查看我的更新。我正在查找并发现使用java 6构建的Mvel api,这会导致错误吗?ByteBuffer api中是否有任何更改?不,仍然是最新版本关于。你的
IllegalAccessError
可能是由类加载器引起的,但如果没有运行的示例,就无法判断。我使用的是带spark的MVEL,因此编译发生在驱动程序上,表达式的执行发生在执行器上。这可能会导致此错误。