本文介绍了WAS Liberty环境中缺少NamedQueries注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Java 7下使用WAS Liberty 8.5.5.5(也在Oracle Java 7-8和IBM Java 7下进行了尝试.

I'm using WAS Liberty 8.5.5.5 under Java 7 (tried under Oracle java 7-8 and IBM java 7 as well).

当我创建一个NamedQuery时,代码可以编译,部署和正常运行.但是,如果尝试使用NamedQueries批注,则会得到以下专有名词:

When I create one NamedQuery, the code compiles, deployes, and runs fine.However, If I try to use the NamedQueries annotation I get the following excpetion:

java.lang.ArrayStoreException: com.sun.proxy.$Proxy29
                  at sun.reflect.annotation.AnnotationParser.parseAnnotationArray(AnnotationParser.java:765)
                  at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:537)
                  at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
                  at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
                  at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
                  at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
                  at java.lang.Class.createAnnotationData(Class.java:3521)
                  at java.lang.Class.annotationData(Class.java:3510)
                  at java.lang.Class.getAnnotation(Class.java:3415)

经过一番调查,我发现了以下两个错误:

After some investigation, I found the following two bugs:

ArrayStoreException,当注释声明缺少类时: http://bugs.java .com/view_bug.do?bug_id = 7183985

ArrayStoreException when annotation declaring class missing: http://bugs.java.com/view_bug.do?bug_id=7183985

环境中似乎缺少javax.persistence.NamedQueries接口(通常存在javax.persinstence.NameQuery ...)

It seems that the javax.persistence.NamedQueries inteface is missing in the enviroment (stangely the javax.persinstence.NameQuery is present ...)

我使用Eclipse Kepler进行开发,部署也由IDE处理.在更多的事情上;其他使用相同代码库的开发人员可以使用适当的设置成功部署和运行该应用程序-因此,我怀疑部署可能是造成此问题的原因.

I use Eclipse Kepler for development, the deployment is also handled by the IDE.On more thing; other developers using the same code base can successfully deploy and run the application with the afformentioned settings - so I suspect the deployment might be responsible for this issue.

是否可以告诉" WAS以包括缺少的类运行时?

Is there a way to "tell" the WAS to include the missing class runtime?

推荐答案

花了一些时间,但我找到了解决方法.

It took some time, but I found the solution.

我们将Ecliselink用作JPA提供程序,并相应地加载它:

We are using Ecliselink as a JPA provider, and load it accordingly:

<classloader commonLibraryRef="EclipseLinkLib" delegation="parentLast"/>

似乎Eclipselink(版本2.5.2)包含javax.persistence.NamedQuery接口,但不包含javax.persistence.NamedQueries接口-这样,WAS不会加载缺少的接口.

It seems that Eclipselink (version 2.5.2) contains the javax.persistence.NamedQuery interface, but not the javax.persistence.NamedQueries interface - this way WAS does not load the missing interface.

通过更改delegation="parentFirst",该应用可以正常运行.

By changing delegation="parentFirst" the app works fine.

这篇关于WAS Liberty环境中缺少NamedQueries注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 14:08