开发者

ant target for junit fails to load spring context xml files

开发者 https://www.devze.com 2023-03-11 07:08 出处:网络
When i run ant target for junit, following error occurs: Configuration problem: Failed to import bean definitions from URL location [classpath:/esw-web-ctx.xml] Offending resource: class path resourc

When i run ant target for junit, following error occurs:

    Configuration problem: Failed to import bean definitions from URL location [classpath:/esw-web-ctx.xml] Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml] Offending resource: class path resource [esw-web-ctx.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]; nested exception is java.net.UnknownHostException: www.springframework.org

    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/esw-web-ctx.xml]
    Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]
    Offending resource: class path resource [esw-web-ctx.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]; nested exception is java.net.UnknownHostException: www.springframework.org
    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).......
......

Ant target:

<target name="junit" depends="buildlocal">  
    <delete dir="${JUNIT_REPORT}" failonerror="false"/>
    <mkdir dir="${BUILD_TEST_DIR}" />
    <mkdir dir="${JUNIT_REPORT}" />
    <echo message="Launching JUnit tests" />    
    <copy todir="${BUILD_TEST_DIR}/" overwrite="true">
        <fileset dir="${COMP_TESTCONFIG_DIR}">
            <exclude name="*.properties.template" />
            <exclude name="*.xml.template" />
            <exclude name="*.ccf.template" />
            <exclude name="**/*.bak" />
            <exclude name="**/*.keep" />
            <exclude name="**/*.keep.*" />
            <exclude name="**/*.contrib" />
            <exclude name="**/*.java" />
            <exclude name="**/*.class" />
            <exclude name="**/*.contrib.*" />
        </fileset>
    </copy>  
    <junit printsummary="on" fork="off" haltonfailure="false" failureproperty="junit.failure" showoutput="false">
        <classpath>
            <path refid="CLASSPATH_JUNIT"/>             
        </classpath>            
        <batchtest fork="off"  todir="${BUILD_TEST_DIR}">
           <fileset dir="${TEST_CLASSES_DIR}">
              <include name="**/*Test.class" />
              <include name="**/Test*.class" />     
              <!-- <exclude name="**/EswCacheInitializerTest.class" /> -->      
           </fileset> 
        </batchtest>
        <formatter type="xml" />
    </junit>        
    <echo message="Launching junitreport" />    
    <junitreport todir="${JUNIT_REPORT}">
        <fileset dir="${BUILD_TEST_DIR}">
            <include name="TEST-*.xml" />           
        </fileset>       
        <report format="frames" todir="${JUNIT_REPORT}"/>       
    </junitreport>
    <delete dir="${BUILD_TEST_DIR}" failonerror="false"/>       
    <echo message="**** Junit report generated at the location: ${JUNIT_REPORT} ***"/>
    <echo message="==============================================="/>
    <echo message="******  JUNIT BUILD ENDS - CORE    ******      "/>
    <echo message="==============================================="/>
    <fail if="junit.failure" message="Unit test(s) failed.  See reports at: ${JUNIT_REPORT}"/>
</target>
<path id="CLASSPATH_JUNIT">
    <path refid="LIB_JAVAC"/>
    <pathelement location="${TEST_CLASSES_DIR}" />
    <pathelement location="${BUILD_TEST_DIR}" />
    <pathelement location="${APP_DIR}\bgc-esw-core\target\classes" />
    <pathelement location="${APP_DIR}\bgc-esw-web\target\classes" />
    <pathelement location="${APP_DIR}\bgc-esw-wicket-components\target\classes" />  
    <fileset dir="${BUILD_LIBS_HOME}">
        <include name="*.jar" />
    </fileset>  
    <fileset dir="${APP_DIR}\bgc-esw-web\build" erroronmissingdir="false">
        <include nam开发者_StackOverflow社区e="bgc-esw-*.jar" />            
    </fileset>  
    <fileset dir="${APP_DIR}\bgc-esw-services\build" erroronmissingdir="false">
        <include name="bgc-esw-service*.jar" />
    </fileset>  
    <fileset dir="${APP_DIR}\bgc-esw-core\build" erroronmissingdir="false">
        <include name="bgc-esw-core*.jar" />
    </fileset>  
    <fileset dir="${APP_DIR}\bgc-esw-wicket-components\build" erroronmissingdir="false">
        <include name="bgc-esw-wicket-components*.jar" />
    </fileset>  
</path>


Check the XML namespaces definitions in that application context definition. It typically contains something like this:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">

I bet that some of the spring XSD files are not in the jars on your classpath; all these should be locally on your system and not downloaded from web.

0

精彩评论

暂无评论...
验证码 换一张
取 消