jaxws和EclipseLink拒绝使用lib中的枚举 [英] jaxws and EclipseLink refuses to use enums from lib

查看:145
本文介绍了jaxws和EclipseLink拒绝使用lib中的枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个maven多模块项目,一个带有web服务,一个lib和一个批处理应用程序的ejb。批处理应用程序和ejb模块共享一些枚举,然后它们位于lib模块中。当尝试在webservice方法中从lib中返回其中一个枚举时,它声明ejb jar文件中没有有效的ejb。此外,当使用另一个这些枚举作为JPA实体中的属性使用 @Enumerated(EnumType.STRING)时,我收到一条错误,说



...不是枚举映射的有效类型,该属性必须定义为Java枚举。



我只是想知道为什么以这种方式使用这些枚举是个问题?除了两次声明之外,是否有任何解决方法?

解决方案

我与我正在开展的项目有同样的问题。我有一个通用的bundle,它保存持久性bundle不能识别的一般接口(和枚举)。因此,我得到了上述异常(即使持久性包通过导入的包依赖于通用包。



我通过包含常见的包来解决这个问题在持久性包的Java构建路径中:



项目 - >项目属性 - > Java构建路径/项目; //添加包含枚举的包


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?

解决方案

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

这篇关于jaxws和EclipseLink拒绝使用lib中的枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