2010-03-08

Maven archetype lexical error

I got this nasty little error today. I thought I would share it, in case someone has the same problem and finds this page.

[ERROR] ResourceManager.getResource()
parse exception:
org.apache.velocity.exception.ParseErrorException:
Lexical error:
org.apache.velocity.runtime.parser.TokenMgrError:
Lexical error at line 3570, column 172.  Encountered:
<eof> after : ""

(Line breaks added for readability)

Now, what that means is that while reading your archetype files, Maven encountered a (likely binary) file that it could not parse. Arguably, this error message could be more clear, in particular it could provide the file name itself.

The solution is simple.

For archetype.xml:

<resource filtered="false">x.gif</resource>
That is, you simple add filtered="false" to your binary resource reference in the archetype.xml file.

For archetype-catalog.xml it is similar; however, there filtering is disabled by default. So, you can either have a declaration similar to the following:

<fileSet encoding="UTF-8">
            <directory>src/main/webapp</directory>
            <includes>
                <include>**/*.gif</include>
            </includes>
        </fileSet>

... or, more explicitly, set the filtered attribute.

<fileSet filtered="false" encoding="UTF-8">
           ...
        </fileSet>

No comments:

Post a Comment