Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-2187

Improve error message when the pom is encoded in the wrong charset

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.2, 2.0.3
    • 3.0-beta-1
    • Errors
    • None

    Description

      When the pom is encoded in a charset different than the one declared in the xml header (UTF8 by default) and containing an special char (รณ or something like that), under Sun's JDK there's no error but under IBM JDK it crashes with
      sun.io.MalformedInputException

      It'd be good if we could check first the encoding or capture the exception and show an error message instead.

      [INFO] Scanning for projects...
      [INFO] ----------------------------------------------------------------------------
      [ERROR] FATAL ERROR
      [INFO] ----------------------------------------------------------------------------
      [INFO] Error building POM (may not be this project's POM).

      Project ID: unknown

      Reason: Failed to build model from file '/home/demo/plexus-compiler/pom.xml'.
      Error: 'null'

      [INFO] ----------------------------------------------------------------------------
      [INFO] Trace
      org.apache.maven.reactor.MavenExecutionException: Failed to build model from file '/home/demo/plexus-compiler/pom.xml'.
      Error: 'null'
      at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:365)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:278)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
      at java.lang.reflect.Method.invoke(Method.java:391)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      Caused by: org.apache.maven.project.ProjectBuildingException: Failed to build model from file '/home/demo/plexus-compiler/pom.xml'.
      Error: 'null'
      at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1103)
      at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFile(DefaultMavenProjectBuilder.java:289)
      at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:274)
      at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:515)
      at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:447)
      at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:351)
      ... 12 more
      Caused by: sun.io.MalformedInputException
      at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java(Compiled Code))
      at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java(Inlined Compiled Code))
      at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java(Compiled Code))
      at sun.nio.cs.StreamDecoder.read(StreamDecoder.java(Compiled Code))
      at java.io.InputStreamReader.read(InputStreamReader.java:208)
      at java.io.Reader.read(Reader.java:113)
      at org.codehaus.plexus.util.IOUtil.copy(IOUtil.java:212)
      at org.codehaus.plexus.util.IOUtil.copy(IOUtil.java:200)
      at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1117)
      at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1094)
      ... 17 more
      [INFO] ----------------------------------------------------------------------------
      [INFO] Total time: 1 second
      [INFO] Finished at: Wed Mar 29 04:25:41 PST 2006
      [INFO] Final Memory: 2M/5M
      [INFO] ----------------------------------------------------------------------------

      Attachments

        1. pom.xml
          8 kB
          Carlos Sanchez Gonzalez

        Issue Links

          Activity

            People

              bentmann Benjamin Bentmann
              carlos Carlos Sanchez Gonzalez
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: