Java: Enum : NoClassDefFoundError

被刻印的时光 ゝ 提交于 2019-12-04 03:20:45

I have a project configuration quite similar to yours: eclipse, Maven, JDK 1.6, JBoss EAP6.2, and I have the same problem with a java.lang.NoClassDefFoundError when using an enum in a switch case.

I have found a workaround for it: generate an ear file (it is a war in my case) and install it manually from the JBoss administration console. I noticed the war includes the $1 needed classes and then you won't get the exception.

This is just a workaround, but it works for me. A good point of this workaround is that subsequent deployments done through eclipse work!

I will be listening to the answers to your question because I want a real solution.

I ran into a similar issue, and the easy workaround was to define the Enum as public instead of private.

(Didn't have time to verify, but my hunch is that this causes the class to not be created as Name$1.class but rather something like Name$Enumname.class, which seemed to be the problem)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!