0

Here is the code I'm trying to run but it is currently throwing an exception at this line:

try {
        File file = new File(getFilesDir().getPath() + "/" + name + ".xml");
        JAXBContext jaxbContext = JAXBContext.newInstance(Restaurant.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(r, file);

    } catch (JAXBException e) {
        e.printStackTrace();
    }  

I'm getting an exception thrown at this line:

JAXBContext jaxbContext = JAXBContext.newInstance(Restaurant.class);

I copied the log to pastebin (https://pastebin.com/WRjXbub7)

I am trying to serialize an object to a XML file. I'm not getting red marks or anything in my code, so I don't know what the issue is here. Thanks!

Kyle Diablo
  • 61
  • 1
  • 7
  • 1
    `java.lang.IllegalStateException: Could not execute method for android:onClick` can you send the code where you are setting the onClickListener ? as your log file suggest exception started from there. And do try clean build also. – Anmol Dec 23 '18 at 10:17
  • @Anmol in activity xml: `android:onClick="finalizePlace"` here is the method declaration: `public void finalizePlace(View view)` The thing is, There is code above this that works just fine in the method. Also, cleaning the project unfortunately didn't help. – Kyle Diablo Dec 23 '18 at 10:21
  • share cade of `Restaurant` class – Anmol Dec 23 '18 at 10:29
  • @Anmol https://pastebin.com/q6YHszyd – Kyle Diablo Dec 23 '18 at 10:30
  • try setting the `@XmlElement` on the getter's not on the variable then it should work.And all the variable's are not Element try reading this https://stackoverflow.com/a/33757/7972699 if something helps i will post it as an answer do tell. – Anmol Dec 23 '18 at 10:33
  • Here is the new log, still getting a exception: https://pastebin.com/cQ02rDsv – Kyle Diablo Dec 23 '18 at 10:38
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/185682/discussion-between-anmol-and-kyle-diablo). – Anmol Dec 23 '18 at 10:40

0 Answers0