Java 在访问器(getter)方法上使用transformer时发生异常

Java 在访问器(getter)方法上使用transformer时发生异常,java,eclipselink,moxy,Java,Eclipselink,Moxy,我正在尝试使用自定义转换器为此SupplierOrderCharge对象创建某种聚合,在该对象中汇总列表中的所有值 如果删除transformer注释,下面列出的异常将消失。 这是有效的配置吗?我可以为这样的getter方法设置一个转换器吗?或者可能是莫西的一只虫子 这是我的代码: @XmlElement @XmlTransformation @XmlReadTransformer(transformerClass = GeneralAttributeMarkerTransformer.clas

我正在尝试使用自定义转换器为此SupplierOrderCharge对象创建某种聚合,在该对象中汇总列表中的所有值

如果删除transformer注释,下面列出的异常将消失。 这是有效的配置吗?我可以为这样的getter方法设置一个转换器吗?或者可能是莫西的一只虫子

这是我的代码:

@XmlElement
@XmlTransformation
@XmlReadTransformer(transformerClass = GeneralAttributeMarkerTransformer.class)
@XmlWriteTransformers({ @XmlWriteTransformer(xmlPath = "ORDER_HEADER/SHIPPING_INFO/SHIPMENT_CODE/text()", transformerClass = ShippingInfoTransformer.class),
@XmlWriteTransformer(xmlPath = "ORDER_HEADER/SHIPPING_INFO/SHIPPING_COST_EX_VAT/text()", transformerClass = ShippingInfoTransformer.class),
@XmlWriteTransformer(xmlPath = "ORDER_HEADER/SHIPPING_INFO/SHIPPING_COST_VAT/text()", transformerClass = ShippingInfoTransformer.class),
@XmlWriteTransformer(xmlPath = "ORDER_HEADER/SHIPPING_INFO/SHIPPING_COST_INC_VAT/text()", transformerClass = ShippingInfoTransformer.class), })
@Transient
protected SupplierOrderCharge getShippingInfo() {
    for (final SupplierOrderCharge soCharge : getOrderCharges()) {
        if (EntryType.SHIPPING.equals(soCharge.getEntryType())) {
            return soCharge;
        }
    }
    return null;
}
我得到一个例外:

javax.xml.bind.JAXBException: 
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [] or [getShippingInfo] is not defined in the object [com.debijenkorf.data.model.supplier.SupplierOrder].
Internal Exception: java.lang.NoSuchMethodException: com.debijenkorf.data.model.supplier.SupplierOrder.(com.debijenkorf.data.model.supplier.SupplierOrderCharge)
Mapping: org.eclipse.persistence.oxm.mappings.XMLTransformationMapping[shippingInfo]
Descriptor: XMLDescriptor(com.debijenkorf.data.model.supplier.SupplierOrder --> [DatabaseTable(SALES_ORDER)])

Runtime Exceptions: 
---------------------------------------------------------

java.lang.NullPointerException

- with linked exception:
[Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [] or [getShippingInfo] is not defined in the object [com.debijenkorf.data.model.supplier.SupplierOrder].
Internal Exception: java.lang.NoSuchMethodException: com.debijenkorf.data.model.supplier.SupplierOrder.(com.debijenkorf.data.model.supplier.SupplierOrderCharge)
Mapping: org.eclipse.persistence.oxm.mappings.XMLTransformationMapping[shippingInfo]
Descriptor: XMLDescriptor(com.debijenkorf.data.model.supplier.SupplierOrder --> [DatabaseTable(SALES_ORDER)])

Runtime Exceptions: 
---------------------------------------------------------

java.lang.NullPointerException
]
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:771)
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:711)
at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:157)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:128)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:249)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
at com.debijenkorf.services.core.JaxbMoxyMarUn.marshal(JaxbMoxyMarUn.java:48)
at com.debijenkorf.services.fc4.JaxbMarUnFC1Test.testMarshal(JaxbMarUnFC1Test.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [] or [getShippingInfo] is not defined in the object [com.debijenkorf.data.model.supplier.SupplierOrder].
Internal Exception: java.lang.NoSuchMethodException: com.debijenkorf.data.model.supplier.SupplierOrder.(com.debijenkorf.data.model.supplier.SupplierOrderCharge)
Mapping: org.eclipse.persistence.oxm.mappings.XMLTransformationMapping[shippingInfo]
Descriptor: XMLDescriptor(com.debijenkorf.data.model.supplier.SupplierOrder --> [DatabaseTable(SALES_ORDER)])

Runtime Exceptions: 
---------------------------------------------------------

java.lang.NullPointerException

at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:638)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:574)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:533)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:777)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:735)
at org.eclipse.persistence.oxm.XMLContext$XMLContextState.<init>(XMLContext.java:857)
at org.eclipse.persistence.oxm.XMLContext$XMLContextState.<init>(XMLContext.java:832)
at org.eclipse.persistence.oxm.XMLContext.<init>(XMLContext.java:193)
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:797)
at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:769)
... 37 more
javax.xml.bind.JAXBException:
描述符异常:
---------------------------------------------------------
异常[EclipseLink-60](Eclipse持久性服务-2.4.0.v20120608-r11652):org.Eclipse.Persistence.exceptions.DescriptorException
异常说明:对象[com.debijenkorf.data.model.supplier.SupplierOrder]中未定义方法[]或[getShippingInfo]。
内部异常:java.lang.NoSuchMethodException:com.debijenkorf.data.model.supplier.SupplierOrder。(com.debijenkorf.data.model.supplier.SupplierOrderCharge)
映射:org.eclipse.persistence.oxm.mappings.XMLTransformationMapping[shippingInfo]
描述符:XMLDescriptor(com.debijenkorf.data.model.supplier.SupplierOrder-->[数据库表(销售订单)])
运行时异常:
---------------------------------------------------------
java.lang.NullPointerException
-除此之外:
[异常[EclipseLink-0](Eclipse持久性服务-2.4.0.v20120608-r11652):org.Eclipse.Persistence.exceptions.IntegrityException
描述符异常:
---------------------------------------------------------
异常[EclipseLink-60](Eclipse持久性服务-2.4.0.v20120608-r11652):org.Eclipse.Persistence.exceptions.DescriptorException
异常说明:对象[com.debijenkorf.data.model.supplier.SupplierOrder]中未定义方法[]或[getShippingInfo]。
内部异常:java.lang.NoSuchMethodException:com.debijenkorf.data.model.supplier.SupplierOrder。(com.debijenkorf.data.model.supplier.SupplierOrderCharge)
映射:org.eclipse.persistence.oxm.mappings.XMLTransformationMapping[shippingInfo]
描述符:XMLDescriptor(com.debijenkorf.data.model.supplier.SupplierOrder-->[数据库表(销售订单)])
运行时异常:
---------------------------------------------------------
java.lang.NullPointerException
]
位于org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:771)
位于org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:711)
位于org.eclipse.persistence.jaxb.JAXBContext.(JAXBContext.java:157)
位于org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:134)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
位于javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:128)
位于javax.xml.bind.ContextFinder.find(ContextFinder.java:249)
位于javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
位于javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
位于javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
位于com.debijenkorf.services.core.JaxbMoxyMarUn.marshal(JaxbMoxyMarUn.java:48)
位于com.debijenkorf.services.fc4.JaxbMarUnFC1Test.testmarshall(JaxbMarUnFC1Test.java:36)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
位于org.junit.runners.model.FrameworkMethod$1.runReflectVeCall(FrameworkMethod.java:44)
位于org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
位于org.junit.runners.model.FrameworkMethod.invokeeexplosive(FrameworkMethod.java:41)
位于org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
位于org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
位于org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
位于org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
位于org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
位于org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
位于org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
访问org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
位于org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
位于org.junit.runners.ParentRunner.run(ParentRunner.java:292)
位于org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
位于org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
原因:异常[EclipseLink-0](Eclipse持久性服务-2.4.0.v20120608-r11652):org.Eclipse.Persistence.exceptions.IntegrityException
描述符异常:
---------------------------------------------------------
异常[EclipseLink-60](Eclipse持久性服务-2.4.0.v20120608-r11652):org.Eclipse.Persistence.exceptions.DescriptorException
异常说明:对象[com.debijenkorf.data.model.supplier.SupplierOrder]中未定义方法[]或[getShippingInfo]。
内部异常:java.lang.NoSuchMethodException:com.debijenkorf.data.model.supplier.SupplierOrder。(com.debijenkorf.data.model.supplier.SupplierOrderCharge)
映射:org.eclipse.persistence.oxm.mappings.XMLTransformationMapping[