jaxws and EclipseLink refuses to use enums from lib

五迷三道 提交于 2020-01-05 14:04:09

问题


I have a maven multimodule project with a ejb with a webservice, a lib, and a batch app. The batch app and the ejb module shares some enums, which then is located in the lib module. When attempting to return one of these enums from the lib in a webservice method it claims that there are no valid ejbs in the ejb jar file. Also, when using another one of these enums as attributes in an JPA entity using @Enumerated(EnumType.STRING) I get an error saying

"...is not a valid type for an enumerated mapping. The attribute must be defined as a Java enum."

I am simply wondering why using these enums in this way is a problem? Are there any workarounds besides declaring them twice?


回答1:


I ran into the same problem, and it was because I was testing with Arquillian and for some reason I had forgotten to add the package containing the actual enum in the shrinkwrap.

So maybe there is something preventing the persistence provider (eclipselink in my case) from seeing your enum class. That's what I would bet is happening in your case, because you have multiple modules.




回答2:


I had the same problem with a project i was working on. I have a common bundle which holds the general interfaces (and enums) which the persistence bundle did not recognise. As a result, I got the above exception (even though the persistence bundle had dependencies to the common bundle through the imported packages.

I solved this problem by including the common bundle in the Java build path of the persistence bundle:

project -> project properties -> Java build path / Projects ;//add the bundle that contains the enums here



来源:https://stackoverflow.com/questions/6101727/jaxws-and-eclipselink-refuses-to-use-enums-from-lib

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