Uploaded image for project: 'ShrinkWrap Descriptors'
  1. ShrinkWrap Descriptors
  2. SHRINKDESC-120

Confusing exception when filename string passed to DescriptorImporter.from(...)

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Done
    • None
    • 2.0.0-alpha-3
    • api
    • None

    Description

      Descriptors 2.0.0.alpha2

      It's too easy to write:

      BeansDescriptor beansXml = Descriptors.importAs(BeansDescriptor.class)
                      .from("src/main/webapp/WEB-INF/beans.xml");
      

      when you really meant:

      BeansDescriptor beansXml = Descriptors.importAs(BeansDescriptor.class)
                      .from(new File("src/main/webapp/WEB-INF/beans.xml"));
      

      The incorrect code reads fine, and the exception thrown doesn't make it at all obvious what's happening:

      java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.JavaArchive com.example.shrinkwraptestsk
      eleton.DemoTest.createDeployment()
         ....
      Caused by: java.lang.reflect.InvocationTargetException
         ....
      Caused by: org.jboss.shrinkwrap.descriptor.api.DescriptorImportException: Could not import XML from stream
         ....
      Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
         ....
      

      I'd like to replace ".from(String)" with ".fromString(...)" . The unqualified .from() could continue to accept an InputStream or Reader, just not String. Adding ".fromFile(String)" is probably pointless given it'd be a pointless wrapper around "new File(..)".

      Attachments

        Activity

          People

            arubinge@redhat.com Andrew Rubinger (Inactive)
            ringerc_jira Craig Ringer (Inactive)
            Archiver:
            samahaja@redhat.com Sagar Mahajan

            Dates

              Created:
              Updated:
              Resolved:
              Archived: