Missing NamedQueries annotation in WAS Liberty env

2019-08-26 03:30发布

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

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:

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

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.

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

1条回答
ら.Afraid
2楼-- · 2019-08-26 04:08

It took some time, but I found the solution.

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

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

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.

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

查看更多
登录 后发表回答