Hi all,
I've been trying for quite some time to get a simple unit test working for a cocoon 3-block where I'm also using the 'cocoon-spring-configurator'. I added the files involved because I have no clue if this is a configuration problem somehow giving me the stacktrace below. Anybody who can help me out here? Many thx in advance. Robby src/main/resources/applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:configurator="http://cocoon.apache.org/schema/configurator" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util" xmlns:pipeline="http://cocoon.apache.org/schema/pipeline" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://cocoon.apache.org/schema/configurator http://cocoon.apache.org/schema/configurator/cocoon-configurator-1.0.1.x sd http://cocoon.apache.org/schema/pipeline http://cocoon.apache.org/schema/pipeline/cocoon-pipeline-1.0.xsd"> <configurator:settings /> <bean name="spider" class="com.nxp.spider.Spider" > <property name="settings" ref="settings"/> </bean> </beans> com.nxp.spider.Spider.java package com.nxp.spider; import org.apache.cocoon.configuration.Settings; public class Spider { private Settings settings; public void setSettings(Settings settings) { this.settings = settings; } public Settings getSettings() { return this.settings; } public String getRunningMode() { return getSettings().getRunningMode(); } public String toString() { return "Application running in mode '" + getRunningMode() + "'."; } } com.nxp.spider.test.SpiderTest package com.nxp.spider.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.nxp.spider.Spider; import junit.framework.TestCase; public class SpiderTest extends TestCase { private ApplicationContext appContext; protected void setUp() throws Exception { super.setUp(); appContext = new ClassPathXmlApplicationContext("application-context.xml"); } protected void tearDown() throws Exception { appContext = null; super.tearDown(); } public void testSpider() { Spider spider = (Spider) appContext.getBean("spider"); assertNotNull(spider); } } StackTrace when running SpiderTest [eclipse] or when running $ mvn test -Dorg.apache.cocoon.mode=dev [cygwin]. I have declared junit 4.4 as dependency. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cocoon.blockdeployment.BlockContextURLStreamHandlerFactory' defined in URL [jar:file:/D:/maven/repo/org/apache/cocoon/cocoon-block-deployment/1.0.0 /cocoon-block-deployment-1.0.0.jar!/META-INF/cocoon/spring/cocoon-blockd eployment-protocol.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.context.support.ClassPathXmlApplicationContext at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObjec t(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.g etSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean( AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab stractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab stractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.pre InstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBea nFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(A bstractApplicationContext.java:380) at org.springframework.context.support.ClassPathXmlApplicationContext.<init >(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init >(ClassPathXmlApplicationContext.java:83) at com.nxp.spider.test.SpiderTest.setUp(SpiderTest.java:16) at junit.framework.TestCase.runBare(TestCase.java:132) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.jav a:81) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4Tes tReference.java:45) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja va:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe stRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe stRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun ner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu nner.java:196) Caused by: java.lang.ClassCastException: org.springframework.context.support.ClassPathXmlApplicationContext at org.apache.cocoon.blockdeployment.BlockContextURLStreamHandlerFactory.se tApplicationContext(BlockContextURLStreamHandlerFactory.java:55) at org.springframework.context.support.ApplicationContextAwareProcessor.pos tProcessBeforeInitialization(ApplicationContextAwareProcessor.java:70) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapable BeanFactory.java:350) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1331) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) ... 28 more
