如何使EclipseLink MOXy忽略AspectJ字段?

时间:2015-12-25 18:09:44

标签: eclipselink aspectj moxy

如何使仅字节码字段为@XmlTransient?

当一个类由AspectJ编织时,其字节码(但其源代码)会收到一个额外注入的静态字段:

private static final org.aspectj.lang.JoinPoint$StaticPart ajc$tjp_0;

MOXy不会将此额外字段视为XmlTransient,并在尝试创建JAXBContext时导致异常:

Caused by: javax.xml.bind.JAXBException: 
Exception Description: The class org.aspectj.runtime.reflect.JoinPointImpl$StaticPartImpl requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.
- with linked exception:
[Exception [EclipseLink-50001] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The class org.aspectj.runtime.reflect.JoinPointImpl$StaticPartImpl requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.]

可能的解决方案

根据EclipseLink MOXy example,似乎我应该能够通过创建一个名为@XmlTransient的文件来创建此字段eclipselink-oxm.xml,并将该文件放在目录中src/main/resources/META-INF。但是,这不起作用。

我该怎么办?

的EclipseLink-oxm.xml

<?xml version="1.0"?>
   <xml-bindings
        xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        version="${eclipselink.version}">
      <java-types>
        <java-type name="se.mithlond.services.organisation.model.address.CategorizedAddress">
            <java-attributes>
                <xml-transient java-attribute="ajc$tjp_0"/>
            </java-attributes>
        </java-type>
        <!--java-type name="org.aspectj.runtime.reflect.JoinPointImpl$StaticPartImpl" xml-transient="true" />
        <java-type name="org.aspectj.runtime.reflect.JoinPointImpl" xml-transient="true" / -->
      </java-types>
   </xml-bindings>

0 个答案:

没有答案