如何将Web应用程序的上下文根设置为“/”。

时间:2012-07-09 09:37:32

标签: jboss jboss5.x contextroot

我无法在我的网络应用程序中设置我的上下文根。 我想将上下文根设置为" /",但是当我启动我的应用程序服务器(jboss-5.1.0.GA)时,我得到以下异常的异常:

  

12:21:23,257 ERROR [AbstractKernelController]安装到Start时出错:name = jboss.web.deployment:war = / state = Create mode = Manual requiredState = Installed   org.jboss.deployers.spi.DeploymentException:部署URL文件已存在Web映射:/ D:/jboss-5.1.0.GA/jboss-5.1.0.GA/server/letu-prod/deploy/ATG.ear /store.war/           在org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:187)           在org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)           在org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)           在org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)           在org.jboss.web.deployers.WebModule.start(WebModule.java:97)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)           在java.lang.reflect.Method.invoke(Method.java:597)           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)           在org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)           在org.jboss.mx.server.Invocation.invoke(Invocation.java:88)           在org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)           在org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)           在org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)           在$ Proxy38.start(未知来源)           在org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)           在org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)           at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)           在org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)           在org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)           在org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)           在org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)           在org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)           在org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)           在org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)           在org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)           在org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)           在org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)           在org.jboss.system.ServiceController.doChange(ServiceController.java:688)           在org.jboss.system.ServiceController.start(ServiceController.java:460)           在org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)           在org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)           在org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)           在org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)           在org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)           在org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)           在org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)           在org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)           在org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)           在org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)           在org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)           在org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)           在org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)           在org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)           在org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)           在org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)           在org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)           在org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)           在org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)           在org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)           在org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)           在org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)           在org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)           在org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)           在org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)           在org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)           在org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)           在org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)           在org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)           在org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)           在org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)           at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)           在org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)           在org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)           在org.jboss.Main.boot(Main.java:221)           在org.jboss.Main $ 1.run(Main.java:556)           在java.lang.Thread.run(Thread.java:662)

有人可以帮我吗?

3 个答案:

答案 0 :(得分:2)

默认情况下。在JBoss的deploy文件夹中有一个ROOT.war绑定到/ context。 早期版本的JBoss在其他应用程序尝试将其上下文绑定到/.

时没有抛出异常

请查看以下链接

Web mapping already exists for deployment

答案 1 :(得分:1)

我也在运行带有eclipse indigo的jBoss 5.1(STS 2.9.2)我将我的Web项目设置保存到我的原始根上下文myWarName.war,例如在eclipse中,但是必须将jBoss.web.xml文件更改为这样:

     

来自:

<jboss-web>
     <context-root>myWarName</context-root>
</jboss-web>

要:

<jboss-web>
    <context-root>/</context-root>
</jboss-web>

然后我将我的jBoss部署文件夹下的ROOT.war重命名为jBossROOT.war,如Arun的链接中提到的那样一切正常。我不想删除ROOT.war,所以我选择了这个选项。

答案 2 :(得分:0)

默认情况下,Web应用程序的上下文根(也称为上下文路径)设置为Web应用程序存档(WAR)的根名称(不带.war扩展名的名称)。您可以使用EAR部署的标准应用程序描述符(即application.xml)或独立WAR的JBoss AS Web描述符(即jboss-web.xml)覆盖上下文根。我们先来谈谈独立的WAR。

独立WAR部署

您可以在位于WAR的WEB-INF目录中的jboss-web.xml中的独立WAR中覆盖Web应用程序(上下文根)的上下文路径。在这里,我们将上下文根设置为/,这称为根上下文。将应用程序分配给根上下文时,它将响应未由更具体的上下文根处理的所有请求。

/WEB-INF/jboss-web.xml(在WAR中)

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-web>  
    <context-root>/</context-root>  
</jboss-web>  

此文件可以配置许多其他设置。虽然不是必需的,但您可以将XSD(或早期版本的DTD)添加到XML根目录。让我们在JBoss AS架构目录中添加JBoss AS 5.1的XSD,并将上下文根更改为/ myapp。

/WEB-INF/jboss-web.xml(在WAR中)

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
   xsi:schemaLocation="  
      http://www.jboss.com/xml/ns/javaee  
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">  
   <context-root>myapp</context-root>  
</jboss-web>

(注意:如果您在部署时遇到问题,请不要使用架构声明)。

虽然在独立WAR中设置上下文路径的方式是专有的,但Java EE确实提供了在EAR中部署时为WAR分配上下文路径的标准方法。

EAR部署

在EAR文件中部署Web应用程序时,使用Web模块内部的context-root元素在EAR的application.xml文件中指定上下文根。在以下示例中,bank-webapp.war应用程序的上下文根设置为/ mymoney。

/META-INF/application.xml(在EAR中)

<application version="5" xmlns="http://java.sun.com/xml/ns/javaee"  
   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/application_5.xsd">  
   <module>  
      <ejb>bank-ejb.jar</ejb>  
   </module>  
   <module>  
      <web>  
         <web-uri>bank-webapp.war</web-uri>  
         <context-root>mymoney</context-root>  
      </web>  
   </module>  
</application>