Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 47301 invoked from network); 15 May 2009 15:46:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 May 2009 15:46:56 -0000 Received: (qmail 51037 invoked by uid 500); 15 May 2009 15:46:55 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 50966 invoked by uid 500); 15 May 2009 15:46:55 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 50958 invoked by uid 99); 15 May 2009 15:46:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 May 2009 15:46:55 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [88.198.46.98] (HELO indoqa.com) (88.198.46.98) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 May 2009 15:46:43 +0000 Received: from [192.168.0.132] (chello062178215074.10.15.vie.surfer.at [62.178.215.74]) by indoqa.com (Postfix) with ESMTP id 2EBBE25733A for ; Fri, 15 May 2009 17:46:22 +0200 (CEST) Message-ID: <4A0D8E54.8010809@indoqa.com> Date: Fri, 15 May 2009 17:46:28 +0200 From: Steven Dolg User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: ClassCastException in cocoon-block-deployment when running junit test [cocoon-3] and using cocoon-spring-configurator References: <7C655C04B6F59643A1EF66056C0E095E0241CAA7@eusex01.sweden.ecsoft> In-Reply-To: <7C655C04B6F59643A1EF66056C0E095E0241CAA7@eusex01.sweden.ecsoft> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org 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_* > > > > > 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"> > > > > > > > > > > > > *_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.(ClassPathXmlApplicationContext.java:139) > > at > org.springframework.context.support.ClassPathXmlApplicationContext.(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: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org