jaxws and EclipseLink refuses to use enums from li

2019-08-03 22:48发布

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?

标签: jpa enums jax-ws
2条回答
Explosion°爆炸
2楼-- · 2019-08-03 23:11

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

查看更多
再贱就再见
3楼-- · 2019-08-03 23:12

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.

查看更多
登录 后发表回答