How to change the context path of my Enterprise Project

So my TestProject project name is TestProject , which contains TestProject-ejb and TestProject-war , so when I run the project, the URL looks like locahost:8080/TestProject-war . How to change this url to localhost:8080/testproject . I am using netbean 6.9, I am trying to right-click on the TestProject-war folder in netbean and specify the context path there under Run , but it still loads locahost:8080/TestProject-war

+7
source share
3 answers

You need to check whether the context root element for the web module in the application.xml file has been changed correctly, which in the META-INF directory of your EAR has been changed correctly.

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 accessible under / testproject of the server you are deploying to, so in your case http://localhost:8080/testproject .

(If you want to deploy it to the root directory of your server, you can leave the context root element empty: <context-root></context-root> .)

If you really see that your action in Netbeans has correctly modified this file, it could be a deployment problem, for example, BalusC. Check the location to which the EAR is deployed, and manually verify that the version of the deployed value has the correct value.

+12
source

As Harry noted, the project template does not create the application.xml file by default, so you need to create it manually in $ENTERPRISE_APP_PATH/src/conf (tested with NB 6.9.1)

+1
source

Just ran into this question in the process of figuring out the same thing. As the OP asked about this in Netbeans, let me add to the previous answers by describing how to do this using NetBeans.

With Netbeans 8 (and possibly also with earlier versions), you can specify an IDE to create the application.xml file for you as follows. Right-click the enterprise application project (in the OP example it will be "TestProject"), select "Create", then "Standard Deployment Descriptor ...". This will create the "application.xml" file and place it in the appropriate place in the Netbeans project. Then you can easily edit this file to set the context root element as you like.

+1
source

All Articles