Issue
So my enterprise project name TestProject
, which contain TestProject-ejb
and TestProject-war
, so when I run the project the url is like this locahost:8080/TestProject-war
. How can I change this url to localhost:8080/testproject
. I use netbean 6.9, I try to right click on TestProject-war
folder in netbean, and specify the context-path there under Run
, but it still load locahost:8080/TestProject-war
Solution
You need to check that the context-root element for the web module in the application.xml file that's in the META-INF directory of your EAR has been correctly changed.
An example would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
id="Application_ID" version="6">
<display-name>TestProject</display-name>
<module>
<web>
<web-uri>TestProjectWeb.war</web-uri>
<context-root>testproject</context-root>
</web>
</module>
<module>
<ejb>TestProjectEJB.jar</ejb>
</module>
</application>
In this example the web module should be available under /testproject of the server you deploy to, so in your case http://localhost:8080/testproject
.
(In case you would like to deploy to the root of your server, you can leave the context-root element empty: <context-root></context-root>
.)
If you indeed see that your action in Netbeans has correctly changed this file, it may be a deployment problem like BalusC indicated. Check the location the EAR is deployed to and manually inspect whether the deployed version also has the correct value.
Answered By - Arjan Tijms
Answer Checked By - Robin (JavaFixing Admin)