Getting java.lang.ClassCastException: [Ljava.lang.Object; cannot be applied to [LBlndItmTmMthd

I need serious help in this matter. It may be very simple, but I cannot understand it. I have an EJB session with one method that returns an array of enums, i.e. Array BlndItmTmMthd. When I call a client-side method, it gives me ClassCastException.

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [LBlndItmTmMthd

During debugging, I found that the ejb method correctly returns an array BlndItmTmMthdby calling BlndItmTmMthd.values(). I can’t find out the reason. Any idea would be helpful.

Added content from the comment below
InterfaceSession.java is an EJB interface that contains the following method declaration:

BlndItmTmMthd[] getAllBlendedItemTimingMethods(); 

SessionEJB.java is an EJB that implements it.

public BlndItmTmMthd[] getAllBlendedItemTimingMethods() { 
    BlndItmTmMthd[] blendedItemTmingMethods = BlndItmTmMthd.values(); 
    return blendedItemTmingMethods; 
}

, , EJB :

BlndItmTmMthd[] _timingMethods = 
             getLoanScheduleSetupSession().getAllBlendedItemTimingMethods(); 

.

+3
3

"[L" - Java ( []) BlndItmTmMthds (BlndItmTmMthd []).

BlndItmTmMthd java.lang.Enum?

+1

, , java.lang.Object Enum, , , EJB .

, :

  • Enum BlndItmTmMthd ?
  • EJB Enum java.lang.Object?
0

I assume that you have access to the server and client code. To track this issue, you must insert entries for the form log

logger.info(array.getClass().getCanonicalName());

in all places on the way from BlndItmTmMthdto Object. Then you can at least say at what point the conversion will happen.

0
source

Source: https://habr.com/ru/post/1755523/


All Articles