当我运行Maven构建时,它显示以下错误

时间:2018-07-06 11:42:05

标签: java xml alfresco alfresco-share

我是Maven的新手。

当我运行Maven构建时,它显示以下错误。

  

无法加载Web应用程序上下文。   在这里,我附加了context-module.xml的xml文件

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building digGovRepo Repository AMP project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ digGovRepo ---
[INFO] Deleting D:\Selva Kumar G\eclipse_workspace\digGovRepo\target
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-sdk-requirements) @ digGovRepo ---
[INFO] 
[INFO] --- alfresco-maven-plugin:2.2.0:set-version (default-set-version) @ digGovRepo ---
[INFO] Removed -SNAPSHOT suffix from version - 1.0
[INFO] Added timestamp to version - 1.0.1807061640
[INFO] 
[INFO] --- build-helper-maven-plugin:1.10:add-test-resource (add-env-test-properties) @ digGovRepo ---
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ digGovRepo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Selva Kumar G\eclipse_workspace\digGovRepo\src\main\resources
[INFO] Copying 17 resources to D:\Selva Kumar G\eclipse_workspace\digGovRepo\target/amp
[INFO] 
[INFO] --- alfresco-maven-plugin:2.2.0:refresh (refresh-webscripts-repo-and-share) @ digGovRepo ---
[WARNING] Connection failed to localhost:8080, null webapp refresh aborted
[INFO] 
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ digGovRepo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to D:\Selva Kumar G\eclipse_workspace\digGovRepo\target\classes
[ERROR] error reading C:\Users\B5451\.m2\repository\com\sun\pdfview\pdfrenderer\0.9.1-patched\pdfrenderer-0.9.1-patched.jar; invalid LOC header (bad signature)
[INFO] 
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ digGovRepo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-properties-to-test-classpath) @ digGovRepo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to alfresco/module/digGovRepo
[INFO] 
[INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-config-to-test-classpath) @ digGovRepo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) @ digGovRepo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\Selva Kumar G\eclipse_workspace\digGovRepo\target\test-classes
[ERROR] error reading C:\Users\B5451\.m2\repository\com\sun\pdfview\pdfrenderer\0.9.1-patched\pdfrenderer-0.9.1-patched.jar; invalid LOC header (bad signature)
[INFO] 
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ digGovRepo ---

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running digGovRepo.digGovRepo.demoamp.test.DemoComponentTest
2018-07-06 16:40:36,938  ERROR [test.context.TestContextManager] [main] Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@3336e6b6] to prepare test instance [digGovRepo.digGovRepo.demoamp.test.DemoComponentTest@7c3fdb62]
 java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:103)
    at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:284)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    at com.tradeshift.test.remote.RemoteTestRunner.run(RemoteTestRunner.java:73)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:alfresco/module-context.xml]
Offending resource: class path resource [alfresco/application-context.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:alfresco/module/*/module-context.xml]
Offending resource: URL [jar:file:/C:/Users/B5451/.m2/repository/org/alfresco/alfresco-repository/5.1.e/alfresco-repository-5.1.e.jar!/alfresco/module-context.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:alfresco/module/digGovRepo/context/bootstrap-context.xml]
Offending resource: file [D:\Selva Kumar G\eclipse_workspace\digGovRepo\target\test-classes\alfresco\module\digGovRepo\module-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 6 in XML document from class path resource [alfresco/module/digGovRepo/context/bootstrap-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 78; Document root element "beans", must match DOCTYPE root "xml".
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:248)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:199)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:147)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:101)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:495)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadBeanDefinitions(AbstractGenericContextLoader.java:233)
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:117)
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:102)
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:246)
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:69)
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:95)
    ... 27 more
Tests run: 3, Failures: 0, Errors: 3, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.262 s
[INFO] Finished at: 2018-07-06T16:40:39+05:30
[INFO] Final Memory: 42M/225M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project digGovRepo: There are test failures.
[ERROR] 
[ERROR] Please refer to D:\Selva Kumar G\eclipse_workspace\digGovRepo\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

上下文文件:

<?xml version='1.0' encoding='UTF-8'?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <!-- This is filtered by Maven at build time, so that module name is single sourced. -->
    <!-- Note. The bootstrap-context.xml file has to be loaded first.
                Otherwise your custom models are not yet loaded when your service beans are instantiated and you
                cannot for example register policies on them. -->
    <import resource="classpath:alfresco/module/${project.artifactId}/context/bootstrap-context.xml" />
    <import resource="classpath:alfresco/module/${project.artifactId}/context/service-context.xml" />
    <import resource="classpath:alfresco/module/${project.artifactId}/context/webscript-context.xml" />

</beans>

2 个答案:

答案 0 :(得分:0)

如果仔细阅读堆栈跟踪,您会发现您的XML配置文件存在格式问题:

Line 6 in XML document from class path resource [alfresco/module/digGovRepo/context/bootstrap-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 78; Document root element "beans", must match DOCTYPE root "xml".

您还在使用XML配置吗?现在该考虑Spring Boot和注释驱动的配置了。

您使用的是哪个版本的Spring?我们现在到了5.x。

答案 1 :(得分:0)

并非一开始就必须执行单元测试,因此请尝试通过执行mvn clean install -DskipTests

来跳过测试