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吗?

更多相关文章

  1. spring框架中一个跟String的trim方法一样的方法
  2. 当只使用get()和set()方法时,用原始类型替换AtomicBoolean?
  3. 理顺 JavaScript (12) - 一个比较实用的数组用法
  4. java中循环遍历删除List和Set集合中元素的方法
  5. 80端口占用异常解决方法java.net.BindException: Address alread
  6. java写入文件的几种方法小结
  7. OOP面向对象编程(一)-------方法的重载
  8. Java之美[从菜鸟到高手演变]之Java学习方法
  9. vue、react等单页面项目部署到服务器的方法及vue和react的区别

随机推荐

  1. 不就是用Python做个动态图吗?看招
  2. 动画:用动画技巧记忆常见笔试 JS 类型转换
  3. 1024 小鹿自费给读者送书啦!
  4. COVID-19每日数据|04-09
  5. 【决战西二旗】|理解标准模板库STL(一)
  6. 我常用的10个Python实用小Trick
  7. 图解:什么是 JS 原型和原型链?
  8. Pandas进阶修炼120题同步视频现已登陆
  9. 【决战西二旗】|你真的懂快速排序?
  10. 词云图的几种制作方法评测,你pick哪款