-->

Run with Netbeans (and Maven) the right context ro

2019-05-14 01:21发布

问题:

I've got a little problem when I run a project from my Netbeans 7.2 (I also use a Glassfish 3.1.2 Server) ...

In fact I'm migrating existing projects from Ant to Maven, my pom.xml are finished and I've used the customisation of the context root as it's described here : http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-context-root.html but when I run the project from netbeans, it's deployed with the name of my .ear : localhost:8080/MyApplicationEAR-0.1-SNAPSHOT instead of localhost:8080/MyApplicationName (which is referenced in <contextRoot>/MyApplicationName</contextRoot>)

If I write the correct URL in my browser it works fine but it's not really pleasant.

Is there a problem in Netbeans or I've forgot something?

EDIT : The application.xml is auto generated by Maven and the context-root is well formed but it seems that Netbeans doesn't matter with this...

回答1:

If you are using Maven and deploying into JBoss, try this.

You should edit the pom.xml file and add the following line into <build> section.

<finalName>${artifactId}</finalName>


回答2:

I just tried that with Netbeans 7.3 beta and it works.

I assume you put in the artifact and groupId tags in your module tag. If not this might be your problem. Here my plugin config as an example:

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <version>6</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <generateApplicationXml>true</generateApplicationXml>
                <applicationName>Gen</applicationName>
                <modules>
                    <ejbModule>
                        <artifactId>Testing-ejb</artifactId>
                        <groupId>de.roeperweise.testing</groupId>
                        <bundleFileName>ejb.jar</bundleFileName>
                    </ejbModule>
                    <webModule>
                        <artifactId>Testing-web</artifactId>
                        <groupId>de.roeperweise.testing</groupId>
                        <bundleFileName>web.war</bundleFileName>
                        <contextRoot>/custom</contextRoot>                         
                    </webModule>
                </modules>
            </configuration>
        </plugin>