开发者

Class cast exception on stateful ejb

开发者 https://www.devze.com 2023-02-09 19:01 出处:网络
For some strange reason I am getting the following exception. 2011-02-08 09:53:30,667 ERROR [STDERR] (QuartzScheduler_Worker-9) java.lang.ClassCastException: org.javassist.tmp.java.lang.Object_$$_jav

For some strange reason I am getting the following exception.

2011-02-08 09:53:30,667 ERROR [STDERR] (QuartzScheduler_Worker-9) java.lang.ClassCastException: org.javassist.tmp.java.lang.Object_$$_javassist_seam_7 cannot be cast to no.kommuneforlaget.fagsystem.saksapp.service.report.SystemlogListener
2011-02-08 09:53:30,668 ERROR [STDERR] (QuartzScheduler_Worker-9)       at no.kommuneforlaget.fagsystem.saksap开发者_运维知识库p.jobs.ESBLogListener.checkESBEvents(ESBLogListener.java:71)
2011-02-08 09:53:30,668 ERROR [STDERR] (QuartzScheduler_Worker-9)       at no.kommuneforlaget.fagsystem.saksapp.jobs.ESBLogListener.scheduler(ESBLogListener.java:119)
2011-02-08 09:53:30,668 ERROR [STDERR] (QuartzScheduler_Worker-9)       at sun.reflect.GeneratedMethodAccessor466.invoke(Unknown Source)
2011-02-08 09:53:30,668 ERROR [STDERR] (QuartzScheduler_Worker-9)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2

I know it shouldn't be a class cast exception because its the correct class.

The code is:

SystemlogListener systemlogListener = (SystemlogListener) Component.getInstance("systemlogListener", ScopeType.SESSION, true);

And the class is

@Name("systemlogListener")
@Scope(ScopeType.SESSION)
@AutoCreate
@Stateful
@TransactionManagement(TransactionManagementType.CONTAINER) //default
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public class SystemlogListener implements SystemlogListenerLocal, Serializable {

Can anyone spot the mistake I have made?


I assume that Component.getInstance(...) returning an injected class. The Implementation that is injected does not have to be of the class of your implementation but only of your Local/Remote interface. So you could cast to your interface SystemlogListenerLocal but not to your implementation SystemlogListener.

The reason is the implementation of your AppServer which could use e.g. a proxy and delegates the methods to your real implementation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号