Example usage for javax.xml.bind UnmarshalException printStackTrace

List of usage examples for javax.xml.bind UnmarshalException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind UnmarshalException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:com.rabidgremlin.legalbeagle.util.HttpHelper.java

private JAXBElement<Model> unMarshallPom(String pom) {
    try {/*from   w w w  . j a v a2  s .c  o  m*/
        return (JAXBElement<Model>) u.unmarshal(new StringReader(pom));
    } catch (javax.xml.bind.UnmarshalException e) {
        // System.out.println(e);
        // return null;

        if (e.getMessage().startsWith("unexpected element (uri:\"\", local:\"project\")")) {
            try {
                pom = pom.replaceFirst("<project>", "<project xmlns=\"http://maven.apache.org/POM/4.0.0\">");

                // System.out.println("***POM is " + pom);

                return (JAXBElement<Model>) u.unmarshal(new StringReader(pom));
            } catch (Exception ex) {
                e.printStackTrace();
                return null;
            }
        } else {
            e.printStackTrace();
            return null;
        }

    } catch (JAXBException e) {
        return null;
    }

}