Maven 2 & 3

Model interpolation crashes if property resolves to value with ampersand

Details

  • Complexity:
    Intermediate
  • Patch Submitted:
    Yes
  • Number of attachments :
    0

Description

Halo!

Maven don't work when In Windows user has ampersand in the name for example username=Tom&Jerry. Windows allows usernames like this, but Maven treat ampersand in the name of users main folder as a part of some url or something ... and cannot get path properly. Windows do not allow to change username with all user's foldernames.

Artur

Issue Links

Activity

Hide
Benjamin Bentmann added a comment -

The only problem I observed with the ampersand character was in the batch files launching Maven, more precisely in

@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set HOME=%HOMEDRIVE%%HOMEPATH%)

which causes something like "Jerry is not recognized as an internal or external command" when executing the set command for the user name "Tom&Jerry".

As outlined in the Windows Command Shell Overview and KB-103368, the ampersand is a special character that needs escaping, e.g. by surrounding with quots.

If you encounter other errors besides the one mentioned, please provide a full debug log of Maven.

Show
Benjamin Bentmann added a comment - The only problem I observed with the ampersand character was in the batch files launching Maven, more precisely in
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set HOME=%HOMEDRIVE%%HOMEPATH%)
which causes something like "Jerry is not recognized as an internal or external command" when executing the set command for the user name "Tom&Jerry". As outlined in the Windows Command Shell Overview and KB-103368, the ampersand is a special character that needs escaping, e.g. by surrounding with quots. If you encounter other errors besides the one mentioned, please provide a full debug log of Maven.
Hide
Artur Smiejowski added a comment -

The main problem is when I use maven with appfuse 2.0.2. After creating project (it works ok) I want to run application with mvn jetty:run-war, and this couse error. Here is some console log:

D:\workspace\testworkspace\myproject>mvn jetty:run-war
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: com.mycompany.app:myproject
POM Location: D:\workspace\testworkspace\myproject\pom.xml

Reason: Cannot read project model from interpolating filter of serialized versio
n. for project com.mycompany.app:myproject at D:\workspace\testworkspace\myproje
ct\pom.xml

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Cannot read project model from
interpolating filter of serialized version. for project com.mycompany.app:mypro
ject at D:\workspace\testworkspace\myproject\pom.xml
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:378)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:292)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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.InvalidProjectModelException: Cannot read pr
oject model from interpolating filter of serialized version. for project com.myc
ompany.app:myproject at D:\workspace\testworkspace\myproject\pom.xml
at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def
aultMavenProjectBuilder.java:882)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFi
leInternal(DefaultMavenProjectBuilder.java:506)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMave
nProjectBuilder.java:198)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:583)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:461)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:365)
... 11 more
Caused by: org.apache.maven.project.interpolation.ModelInterpolationException: C
annot read project model from interpolating filter of serialized version.
at org.apache.maven.project.interpolation.RegexBasedModelInterpolator.in
terpolate(RegexBasedModelInterpolator.java:114)
at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLog
ic(DefaultMavenProjectBuilder.java:1025)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def
aultMavenProjectBuilder.java:878)
... 16 more
Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: entity refe
rence name can not contain character \' (position: START_TAG seen ...<jdbc.url>j
dbc:h2:C:\Users\Ada&Fin\... @611:44)
at org.codehaus.plexus.util.xml.pull.MXParser.parseEntityRef(MXParser.ja
va:2222)
at org.codehaus.plexus.util.xml.pull.MXParser.nextImpl(MXParser.java:127
5)
at org.codehaus.plexus.util.xml.pull.MXParser.next(MXParser.java:1093)
at org.codehaus.plexus.util.xml.pull.MXParser.nextText(MXParser.java:105
8)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.parseProfile(MavenXpp3
Reader.java:3414)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.parseModel(MavenXpp3Re
ader.java:2239)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.j
ava:4422)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.j
ava:4433)
at org.apache.maven.project.interpolation.RegexBasedModelInterpolator.in
terpolate(RegexBasedModelInterpolator.java:105)
... 18 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Jul 22 11:29:45 CEST 2008
[INFO] Final Memory: 1M/4M
[INFO] ------------------------------------------------------------------------

I think that the problem is becouse of ampersand in the username - on other computer there is no problem with running application. Only on my laptop, where I have ampersand in the username.

Thanks in advice.
Artur.

