简体   繁体   中英

Java Wildfly javax.ejb.EJBException

I am working on project using java and wildfly 10. I have problem when I try to make rest request. I can not figure out where is the real problem. Here is a project source code: https://github.com/alien93/at and here is error from consele https://gist.github.com/MiselAdemi/f5876f6f4b2b6dffcfcf6598cd3ce903

Can somebody help me, or even just to give me some hint?

Relevant part of the stacktrace is:

Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to session.HostsList
at session.HostBean.register(HostBean.java:71)

When we take a look to the row 71 in HostBean.java, we will find following:

return (HostsList) Host.hosts;

As stacktrace says, Host.hosts is not a HostList . Also it cannot be because type of of hosts is something that implements java.util.List, in this case runtime type is ArrayList:

public transient static List<Host> hosts = new ArrayList<Host>();

HostList can be constructed and then returned as follows (in line 71 in HostBean.java):

HostsList hl = new HostList();
hl.setHosts(host.hosts);
return hosts;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM