Run with Netbeans (and Maven) the right context root

时光总嘲笑我的痴心妄想 提交于 2019-12-07 08:24:08

问题


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>


来源:https://stackoverflow.com/questions/13232497/run-with-netbeans-and-maven-the-right-context-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!