Show
Artur Smiejowski added a comment - The main problem is when I use maven with appfuse 2.0.2. After creating project (it works ok) I want to run application with mvn jetty:run-war, and this couse error. Here is some console log: D:\workspace\testworkspace\myproject>mvn jetty:run-war [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [ERROR] FATAL ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error building POM (may not be this project's POM). Project ID: com.mycompany.app:myproject POM Location: D:\workspace\testworkspace\myproject\pom.xml Reason: Cannot read project model from interpolating filter of serialized versio n. for project com.mycompany.app:myproject at D:\workspace\testworkspace\myproje ct\pom.xml [INFO] ------------------------------------------------------------------------ [INFO] Trace org.apache.maven.reactor.MavenExecutionException: Cannot read project model from interpolating filter of serialized version. for project com.mycompany.app:mypro ject at D:\workspace\testworkspace\myproject\pom.xml at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:378) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:292) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129) at org.apache.maven.cli.MavenCli.main(MavenCli.java:287) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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.InvalidProjectModelException: Cannot read pr oject model from interpolating filter of serialized version. for project com.myc ompany.app:myproject at D:\workspace\testworkspace\myproject\pom.xml at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def aultMavenProjectBuilder.java:882) at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFi leInternal(DefaultMavenProjectBuilder.java:506) at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMave nProjectBuilder.java:198) at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:583) at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:461) at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:365) ... 11 more Caused by: org.apache.maven.project.interpolation.ModelInterpolationException: C annot read project model from interpolating filter of serialized version. at org.apache.maven.project.interpolation.RegexBasedModelInterpolator.in terpolate(RegexBasedModelInterpolator.java:114) at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLog ic(DefaultMavenProjectBuilder.java:1025) at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def aultMavenProjectBuilder.java:878) ... 16 more Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: entity refe rence name can not contain character \' (position: START_TAG seen ...<jdbc.url>j dbc:h2:C:\Users\Ada&Fin\... @611:44) at org.codehaus.plexus.util.xml.pull.MXParser.parseEntityRef(MXParser.ja va:2222) at org.codehaus.plexus.util.xml.pull.MXParser.nextImpl(MXParser.java:127 5) at org.codehaus.plexus.util.xml.pull.MXParser.next(MXParser.java:1093) at org.codehaus.plexus.util.xml.pull.MXParser.nextText(MXParser.java:105 8) at org.apache.maven.model.io.xpp3.MavenXpp3Reader.parseProfile(MavenXpp3 Reader.java:3414) at org.apache.maven.model.io.xpp3.MavenXpp3Reader.parseModel(MavenXpp3Re ader.java:2239) at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.j ava:4422) at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.j ava:4433) at org.apache.maven.project.interpolation.RegexBasedModelInterpolator.in terpolate(RegexBasedModelInterpolator.java:105) ... 18 more [INFO] ------------------------------------------------------------------------ [INFO] Total time: < 1 second [INFO] Finished at: Tue Jul 22 11:29:45 CEST 2008 [INFO] Final Memory: 1M/4M [INFO] ------------------------------------------------------------------------ I think that the problem is becouse of ampersand in the username - on other computer there is no problem with running application. Only on my laptop, where I have ampersand in the username. Thanks in advice. Artur.
Hide
Brett Porter added a comment -

scheduling for the patch to the batch file.

As for the parse error, what is actually putting the value in the POM? It should be writing & instead.

Show
Brett Porter added a comment - scheduling for the patch to the batch file. As for the parse error, what is actually putting the value in the POM? It should be writing & instead.
Hide
Benjamin Bentmann added a comment - - edited

From a mail Artur sent me today I got this snippet from his POM (I asked him to attach it here for further inspection, too):

<jdbc.url><![CDATA[jdbc:h2:${java.io.tmpdir}/myapp]]></jdbc.url>

IIRC, the POM is parsed once, then serialized back into a string, this string is then interpolated and the result is parsed again into a Maven model. Apparently during serialization into string form, the original CDATA section markers are lost such that the second parsing step after interpolation is sensitive to XML metacharacters.

I am not familar with the POM interpolation but maybe we could just make the MavenXpp3Writer always wrap text with CDATA sections (if requested via some flag). This way, the interpolator doesn't need to care about XML escaping but can safely insert replacement values for the expressions.

Show
Benjamin Bentmann added a comment - - edited From a mail Artur sent me today I got this snippet from his POM (I asked him to attach it here for further inspection, too):
<jdbc.url><![CDATA[jdbc:h2:${java.io.tmpdir}/myapp]]></jdbc.url>
IIRC, the POM is parsed once, then serialized back into a string, this string is then interpolated and the result is parsed again into a Maven model. Apparently during serialization into string form, the original CDATA section markers are lost such that the second parsing step after interpolation is sensitive to XML metacharacters. I am not familar with the POM interpolation but maybe we could just make the MavenXpp3Writer always wrap text with CDATA sections (if requested via some flag). This way, the interpolator doesn't need to care about XML escaping but can safely insert replacement values for the expressions.
Hide
Benjamin Bentmann added a comment -

This was fixed by refactoring of the model interpolation in both Maven 2.1.x (by John) and 3.x (by Shane).

Show
Benjamin Bentmann added a comment - This was fixed by refactoring of the model interpolation in both Maven 2.1.x (by John) and 3.x (by Shane).

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: