Robby Pelssers schrieb:

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.xsd

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-blockdeployment-protocol.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.context.support.ClassPathXmlApplicationContext

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)

at java.security.AccessController.doPrivileged(Native Method)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.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.java:81)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Caused by: java.lang.ClassCastException: org.springframework.context.support.ClassPathXmlApplicationContext

at org.apache.cocoon.blockdeployment.BlockContextURLStreamHandlerFactory.setApplicationContext(BlockContextURLStreamHandlerFactory.java:55)

at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:70)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1331)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)

... 28 more


Caused by: java.lang.ClassCastException: org.springframework.context.support.ClassPathXmlApplicationContext

at org.apache.cocoon.blockdeployment.BlockContextURLStreamHandlerFactory.setApplicationContext(BlockContextURLStreamHandlerFactory.java:55)


That line reads:
WebApplicationContext webApplicationContext = (WebApplicationContext) applicationContext;

Which basically means the block deployment subproject is for web apps.

See also http://cocoon.apache.org/subprojects/block-deployment/1.1/1471_1_1.html


Regards,
Steven

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to