Nfe XML Parser for Object

Asked

Viewed 700 times

0

I am trying to parse an Nfe XML parser for the Tnfeproc object, and I always get the error:

java.lang.IllegalArgumentException: can't parse argument number: {0}
at java.text.MessageFormat.makeFormat(MessageFormat.java:1429)
at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
at java.text.MessageFormat.<init>(MessageFormat.java:362)
at java.text.MessageFormat.format(MessageFormat.java:840)
at com.sun.xml.internal.bind.v2.model.impl.Messages.format(Messages.java:117)
at com.sun.xml.internal.bind.v2.model.impl.ReferencePropertyInfoImpl.calcTypes(ReferencePropertyInfoImpl.java:171)
at com.sun.xml.internal.bind.v2.model.impl.ReferencePropertyInfoImpl.link(ReferencePropertyInfoImpl.java:372)
at com.sun.xml.internal.bind.v2.model.impl.ClassInfoImpl.link(ClassInfoImpl.java:1257)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl.link(RuntimeClassInfoImpl.java:182)
at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.link(ModelBuilder.java:439)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.link(RuntimeModelBuilder.java:118)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:443)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at br.indie.parser.app.Execute.getNFe(Execute.java:32)
at br.indie.parser.app.Execute.main(Execute.java:22)

Caused by: java.lang.Numberformatexception: For input string: "{0}"

Method responsible for parser:

public static TNfeProc getNFe(String xml) throws Exception {
    try {
        JAXBContext context = JAXBContext.newInstance(TNfeProc.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        TNfeProc nfe = unmarshaller.unmarshal(new StreamSource(new StringReader(xml)), TNfeProc.class).getValue();
        return nfe;
    } catch (JAXBException ex) {
        throw new Exception(ex.toString());
    }
}
  • Hello Jeferson, I’ve worked with NF-e. Please, you can post your XML mapping class?

  • The class used is Tnfeproc, it’s a little big to add here, I think it’s kind of "standard" just like the others (Tnfe, Tuf ... etc)

  • So tomorrow I’ll look at her at work. In case you haven’t solved, I’ll try to help.

  • I’m still trying to...

  • I just forgot about your case, brother. Tomorrow I’m gonna take the time to see this.

  • I solved the problem using some libs from apache Camel.

  • For those interested, please follow the XML conversion project to TXT standard https://github.com/JefersonOC/parser-xml

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.