Tiles Config bean 抛出异常:TestNG+Spring 3+Tiles2

发布于 2024-11-30 18:02:14 字数 12076 浏览 1 评论 0原文

我正在尝试运行 TestNG+Spring+JPA+Hibernate 'Hello World' 测试。执行结果出现 NullPointerException,tiles 配置器 bean 失败。

例外:

2011-08-20 18:12:18,547 [main] INFO  org.springframework.web.servlet.view.tiles2.TilesConfigurer  - TilesConfigurer: adding definitions [/WEB-INF/tiles/tiles.xml]
        2011-08-20 18:12:18,552 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory  - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@68cb6b: defining beans [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler#0,org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor#0,org.springframework.security.methodSecurityMetadataSourceAdvisor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,nethawalaDS,jspViewResolver,tilesViewResolver,tilesConfigurer,nethawalaEMF,transactionManager,jpaVendorAdapter,validator,auditLog,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,logoutHandlerBean,userDetailsService,customAuthenticationFailureHandlerBean,customAuthenticationSuccessHandlerBean,httpSessionEventListener,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.scheduling.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.internalScheduledAnnotationProcessor,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,homeController,userSessionController,NHUserDAOImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,nethawalaProperties,placeholderConfig]; root of factory hierarchy
        2011-08-20 18:12:18,563 [main] ERROR org.springframework.test.context.TestContextManager  - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@fdfc58] to prepare test instance [com.tigermindz.test.FacultyDaoTest@1afae45]
        java.lang.IllegalStateException: Failed to load ApplicationContext
            at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
            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.testng.AbstractTestNGSpringContextTests.springTestContextPrepareTestInstance(AbstractTestNGSpringContextTests.java:133)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:76)
            at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
            at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
            at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
            at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
            at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
            at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
            at org.testng.TestRunner.privateRun(TestRunner.java:749)
            at org.testng.TestRunner.run(TestRunner.java:600)
            at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
            at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
            at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
            at org.testng.SuiteRunner.run(SuiteRunner.java:223)
            at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
            at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
            at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)
            at org.testng.TestNG.runSuitesLocally(TestNG.java:964)
            at org.testng.TestNG.run(TestNG.java:900)
            at org.testng.TestNG.privateMain(TestNG.java:1182)
            at org.testng.TestNG.main(TestNG.java:1146)
        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in class path resource [nethawala-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
            at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
            at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
            at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
            at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
            ... 28 more
        Caused by: java.lang.NullPointerException
            at org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext.(SpringTilesApplicationContextFactory.java:72)
            at org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory.createApplicationContext(SpringTilesApplicationContextFactory.java:55)
            at org.springframework.web.servlet.view.tiles2.TilesConfigurer.afterPropertiesSet(TilesConfigurer.java:335)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
            ... 41 more

我的applicationContext.xml,只显示tiles配置bean def:

<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
    <list>
        <value>/WEB-INF/tiles/tiles.xml</value>
    </list>
</property>
</bean>

做了很多谷歌搜索,唯一发现的是,人们提到了cglib和/或asm jars与spring和hibernate依赖项冲突。我不认为这适用于这里,但是我的 lib 文件夹有以下 jar,抱歉不按顺序:

    ./tiles-template-2.2.2.jar
    ./spring-security-acl-3.0.5.RELEASE.jar
    ./org.springframework.context-3.0.5.RELEASE.jar
    ./hibernate-jpa-2.0-api-1.0.0.Final.jar
    ./tiles-api-2.2.2.jar
    ./validation-api-1.0.0.GA.jar
    ./org.springframework.web.servlet-3.0.5.RELEASE.jar
    ./hsqldb.jar
    ./spring-security-taglibs-3.0.5.RELEASE.jar
    ./commons-pool-1.5.6.jar
    ./aspectjrt-1.6.8.jar
    ./commons-beanutils-1.8.3.jar
    ./org.springframework.aop-3.0.5.RELEASE.jar
    ./spring-security-core-3.0.5.RELEASE.jar
    ./commons-collections-3.1.jar
    ./org.springframework.web-3.0.5.RELEASE.jar
    ./jstl-1.2.jar
    ./org.springframework.expression-3.0.5.RELEASE.jar
    ./dom4j-1.6.1.jar
    ./org.springframework.orm-3.0.5.RELEASE.jar
    ./log4j-1.2.16.jar
    ./org.springframework.beans-3.0.5.RELEASE.jar
    ./tiles-servlet-2.2.2.jar
    ./poi-3.7-20101029.jar
    ./spring-security-aspects-3.0.5.RELEASE.jar
    ./slf4j-api-1.6.1.jar
    ./aopalliance-1.0.jar
    ./slf4j-simple-1.6.1.jar
    ./hibernate3.jar
    ./slf4j-ext-1.6.1.jar
    ./spring-security-web-3.0.5.RELEASE.jar
    ./jta-1.1.jar
    ./asm-3.3.1.jar
    ./org.springframework.test-3.0.5.RELEASE.jar
    ./spring-security-config-3.0.5.RELEASE.jar
    ./org.springframework.core-3.0.5.RELEASE.jar
    ./org.springframework.asm-3.0.5.RELEASE.jar
    ./tiles-jsp-2.2.2.jar
    ./testng-6.0.1.jar
    ./commons-digester-2.1.jar
    ./commons-logging-1.1.1.jar
    ./org.springframework.transaction-3.0.5.RELEASE.jar
    ./javax.inject.jar
    ./commons-dbcp-1.4.jar
    ./slf4j-log4j12-1.6.1.jar
    ./hibernate-validator-4.1.0.Final.jar
    ./javassist-3.12.0.GA.jar
    ./tiles-core-2.2.2.jar
    ./aspectjweaver-1.6.8.jar
    ./org.springframework.jdbc-3.0.5.RELEASE.jar
    ./jackson-all-1.7.5.jar
    ./jstl-api-1.2.jar
    ./antlr-2.7.6.jar
    ./cglib-2.2.jar

测试类如下:

@ContextConfiguration(locations = { "classpath:test-servlet.xml" })
public class FacultyDaoTest extends AbstractTransactionalTestNGSpringContextTests {

    private final XLogger logger = XLoggerFactory.getXLogger(FacultyDaoTest.class);

    @Inject
    FacultyDAO facultyDao;

    @BeforeClass
    public void setUp() {
        logger.entry();    
        System.out.println("Inside setup");    
    }

    @Test(groups = { "fast" })
    @Rollback(value = false)
        public void createFaculty() {
        Faculty f = new Faculty();
        f.setFirstName("John");
        f.setLastName("Frost");
        f.setCpsoNumber("23198");

        f = facultyDao.makePersistent(f);

        assert(f.getId() > 0);    
    }

    @Test(groups = { "fast" })
    public void aFastTest() {
        logger.entry();    
        logger.info("Inside a Fast test");
    }

    @Test(groups = { "slow" })
    public void aSlowTest() {
        logger.entry();    
        logger.info("Inside a Slow test");
    }
}

任何指针将不胜感激。

I'm trying to run a TestNG+Spring+JPA+Hibernate 'Hello World' test. The execution results in a NullPointerException, the tiles configurer bean fails.

The exception:

2011-08-20 18:12:18,547 [main] INFO  org.springframework.web.servlet.view.tiles2.TilesConfigurer  - TilesConfigurer: adding definitions [/WEB-INF/tiles/tiles.xml]
        2011-08-20 18:12:18,552 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory  - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@68cb6b: defining beans [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler#0,org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor#0,org.springframework.security.methodSecurityMetadataSourceAdvisor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,nethawalaDS,jspViewResolver,tilesViewResolver,tilesConfigurer,nethawalaEMF,transactionManager,jpaVendorAdapter,validator,auditLog,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,logoutHandlerBean,userDetailsService,customAuthenticationFailureHandlerBean,customAuthenticationSuccessHandlerBean,httpSessionEventListener,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.scheduling.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.internalScheduledAnnotationProcessor,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,homeController,userSessionController,NHUserDAOImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,nethawalaProperties,placeholderConfig]; root of factory hierarchy
        2011-08-20 18:12:18,563 [main] ERROR org.springframework.test.context.TestContextManager  - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@fdfc58] to prepare test instance [com.tigermindz.test.FacultyDaoTest@1afae45]
        java.lang.IllegalStateException: Failed to load ApplicationContext
            at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
            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.testng.AbstractTestNGSpringContextTests.springTestContextPrepareTestInstance(AbstractTestNGSpringContextTests.java:133)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:76)
            at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
            at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
            at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
            at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
            at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
            at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
            at org.testng.TestRunner.privateRun(TestRunner.java:749)
            at org.testng.TestRunner.run(TestRunner.java:600)
            at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
            at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
            at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
            at org.testng.SuiteRunner.run(SuiteRunner.java:223)
            at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
            at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
            at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)
            at org.testng.TestNG.runSuitesLocally(TestNG.java:964)
            at org.testng.TestNG.run(TestNG.java:900)
            at org.testng.TestNG.privateMain(TestNG.java:1182)
            at org.testng.TestNG.main(TestNG.java:1146)
        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in class path resource [nethawala-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
            at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
            at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
            at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
            at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
            ... 28 more
        Caused by: java.lang.NullPointerException
            at org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext.(SpringTilesApplicationContextFactory.java:72)
            at org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory.createApplicationContext(SpringTilesApplicationContextFactory.java:55)
            at org.springframework.web.servlet.view.tiles2.TilesConfigurer.afterPropertiesSet(TilesConfigurer.java:335)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
            ... 41 more

My applicationContext.xml, only showing the tiles config bean def:

<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
    <list>
        <value>/WEB-INF/tiles/tiles.xml</value>
    </list>
</property>
</bean>

Did a lot of googling, only thing found, people mentioned about cglib and/or asm jars in conflict with spring and hibernate dependencies. I don't think that is applicable here however my lib folder has the following jars, sorry not in order:

    ./tiles-template-2.2.2.jar
    ./spring-security-acl-3.0.5.RELEASE.jar
    ./org.springframework.context-3.0.5.RELEASE.jar
    ./hibernate-jpa-2.0-api-1.0.0.Final.jar
    ./tiles-api-2.2.2.jar
    ./validation-api-1.0.0.GA.jar
    ./org.springframework.web.servlet-3.0.5.RELEASE.jar
    ./hsqldb.jar
    ./spring-security-taglibs-3.0.5.RELEASE.jar
    ./commons-pool-1.5.6.jar
    ./aspectjrt-1.6.8.jar
    ./commons-beanutils-1.8.3.jar
    ./org.springframework.aop-3.0.5.RELEASE.jar
    ./spring-security-core-3.0.5.RELEASE.jar
    ./commons-collections-3.1.jar
    ./org.springframework.web-3.0.5.RELEASE.jar
    ./jstl-1.2.jar
    ./org.springframework.expression-3.0.5.RELEASE.jar
    ./dom4j-1.6.1.jar
    ./org.springframework.orm-3.0.5.RELEASE.jar
    ./log4j-1.2.16.jar
    ./org.springframework.beans-3.0.5.RELEASE.jar
    ./tiles-servlet-2.2.2.jar
    ./poi-3.7-20101029.jar
    ./spring-security-aspects-3.0.5.RELEASE.jar
    ./slf4j-api-1.6.1.jar
    ./aopalliance-1.0.jar
    ./slf4j-simple-1.6.1.jar
    ./hibernate3.jar
    ./slf4j-ext-1.6.1.jar
    ./spring-security-web-3.0.5.RELEASE.jar
    ./jta-1.1.jar
    ./asm-3.3.1.jar
    ./org.springframework.test-3.0.5.RELEASE.jar
    ./spring-security-config-3.0.5.RELEASE.jar
    ./org.springframework.core-3.0.5.RELEASE.jar
    ./org.springframework.asm-3.0.5.RELEASE.jar
    ./tiles-jsp-2.2.2.jar
    ./testng-6.0.1.jar
    ./commons-digester-2.1.jar
    ./commons-logging-1.1.1.jar
    ./org.springframework.transaction-3.0.5.RELEASE.jar
    ./javax.inject.jar
    ./commons-dbcp-1.4.jar
    ./slf4j-log4j12-1.6.1.jar
    ./hibernate-validator-4.1.0.Final.jar
    ./javassist-3.12.0.GA.jar
    ./tiles-core-2.2.2.jar
    ./aspectjweaver-1.6.8.jar
    ./org.springframework.jdbc-3.0.5.RELEASE.jar
    ./jackson-all-1.7.5.jar
    ./jstl-api-1.2.jar
    ./antlr-2.7.6.jar
    ./cglib-2.2.jar

The test class is as follows:

@ContextConfiguration(locations = { "classpath:test-servlet.xml" })
public class FacultyDaoTest extends AbstractTransactionalTestNGSpringContextTests {

    private final XLogger logger = XLoggerFactory.getXLogger(FacultyDaoTest.class);

    @Inject
    FacultyDAO facultyDao;

    @BeforeClass
    public void setUp() {
        logger.entry();    
        System.out.println("Inside setup");    
    }

    @Test(groups = { "fast" })
    @Rollback(value = false)
        public void createFaculty() {
        Faculty f = new Faculty();
        f.setFirstName("John");
        f.setLastName("Frost");
        f.setCpsoNumber("23198");

        f = facultyDao.makePersistent(f);

        assert(f.getId() > 0);    
    }

    @Test(groups = { "fast" })
    public void aFastTest() {
        logger.entry();    
        logger.info("Inside a Fast test");
    }

    @Test(groups = { "slow" })
    public void aSlowTest() {
        logger.entry();    
        logger.info("Inside a Slow test");
    }
}

Any pointers will be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2024-12-07 18:02:14

您的测试加载了特定于 Web 应用程序的配置文件,但您的测试环境未提供所需的文件:

您需要将特定于 Web 应用程序的配置与无需 Web 应用程序上下文的配置分开。

然后使用无需 Web 应用程序即可运行的测试。

对于您来说,这意味着:删除测试配置的 Tiles 配置。因为在测试中/WEB-INF/tiles/tiles.xml文件不可用。

Your test load a web app specific configuration file, but your test environment does not provide the required files:

You need to separate the Web Application specific configuration from the one the works wihtout web application context.

Then use for the test the one that works without Web Application.

For you that mean: remove the Tiles Configuration for the test configuration. Because in the test the /WEB-INF/tiles/tiles.xml file is not available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文