jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2 & 3
  • MNG-2187

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

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0.2, 2.0.3
  • Fix Version/s: 3.0-beta-1
  • Component/s: Errors
  • Labels:
    None
  • Complexity:
    Intermediate

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] ----------------------------------------------------------------------------

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. XML File
    pom.xml
    29/Mar/06 1:58 AM
    8 kB
    Carlos Sanchez

Issue Links

relates to

Bug - A problem which impairs or prevents the functions of the product. MNG-2254 the encoding parameter in xml declaration of POM is ignored

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Benjamin Bentmann added a comment - 30/Mar/10 8:51 AM

We now output

[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   The project (D:\test\pom.xml) has 1 error
[ERROR]     Non-readable POM D:\test\pom.xml: Some input bytes do not match the file encoding. MalformedInputException -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/MalformedInputException

as per r929140.

Ideally, we would throw this kind of error on all JRE's but that is another story.

Show
Benjamin Bentmann added a comment - 30/Mar/10 8:51 AM We now output
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   The project (D:\test\pom.xml) has 1 error
[ERROR]     Non-readable POM D:\test\pom.xml: Some input bytes do not match the file encoding. MalformedInputException -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/MalformedInputException
as per r929140. Ideally, we would throw this kind of error on all JRE's but that is another story.

People

  • Assignee:
    Benjamin Bentmann
    Reporter:
    Carlos Sanchez
Vote (0)
Watch (0)

Dates

  • Created:
    29/Mar/06 1:58 AM
    Updated:
    30/Mar/10 2:46 PM
    Resolved:
    30/Mar/10 8:51 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.