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

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

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-alpha-3
    • Component/s: api
    • Labels:
      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(..)".

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                alrubinger Andrew Rubinger
                Reporter:
                ringerc Craig Ringer
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: