RunTime Retention policy java annotations doesn't work in Weblogic 12C

南笙酒味 提交于 2019-12-13 19:25:25

问题


We are planning to upgrade our product to Web-logic 12.C and WebSphere 8 stack ( Earlier it was WLC 10.3.5 and WAS 7). But issue in one of the web service component causing entire application failed to deploy in web logic. It works perfectly fine with WebSphere 8.

When deploying the EAR, Application sever throws 'Exception [EclipseLink-59] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException' . After more analysis, I found below code in one of the WebServce dependant class causing the problem,

@ExcludeAttribute
public Map getOperations(){
    Map map = new HashMap();
    //some operation
    return map;
}

@ExcludeAttribute describes Runtime retention policies, which is defined as shown below

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ExcludeAttribute {
}

getOperations method returns java.util.Map which does not work with RunTime retention annotations, but works with any other data types such as (Integer, Customer etc) . I have changed to java.uitl.HashMap and did not work.

I was able to fix this (rather I would call work around) by using following annotation,

@XmlTransient

I have no other clue why does it not working with java.uitl.Map. Any thoughts would really give thumbs up!! I have posted to Oracle support, even they have not came back yet. Is there any know issues with java.util.Map/Collection class with combination of WEblogic12c/Annotations.

[EDIT - 1]

To answer Doughan question, methods which return non collection data type does not throw any exception, for eg:

@ExcludeAttribute
public Integer getOperations(){
  return 1;
}

Where @ExcludeAttribute is custom annotation defines '@Retention(RetentionPolicy.RUNTIME)', and I do not need to define @XmlTransient to ignore.
I am bit confused to with usage of retention run time annotation , and not sure if I need to keep it or should use XMLTransient annotation.

[Edit 2 ,Based on @Doughan's answer]

I understand that we need to explicitly annotate getter methods ( as @XMLTransient) if they are not to be mapped from Weblogic 12C, and this is no way related to RuntTime Retention annotations. So any stack upgrade to 12C should update code base with this annotation if there unmapped public getter methods. I think is pretty much answers my concerns.

Correct me if I am wrong.

The existing code base already has annotated with Runtime annotation, and I thought its the one causing issue.

Detailed stack trace follows

weblogic.application.ModuleException: [HTTP:101216]Servlet: "com.chordiant.component.cxradecisions.decision.impl.internal.AssessmentDecisionInterfaceWebServiceWrapper" failed to preload on startup in Web application: "/ra".

com.sun.xml.ws.spi.db.DatabindingException: Descriptor Exceptions:

Exception [EclipseLink-59] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The instance variable [responseButtons] is not defined in the domain class [com.chordiant.dm.ra.bean.Assessment], or it is not accessible. Internal Exception: java.lang.NoSuchFieldException: responseButtons Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[responseButtons] Descriptor: XMLDescriptor(com.chordiant.dm.ra.bean.Assessment --> [])

Runtime Exceptions:

            at com.sun.xml.ws.db.toplink.JAXBContextFactory.newContext(JAXBContextFactory.java:185)
            at com.sun.xml.ws.spi.db.BindingContextFactory.create(BindingContextFactory.java:179)
            at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:211)
            at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:185)

And I have a method getResponseButtons() defined in Assessment class

@ExcludeAttribute
    public Map getResponseButtons() {
        Map map = new HashMap();

回答1:


Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

In WebLogic 12.1.1 you will need to annotate that property with @XmlTransient:

@ExcludeAttribute
public Map getOperations(){
    Map map = new HashMap();
    //some operation
    return map;
}

@ExcludeAttribute is custom annotation created by us, which uses @Retention(RetentionPolicy.RUNTIME), ( I have provided snippet of this annotation)

Custom annotations do not affect how MOXy produces its mapping metadata. There is no way that it could, just because the annotation is called @ExcludeAttribute MOXy couldn't assume it should be treated like @XmlTransient.

But issue in one of the web service component causing entire application failed to deploy in web logic. It works perfectly fine with WebSphere 8.

EclipseLink MOXy is the default JAXB provider in WebLogic as of version 12.1.1. You may be hitting an issue where previously MOXy treated all properties with only a getmethod as write only properties. New versions of MOXy will ignore these properties unless they are explicitly annotated. This may have caused it to appear to you that the @ExcludeAttribute annotation was having an effect.

I am bit confused to with usage of retention run time annotation

This setting is related to whether or not you can access this annotation via reflection at runtime. Are you creating your own annotation for your own purposes?

When deploying the EAR, Application sever throws 'Exception [EclipseLink-59] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException'

If the contents of that property are meant to be mapped could you share the complete stack trace?



来源:https://stackoverflow.com/questions/16932858/runtime-retention-policy-java-annotations-doesnt-work-in-weblogic-12c

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