public static Customer[] getAllCustomers() { Mapping mapping = new Mapping(); try { mapping.loadMapping( new InputSource( Thread.currentThread() .getContextClassLoader() .getResource("mappings.xml") .getFile())); Unmarshaller unmarshaller = new Unmarshaller(mapping); unmarshaller.setIgnoreExtraElements(true); CustomersContainer customersContainer = (CustomersContainer) unmarshaller.unmarshal( new InputSource( Thread.currentThread() .getContextClassLoader() .getResource("Customers.xml") .getFile())); Customer[] customers = new Customer[customersContainer.getCustomers().size()]; for (int i = 0; i < customersContainer.getCustomers().size(); i++) { customers[i] = customersContainer.getCustomers().get(i); } return customers; } catch (Exception e) { throw new RuntimeException(e); } }