. lang。ClassCastException:[Ljava.lang.Object;不能被投射到[lblnditmmthd]
I need a serious help in this issue. May be its very basic, but, I am not able to figure it out. I have a session EJB with one method which returns an enum array, i.e. BlndItmTmMthd
array. When, I call the method in the client side, it gives me a ClassCastException
.
在这个问题上我需要认真的帮助。这可能是最基本的,但我不知道。我有一个会话EJB,其中有一个方法返回enum数组,即blnditmmthd数组。当我在客户端调用方法时,它会给我一个ClassCastException。
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [LBlndItmTmMthd
While debugging, I have found that the ejb method is correctly returning BlndItmTmMthd
array by calling BlndItmTmMthd.values()
. I am not able to find out the reason. Any idea will be helpful.
在调试过程中,我发现ejb方法通过调用BlndItmTmMthd.values()来正确地返回BlndItmTmMthd数组。我找不到原因。任何想法都是有用的。
Added content from a comment below
AgreementSession.java is the EJB interface which contains the following method declaration:
添加内容从评论下面的协议会话。java是EJB接口,包含以下方法声明:
BlndItmTmMthd[] getAllBlendedItemTimingMethods();
AgreementSessionEJB.java is the EJB that implements it.
AgreementSessionEJB。java是实现它的EJB。
public BlndItmTmMthd[] getAllBlendedItemTimingMethods() {
BlndItmTmMthd[] blendedItemTmingMethods = BlndItmTmMthd.values();
return blendedItemTmingMethods;
}
Now, at the client side, when I invoke the EJB method with the following code:
现在,在客户端,当我使用以下代码调用EJB方法时:
BlndItmTmMthd[] _timingMethods =
getLoanScheduleSetupSession().getAllBlendedItemTimingMethods();
I get that runtime exception.
我得到了运行时异常。
3 个解决方案
#1
1
The "[L" in your error tells you the problem - Java is failing to cast an array of Objects (that is, an Object[]) to an array of BlndItmTmMthds (a BlndItmTmMthd[]).
错误中的“L”告诉您问题所在——Java没有将对象数组(即对象[])转换为blnditmmthds数组(blnditmmthd[])。
Is BlndItmTmMthd really a java.lang.Enum?
blnditmmthd真的是java.lang.Enum吗?
更多相关文章
- spring框架中一个跟String的trim方法一样的方法
- 当只使用get()和set()方法时,用原始类型替换AtomicBoolean?
- 理顺 JavaScript (12) - 一个比较实用的数组用法
- java中循环遍历删除List和Set集合中元素的方法
- 80端口占用异常解决方法java.net.BindException: Address alread
- java写入文件的几种方法小结
- OOP面向对象编程(一)-------方法的重载
- Java之美[从菜鸟到高手演变]之Java学习方法
- vue、react等单页面项目部署到服务器的方法及vue和react的区别