8

I have an application which I have deployed using Maven to Weblogic 10.3.6. I have specified context root in weblogic.xml as

<context-root>/myapps</context-root>

The problem I am having is it is taking the war file name as context root instead of the name I have specified in weblogic.xml

How can I change the context root instead of the name taking war file name as context root?

Weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd 
 http://xmlns.oracle.com/weblogic/weblogic-web-app 
 http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
 <context-root>/myapps</context-root>
<container-descriptor>
        <prefer-application-packages>
            <package-name>antlr.*</package-name>
            <package-name>org.hibernate.*</package-name>
            <package-name>javax.persistence.*</package-name>
        </prefer-application-packages>
    </container-descriptor>
    </weblogic-web-app>
Jacob
  • 14,463
  • 65
  • 207
  • 320
  • 1
    I assume this is happening because of your Maven setup/properties. Have you seen this answer and looked at the Maven link? http://stackoverflow.com/questions/13232497/run-with-netbeans-and-maven-the-right-context-root – Display Name is missing May 20 '13 at 15:04
  • 1
    @better_use_mkstemp Yes you seems to be rather right. I have added for my war file name in build. Now the name defined in weblogic.xml seems to be taking as context root. Doing some testing now. – Jacob May 20 '13 at 17:26
  • Cool - hope that works out. – Display Name is missing May 20 '13 at 18:32

2 Answers2

4

I assume this is happening because of your Maven setup/properties. (The same can happen with jDeveloper, if you don't have a property set it will override your context root).

Have you seen this answer? Run with Netbeans (and Maven) the right context root

And the corresponding Maven link: http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-context-root.html

Community
  • 1
  • 1
Display Name is missing
  • 6,197
  • 3
  • 34
  • 46
3

If you are using eclipse/oepe - the context root is in .settings/org.eclipse.wst.common.component file and wtp overrides your files

correct it here and eclipse would respect it

Edit: Looks like they fixed this the right way in 2015

if you are using maven, put this in the pom file

<properties>
  <m2eclipse.wtp.contextRoot>my_context_root !</m2eclipse.wtp.contextRoot>
</properties>

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=461068

Kalpesh Soni
  • 6,879
  • 2
  • 56
  • 59
  • 1
    This answers the question for me. Given the original question involved weblogic, it is reasonable to also assume the oepe plugin for weblogic. Also, instead of directly manipulating files inside .settings, rather right-click project, properties, Web Project Settings, set context root. – tkruse Sep 29 '16 at 00:38
  • 1
    Actually this can be fixed in the pom.xml also: (https://bugs.eclipse.org/bugs/show_bug.cgi?id=461068) by adding a property m2eclipse.wtp.contextRoot in the general pom.xml properties section – tkruse Jan 11 '17 at 03:14