Up vote 3 down vote favorite share g+ share fb share tw.
The situation I'm using EclipseLink's MOXy and I'm trying to use the external OX mapping XML with classes that implement the Map interface. However, every time I try create a JAXBContext, I get the following NPE: Caused by: javax.xml.bind. JAXBException - with linked exception: java.lang.
NullPointerException at org.eclipse.persistence.jaxb. JAXBContext$TypeMappingInfoInput. CreateContextState(JAXBContext.
Java:832) at org.eclipse.persistence.jaxb.JAXBContext.(JAXBContext. Java:143) at org.eclipse.persistence.jaxb. JAXBContextFactory.
CreateContext(JAXBContextFactory. Java:142) at org.eclipse.persistence.jaxb. JAXBContextFactory.
CreateContext(JAXBContextFactory. Java:129) at org.eclipse.persistence.jaxb. JAXBContextFactory.
CreateContext(JAXBContextFactory. Java:93) at org.eclipse.persistence.jaxb. JAXBContextFactory.
CreateContext(JAXBContextFactory. Java:83) at javax.xml.bind.ContextFinder. NewInstance(ContextFinder.
Java:210) at javax.xml.bind.ContextFinder. Find(ContextFinder. Java:336) at javax.xml.bind.JAXBContext.
NewInstance(JAXBContext. Java:574) at com.example. MOXyOXTest(MOXyOXTest.
Java:59) Caused by: java.lang. NullPointerException at org.eclipse.persistence.jaxb.compiler.XMLProcessor. ProcessXML(XMLProcessor.
Java:202) at org.eclipse.persistence.jaxb.compiler.Generator.(Generator. Java:145) at org.eclipse.persistence.jaxb. JAXBContext$TypeMappingInfoInput.
CreateContextState(JAXBContext. Java:829) Details This problem only occurs if the class being mapped extends the java.util. Map interface.
If the class I'm mapping does not extend that interface, everything works fine. Here's a simplified example of a class I'm trying to map: package com. Example; import java.util.
Map; // This class just wraps a java.util. HashMap import com.xetus.lib.type. DelegatedMap; public class SampleClassA extends DelegatedMap{ public SampleClassA(){ super(); } public SampleClassA(Map m){ super(m); } public void setSomeProperty(String value){ put("somevalue", value); } public String getSomeProperty(){ return (String) get("somevalue"); } } Here is a simplified sample of the MOXy OX meta data I'd like to use: Here is how I'm creating my JAXBContext Map props = new HashMap(1); List bindings = new ArrayList(1); bindings.
Add(new StreamSource(MOXyOXTest.class. GetResourceAsStream("test-mappings. Xml"))); props.
Put(JAXBContextFactory. ECLIPSELINK_OXM_XML_KEY, bindings); cntxt = JAXBContext. NewInstance(new Class { SampleClassA.
Class }, props); I'm using EclipseLink version 2.3.2, in case that's important. I've also tried with version 2.2.1 with the same results. My Question This the first time I've tried to use JAXB on a class that extends the java.util.
Map interface and I'm curious if I'm missing something fundamental. I don't expect the OX Mappings to work with the Map's name/value pairs, but instead with the custom getters and setters added to the class. Is a configuration like this supposed to work?
Additional Details The DelegatedMap used in the sample code does not extend java.util. HashMap, it just wraps an instance of one and implements the Map interface. Also, that class is annotated with @XmlAccessorType(XmlAccessType.
NONE). I get the same error regardless of which abstract class that implements the Map interface I use for SampleClassA. If SampleClassA extends a class that does not implement a map, everything behaves correctly.
The code base I'm working with requires many of the classes to implement the Map interface. Java map jaxb moxy link|improve this question edited 1 hour ago asked 6 hours agoTerence5314.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.