Oracle Weblogic:描述符文件中缺少根元素web-app

时间:2014-03-12 00:43:12

标签: java eclipse weblogic jax-rs

我正在尝试使用JAX-RS创建托管在Oracle Weblogic服务器上的Web服务。我是这项技术的新手,所以我只是按照我的导师给出的教程。这是我的代码:

的WebContent / WEB-INF / web.xml中

<servlet> 
    <servlet-name>Jersey REST Service</servlet-name> 
    <servlet-class> 
    com.sun.jersey.spi.container.servlet.ServletContainer 
    </servlet-class> 
    <init-param> 
        <param-name>com.sun.jersey.config.property.edu.cs157b.restful </param-name> 
        <param-value>AssignmentTwo</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
    <servlet-mapping> 
        <servlet-name>Jersey REST Service</servlet-name> 
        <url-pattern>/api/*</url-pattern> 
    </servlet-mapping>
</servlet> 

的WebContent / WEB-INF / weblogic.xml中

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="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.5/weblogic-web-app.xsd">
    <wls:weblogic-version>12.1.2</wls:weblogic-version>
    <wls:context-root>AssignmentTwo</wls:context-root>
</wls:weblogic-web-app>

这是我得到的错误

<Mar 11, 2014 5:32:16 PM PDT> <Error> <HTTP> <BEA-101064> <[WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
    at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
    at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
    at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
    at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
    Truncated. see log file for complete stacktrace
> 
<Mar 11, 2014 5:32:16 PM PDT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1394584335621" for task "6". Error is: "weblogic.application.ModuleException: [HTTP:101064][WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
    at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
    at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
    at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
    at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
    at weblogic.application.descriptor.VersionMunger.init(VersionMunger.java:485)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:86)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:62)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:50)
    at weblogic.servlet.internal.WebAppReader2.<init>(WebAppReader2.java:47)
    at weblogic.servlet.internal.WebAppDescriptor$MyWebAppDescriptor.createXMLStreamReader(WebAppDescriptor.java:275)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:406)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:778)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:787)
    at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:142)
    at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1446)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
    at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
    at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
    at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
    at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:342)
    at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:355)
    at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:383)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
    at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:233)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:749)
    at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1238)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:252)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:172)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

[Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml."
weblogic.application.ModuleException: [HTTP:101064][WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
    at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
    at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
    at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
    at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
    at weblogic.application.descriptor.VersionMunger.init(VersionMunger.java:485)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:86)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:62)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:50)
    at weblogic.servlet.internal.WebAppReader2.<init>(WebAppReader2.java:47)
    at weblogic.servlet.internal.WebAppDescriptor$MyWebAppDescriptor.createXMLStreamReader(WebAppDescriptor.java:275)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:406)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:778)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:787)
    at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:142)
    at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1446)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
    at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
    at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
    at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
    at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:342)
    at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:355)
    at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:383)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
    at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:233)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:749)
    at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1238)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:252)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:172)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

[Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.servlet.internal.WebAppModule.createModuleException(WebAppModule.java:1824)
    at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1473)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
    at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
    Truncated. see log file for complete stacktrace
Caused By: weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
    at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
    at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
    at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
    at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
    Truncated. see log file for complete stacktrace
> 
<Mar 11, 2014 5:32:16 PM PDT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating distribute task for application "_auto_generated_ear_".> 
<Mar 11, 2014 5:32:16 PM PDT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: [HTTP:101064][WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
    at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
    at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
    at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
    at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
    at weblogic.application.descriptor.VersionMunger.init(VersionMunger.java:485)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:86)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:62)
    at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:50)
    at weblogic.servlet.internal.WebAppReader2.<init>(WebAppReader2.java:47)
    at weblogic.servlet.internal.WebAppDescriptor$MyWebAppDescriptor.createXMLStreamReader(WebAppDescriptor.java:275)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:406)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:778)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:787)
    at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:142)
    at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1446)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
    at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
    at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
    at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
    at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:342)
    at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:355)
    at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:383)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
    at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:233)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:749)
    at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1238)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:252)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:172)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

[Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.servlet.internal.WebAppModule.createModuleException(WebAppModule.java:1824)
    at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1473)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
    at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
    at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
    Truncated. see log file for complete stacktrace
Caused By: weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
    at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
    at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
    at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
    at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
    at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
    Truncated. see log file for complete stacktrace
> 

1 个答案:

答案 0 :(得分:1)

  

描述符文件

中缺少根元素web-app

您的web.xml缺少根元素<web-app>。嵌套也是不正确的。 <servlet-mapping>元素是一个顶级元素,如<servlet>元素,而不是嵌套在其中。

您的web.xml应该具有与此类似的结构:

<web-app 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/web-app_3_0.xsd"
      version="3.0"> 

    <servlet>
       <servlet-name>Jersey REST Service</servlet-name> 
       <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> 
       <init-param> 
           <param-name>com.sun.jersey.config.property.edu.cs157b.restful </param-name> 
           <param-value>AssignmentTwo</param-value> 
       </init-param> 
       <load-on-startup>1</load-on-startup> 
    </servlet>

    <servlet-mapping> 
        <servlet-name>Jersey REST Service</servlet-name> 
        <url-pattern>/api/*</url-pattern> 
    </servlet-mapping>

</web-app>

如果在创建Web应用程序时使用IDE(如Netbeans,Eclipse),它将为您生成有效的web.xml。如果您创建REST Web服务,它甚至可能为您配置JAX-RS web.xml。