我是春天的新手,我现在正在使用春天4
战争部署到JCS-SaaS(云)后,我得到以下错误:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 来自类路径资源的XML文档中的第33行 [pepsiServlet-context.xml]无效;嵌套异常是 org.xml.sax.SAXParseException; lineNumber:33; columnNumber:62; cvc-complex-type.2.4.a:找到无效的内容 元素资源'。之一 ' {" http://www.springframework.org/schema/beans":进口, " http://www.springframework.org/schema/beans":别名, " http://www.springframework.org/schema/beans":豆, WC [##其它:" http://www.springframework.org/schema/beans&#34], " http://www.springframework.org/schema/beans":豆}'是预期的。
引起:org.xml.sax.SAXParseException; lineNumber:33; columnNumber:62; cvc-complex-type.2.4.a:找到无效的内容 从元素'资源开始。之一 ' {" http://www.springframework.org/schema/beans":进口, " http://www.springframework.org/schema/beans":别名, " http://www.springframework.org/schema/beans":豆, WC [##其它:" http://www.springframework.org/schema/beans&#34], " http://www.springframework.org/schema/beans":豆}'是预期的。
的pom.xml
<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.itc</groupId>
<artifactId>pepsiIndIntegration</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>pepsiIndIntegration Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.7</jdk.version>
<spring.version>4.1.7.RELEASE</spring.version>
<slf4j.version>1.7.10</slf4j.version>
<log4j.version>1.2.17</log4j.version>
<apache.commons.version>3.4</apache.commons.version>
</properties>
<dependencies>
<!-- JUnit Dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- Spring Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Logging Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- Spring MVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Org Apache Commons -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.version}</version>
</dependency>
<!-- Oracle Driver Dependency -->
<!-- <dependency> <groupId>oracle</groupId> <artifactId>ojdbc6</artifactId>
<version>1.0</version> <scope>system</scope> <systemPath>${oracle.driver.path}</systemPath>
</dependency> -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<!-- Dependency for common file upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId>
<version>2.9.1</version> </dependency> -->
</dependencies>
<build>
<finalName>pepsiIndIntegration</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<extensions>
<extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:3.1.2</extension>
</extensions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceRoot>${basedir}/target/generated-sources/cxf/wsdl2java</sourceRoot>
<!-- <sourceRoot>${basedir}/target/generated-sources/cxf/wsdl2java</sourceRoot> -->
<!-- <defaultOptions> <bindingFiles> <bindingFile>${binding}/binding.xml</bindingFile>
</bindingFiles> </defaultOptions> -->
<wsdlRoot>${wsdls}</wsdlRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>https://someurl:someport/xyz/abc?wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
下面是web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<!-- Loading Beans -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:pepsiBeans.xml
</param-value>
</context-param>
<!-- Spring Dispatched Servlet -->
<servlet>
<servlet-name>pepsiServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:pepsiServlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>pepsiServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
下面是我的pepsiServlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context:component-scan base-package="com.test.pepsi" />
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<!-- Enable Annotation based Declarative Transaction Management -->
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" />
<!-- Creating TransactionManager Bean, since JDBC we are creating of type
DataSourceTransactionManager -->
<beans:bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<beans:property name="dataSource" ref="dataSource" />
</beans:bean>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Initialization for data source -->
<!-- <beans:bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<beans:property name="url"
value="jdbc:oracle:thin@hostname:port:service/sid" />
<beans:property name="username" value="USER_NAME" />
<beans:property name="password" value="PASSWORD" />
</beans:bean> -->
<beans:bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="classpath:ApplicationMessages" />
<beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>
<task:annotation-driven scheduler="scheduler"
executor="executor" />
<task:scheduler id="scheduler" pool-size="10" />
<task:executor id="executor" pool-size="10" />
<task:scheduled-tasks scheduler="scheduler">
<task:scheduled ref="pepsiIntgService" method="readFile"
cron="${cronstring}" />
</task:scheduled-tasks>
<!-- <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="5" /> <property name="maxPoolSize" value="10"
/> <property name="queueCapacity" value="25" /> </bean> <bean id="taskExecutorExample"
class="TaskExecutorExample"> <constructor-arg ref="taskExecutor" /> </bean> -->
</beans:bean>
以下是部署到JCS-SaaS后的日志
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 来自类路径资源的XML文档中的第33行 [pepsiServlet-context.xml]无效;嵌套异常是 org.xml.sax.SAXParseException; lineNumber:33; columnNumber:62; cvc-complex-type.2.4.a:找到无效的内容 元素资源&#39;。之一 &#39; {&#34; http://www.springframework.org/schema/beans&#34;:进口, &#34; http://www.springframework.org/schema/beans&#34;:别名, &#34; http://www.springframework.org/schema/beans&#34;:豆, WC [##其它:&#34; http://www.springframework.org/schema/beans&#34], &#34; http://www.springframework.org/schema/beans&#34;:豆}&#39;是期待。在 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404) 在 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) 在 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) 在 org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) 在 org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) 在 org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) 在 org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) 在 org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) 在 org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) 在 org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) 在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) 在 org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402) 在 org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316) 在 org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282) 在 org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126) 在javax.servlet.GenericServlet.init(GenericServlet.java:241)at weblogic.servlet.internal.StubSecurityHelper $ ServletInitAction.run(StubSecurityHelper.java:283) 在 weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) 在 weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) 在 weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64) 在 weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58) 在 weblogic.servlet.internal.StubLifecycleHelper。(StubLifecycleHelper.java:48) 在 weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539) 在 weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:2037) 在 weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:2011) 在 weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1930) 在 weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3226) 在 weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1529) 在 weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:488) 在 weblogic.application.internal.flow.ModuleStateDriver $ 3.next(ModuleStateDriver.java:425) 在 weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) 在 weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) 在 weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200) 在 weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247) 在 weblogic.application.internal.flow.ModuleStateDriver $ 3.next(ModuleStateDriver.java:425) 在 weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) 在 weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) 在 weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27) 在 weblogic.application.internal.BaseDeployment $ 2.next(BaseDeployment.java:671) 在 weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) 在 weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212) 在 weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44) 在 weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161) 在 weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:84) 在 weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:573) 在 weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150) 在 weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116) 在 weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:327) 在 weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:849) 在 weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1273) 在 weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:441) 在 weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163) 在 weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:217) 在 weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access $ 100(DeploymentReceiverCallbackDeliverer.java:14) 在 weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer $ 2.run(DeploymentReceiverCallbackDeliverer.java:69) 在 weblogic.work.SelfTuningWorkManagerImpl $ WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550) 在weblogic.work.ExecuteThread.execute(ExecuteThread.java:268)at weblogic.work.ExecuteThread.run(ExecuteThread.java:226)引起: org.xml.sax.SAXParseException; lineNumber:33; columnNumber:62; cvc-complex-type.2.4.a:找到无效的内容 元素资源&#39;。之一 &#39; {&#34; http://www.springframework.org/schema/beans&#34;:进口, &#34; http://www.springframework.org/schema/beans&#34;:别名, &#34; http://www.springframework.org/schema/beans&#34;:豆, WC [##其它:&#34; http://www.springframework.org/schema/beans&#34], &#34; http://www.springframework.org/schema/beans&#34;:豆}&#39;是期待。在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator $ XSIErrorReporter.reportError(XMLSchemaValidator.java:452) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1790) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:760) 在 com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl $ FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) 在 com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) 在 com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) 在 com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) 在 com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:338) 在 weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:165) 在 org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75) 在 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) ......还有57个
如果需要更改文件,请帮助我,谢谢
答案 0 :(得分:1)
文件pepsiServlet-context.xml中的此标记
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
不正确版本或旧版本,我使用:
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
使用带有方向的正确标记URL xsd,该情况仅使用 bean
答案 1 :(得分:0)
我在XML
文件中看到了2个问题:
结束标记不正确,应该是:
</beans:beans> (not </beans:bean>)
因此,与pepsiServlet-context.xml
对应的XML文档不是well-formed,因此无法对其进行解析。
resources
您的第二个问题与以下事实有关:您忘记将前缀 mvc
添加到resources
,这会使您的XML文件无效,它应该是:
<mvc:resources mapping="/resources/**" location="/resources/" />