1

我一直在使用 tomcat 6 在本地主机上开发一个简单的 Web 应用程序,并且在部署到 tomcat 时没有问题,但是当我尝试将其部署到 WebLogic Server 时出现以下错误

[HTTP:101216]Servlet: "mdc-dispatcher" failed to preload on startup in Web application: "admin_UI.war".
 org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource
    [/WEB-INF/mdc-dispatcher-servlet.xml]; nested exception is java.lang.NoSuchMethodError:
        org/springframework/beans/MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues; at
        org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420) at
        org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) at
        org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) at
        org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at
        org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at
        org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at
        org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) at
        org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) at
        org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) at
        org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423) at
        org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355) at
        org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402) at
        org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316) at
        org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282) at
        org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:128) at javax.servlet.GenericServlet.init(GenericServlet.java:242) at
        weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283) at
        weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at
        weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64) at
        weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58) at
        weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48) at
        weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539) at
        weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985) at
        weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959) at
        weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878) at
        weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154) at
        weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:485)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427) at
        weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at
        weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at
        weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:201) at
        weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:249) at
        weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427) at
        weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at
        weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at
        weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:28) at
        weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:637) at
        weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at
        weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205) at
        weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:43) at
        weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161) at
        weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79) at
        weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569) at
        weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150) at
        weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116) at
        weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:140) at
        weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323) at
        weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844) at
        weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253) at
        weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440) at
        weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:164) at
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195) at
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13) at
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69) at
        weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528) at
        weblogic.work.ExecuteThread.run(ExecuteThread.java:176) Caused by: java.lang.NoSuchMethodError:
        org/springframework/beans/MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues; at
        org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:101) at
        org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69) at
        org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297) at
        org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287) at
        org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) at
        org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92) at
        org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) at
        org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398) at
        org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) at
        org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) at
        org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at
        org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at
        org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at
        org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) at
        org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) at
        org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) at
        org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) at
        org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at
        org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402) at
        org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316) at
        org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282) at
        org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126) at javax.servlet.GenericServlet.init(GenericServlet.java:241) at
        weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283) at
        weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at
        weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at
        weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64) at
        weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58) at
        weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48) at
        weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539) at
        weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985) at
        weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959) at
        weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878) at
        weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153) at
        weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) at
        weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at
        weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at
        weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200) at
        weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247) at
        weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) at
        weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at
        weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at
        weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27) at
        weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636) at
        weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at
        weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205) at
        weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:43) at
        weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161) at
        weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79) at
        weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569) at
        weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150) at
        weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116) at
        weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:140) at
        weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323) at
        weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844) at
        weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253) at
        weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440) at
        weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163) at
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195) at
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13) at
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68) at
        weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528) at
        weblogic.work.ExecuteThread.execute(ExecuteThread.java:207) ... 1 more 

我在 Stackoverflow(见此处)或 Google 上找到的任何内容似乎都指向 spring 版本低于 3.0 的问题,但我使用的是 3.0.4

这是我的 pom 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.fid.mdc</groupId>
    <artifactId>admin_UI</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>admin_UI Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <springVersion>3.0.4.RELEASE</springVersion>
    </properties>
    <dependencies>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <!-- ORACLE JDBC driver, need install yourself -->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.3.Final</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>

        <!-- Spring framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${springVersion}</version>
        </dependency>

        <!-- for compile only, your container should have this -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <!-- Commons-logging & log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.12</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>admin_UI</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <webappDirectory>/sample/servlet/container/deploy/directory</webappDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是导出战争中lib的内容:

在此处输入图像描述

在今天之前我从未使用过 WebLogic,所以如果我忽略了任何基本的东西,请原谅我。

任何帮助或建议将不胜感激

4

1 回答 1

1

因此,解决方案是包含一个 weblogic.xml 文件,其中 prefer-web-inf-classes 设置为 true,请参见下文:

<!--?xml version="1.0" encoding="UTF-8"?-->
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
    <context-root>admin_UI</context-root>
    <container-descriptor>
      <prefer-web-inf-classes>true</prefer-web-inf-classes>
  </container-descriptor>
</weblogic-web-app>

这允许它进行部署,但目前它并没有映射所有资源,包括我的 css 和图像,但我相信这只是包含适当标签的问题,当我对它进行排序时,我会更新我的答案,以便其他可能会从中受益

更新

我能够pageContext.servletContext.contextPath在我的 jsp 页面中访问我的 css 和图像,例如<link type="text/css" rel="stylesheet" href="${pageContext.servletContext.contextPath}/resources/css/style.css"/>

于 2012-11-16T11:18:12.507 回答