Announcement Announcement Module
Collapse
No announcement yet.
java.net.MalformedURLException: unknown protocol while migrating from 2.5.6 to 3.0.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.net.MalformedURLException: unknown protocol while migrating from 2.5.6 to 3.0.2

    Hi,

    We are migrating our application from 2.5.6 to 3.0.2. After updating the dependencies in POM, we are getting the following error in our unit tests(sun jdk 1.6.0_13).

    Code:
    TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@629a99eb] to prepare test instance [[email protected]]
    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:333)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
    	at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
    	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
    	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
    	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
    	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
    	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    	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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
    	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vehicleDataSet' defined in class path resource [com/accenture/foundation/common/codetable/codetype-unit-test-dataset-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.dbunit.dataset.xml.FlatXmlDataSet]: Constructor threw exception; nested exception is org.dbunit.dataset.DataSetException: java.net.MalformedURLException: unknown protocol: classpath
    	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:283)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:886)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    	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: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.dbunit.dataset.xml.FlatXmlDataSet]: Constructor threw exception; nested exception is org.dbunit.dataset.DataSetException: java.net.MalformedURLException: unknown protocol: classpath
    	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
    	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:107)
    	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275)
    	... 43 more
    Caused by: org.dbunit.dataset.DataSetException: java.net.MalformedURLException: unknown protocol: classpath
    	at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:353)
    	at org.dbunit.dataset.CachedDataSet.<init>(CachedDataSet.java:81)
    	at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:99)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
    	... 45 more
    Caused by: java.net.MalformedURLException: unknown protocol: classpath
    	at java.net.URL.<init>(URL.java:574)
    	at java.net.URL.<init>(URL.java:464)
    	at java.net.URL.<init>(URL.java:413)
    	at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    	at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    	at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:340)
    	... 52 more
    The bean definition that is giving the exception is :

    Code:
    <bean name="vehicleDataSet" class="org.dbunit.dataset.xml.FlatXmlDataSet">
    		<constructor-arg value="classpath:com/company/foundation/common/codetable/vehicle-dataset.xml" />
    </bean>
    It is to be noted we are having dependency on dbunit-2.4.1.jar.

    With reference to JIRA http://jira.springframework.org/browse/SPR-1530, I would like to understand whether there is a possibility of the bug resurfacing in 3.0.x. It is to be noted that the error does NOT occur in Spring 2.5.6.

    Also, we noticed that this test error is not happening in jdk version 1.6.0_19 where the beans are loading fine

    Code:
    2010-04-14 03:29:59,253 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3bc257: defining beans [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,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,liquibase,dbUnitConnection,dataLoader,vehicleDataSet,airportDataSet,multiCategoryDataSet,cache,transactionManager,keyGenerator,codeRecordDao,codeType,cacheMap,codeService,codeServiceFactory,testCodeService,codeTableConfigurationClasspaths]; root of factory hierarchy
Working...
X