views:

722

answers:

1

Say I have a simple j2EE ear:

foo.ear
- foo.war

I would like to deploy the same ear twice so I rename the ear:

bar.ear
- foo.war

The META-INF\application.xml file looks like this:

<application>
    <module>
        <web>
            <web-uri>foo.war</web-uri>
            <context-root>/baz</context-root>
        </web>
    </module>
</application>

When I deploy there is a collison, both apps will try to mount at http://localhost:8080/baz. Is there a way to prefix the ear name to the context-root to get foo/baz and bar/baz?

+1  A: 

How about setting it at build time, by generating the application.xml? Ant can do this easily with a filter, on

<context-root>@context.root@</context-root>

In the Ant build script, do:

<copy todir="${ear.dir}/META-INF" file="${ear}/META-INF/application.xml" overwrite="true">
    <filterset>
        <filter token="context.root" value="${context.root}" />
    </filterset>
</copy>
Peter Hilton