java - IllegalAnnotationExceptions There's no ObjectFactory with an @XmlElementDecl for the element -
i got following error while running project on command prompt
java com.javavids.jaxb.sitemap.main.main
i got following error
exception in thread "main" com.sun.xml.internal.bind.v2.runtime.illegalannotationsexception: 1 counts of illegalannotationexceptions there's no objectfactory @xmlelementdecl element {unison}fromtime. problem related following location: @ protected java.util.list com.javavids.jaxb.sitemap.upm.test.dateorstartdateorenddate @ com.javavids.jaxb.sitemap.upm.test @ protected java.util.list com.javavids.jaxb.sitemap.upm.condition.content @ com.javavids.jaxb.sitemap.upm.condition @ protected com.javavids.jaxb.sitemap.upm.condition com.javavids.jaxb.sitemap.upm.rule.condition @ com.javavids.jaxb.sitemap.upm.rule @ protected java.util.list com.javavids.jaxb.sitemap.upm.policy.rule @ com.javavids.jaxb.sitemap.upm.policy @ protected java.util.list com.javavids.jaxb.sitemap.upm.configuration.policyorconditionoractionlist @ com.javavids.jaxb.sitemap.upm.configuration @ protected com.javavids.jaxb.sitemap.upm.configuration com.javavids.jaxb.sitemap.upm.bmwebgateconf.configuration @ com.sun.xml.internal.bind.v2.runtime.illegalannotationsexception$builder.check(unknown source) @ com.sun.xml.internal.bind.v2.runtime.jaxbcontextimpl.gettypeinfoset(unknown source) @ com.sun.xml.internal.bind.v2.runtime.jaxbcontextimpl.<init>(unknown source) @ com.sun.xml.internal.bind.v2.runtime.jaxbcontextimpl.<init>(unknown source) @ com.sun.xml.internal.bind.v2.runtime.jaxbcontextimpl$jaxbcontextbuilder.build(unknown source) @ com.sun.xml.internal.bind.v2.contextfactory.createcontext(unknown source) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ javax.xml.bind.contextfinder.newinstance(unknown source) @ javax.xml.bind.contextfinder.newinstance(unknown source) @ javax.xml.bind.contextfinder.find(unknown source) @ javax.xml.bind.jaxbcontext.newinstance(unknown source) @ javax.xml.bind.jaxbcontext.newinstance(unknown source) @ com.javavids.jaxb.sitemap.main.main.main(main.java:55)
source: com/javavids/jaxb/sitemap/upm/test.java
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "", proporder = { "conditionref", "attribute", "op", "dateorstartdateorenddate", "listref", "value" }) @xmlrootelement(name = "test") public class test { @xmlelement(name = "conditionref") protected string conditionref; @xmlelement(name = "attribute") protected string attribute; @xmlelement(name = "op") protected string op; @xmlelementrefs({ @xmlelementref(name = "fromtime", namespace = "unison", type = jaxbelement.class, required = false), @xmlelementref(name = "date", namespace = "unison", type = jaxbelement.class, required = false), @xmlelementref(name = "durationindays", namespace = "unison", type = jaxbelement.class, required = false), @xmlelementref(name = "enddate", namespace = "unison", type = jaxbelement.class, required = false), @xmlelementref(name = "startdate", namespace = "unison", type = jaxbelement.class, required = false), @xmlelementref(name = "totime", namespace = "unison", type = jaxbelement.class, required = false), @xmlelementref(name = "weekday", namespace = "unison", type = jaxbelement.class, required = false), @xmlelementref(name = "frequency", namespace = "unison", type = jaxbelement.class, required = false) }) protected list<jaxbelement<? extends serializable>> dateorstartdateorenddate; @xmlelement(name = "listref") protected string listref; @xmlelement(name = "value") protected string value; @xmlattribute(name = "type", required = true) protected string type; public list<jaxbelement<? extends serializable>> getdateorstartdateorenddate() { if (dateorstartdateorenddate == null) { dateorstartdateorenddate = new arraylist<jaxbelement<? extends serializable>>(); } return this.dateorstartdateorenddate; }
source: com/javavids/jaxb/sitemap/upm/objectfactory.java
@xmlregistry public class objectfactory { private final static qname _startdate_qname = new qname("unison", "startdate"); private final static qname _date_qname = new qname("unison", "date"); private final static qname _totime_qname = new qname("unison", "totime"); private final static qname _createtime_qname = new qname("unison", "createtime"); private final static qname _enddate_qname = new qname("unison", "enddate"); private final static qname _fromtime_qname = new qname("unison", "fromtime"); private final static qname _durationindays_qname = new qname("unison", "durationindays"); private final static qname _importtime_qname = new qname("unison", "importtime"); private final static qname _frequency_qname = new qname("unison", "frequency"); private final static qname _weekday_qname = new qname("unison", "weekday"); @xmlelementdecl(namespace = "unison", name = "startdate") public jaxbelement<string> createstartdate(string value) { return new jaxbelement<string>(_startdate_qname, string.class, null, value); } @xmlelementdecl(namespace = "unison", name = "fromtime") public jaxbelement<string> createfromtime(string value) { return new jaxbelement<string>(_fromtime_qname, string.class, null, value); }
source: com/javavids/jaxb/sitemap/main/main.java
public static void main(string[] args) throws jaxbexception { file file = new file("c:\\users\\t_pavans\\workspace\\jaxbtest1\\medialossy.xml"); jaxbcontext jaxbcontext = jaxbcontext.newinstance(com.javavids.jaxb.sitemap.upm.bmwebgateconf.class); unmarshaller jaxbunmarshaller = jaxbcontext.createunmarshaller(); //bmwebgate root element variables bmw = (bmwebgateconf) jaxbunmarshaller.unmarshal(file);
note: code work fine on eclipse. when try run on command prompt, throws , exception
when create jaxbcontext
classes need include objectfactory
class in classes passed in create jaxbcontext
.
jaxbcontext jaxbcontext = jaxbcontext.newinstance(bmwebgateconf.class, objectfactory.class);
if model generated xml schema recommend creating jaxbcontext
on package name:
jaxbcontext jaxbcontext = jaxbcontext.newinstance("com.javavids.jaxb.sitemap");
Comments
Post a Comment