Results 1 to 5 of 5

Thread: repository:jackson-populator produces "Could not open ServletContext resource [/]"

  1. #1
    Join Date
    Dec 2012
    Posts
    3

    Default repository:jackson-populator produces "Could not open ServletContext resource [/]"

    Hello,
    I'm trying to use the jackson-populator to put some fixed values into a database. However loading the application context always fails with a FileNotFoundException:-
    java.io.FileNotFoundException: Could not open ServletContext resource [/]

    The application context is:-

    Code:
    <?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:context="http://www.springframework.org/schema/context"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:repository="http://www.springframework.org/schema/data/repository"
    	xsi:schemaLocation="http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    	
    	<repository:jackson-populator location="classpath*:/data.json" />
    	
    </beans>
    The data.json file is in src/main/resources/data.json. It seems as if I have specified location="/", though clearly I have not. I also tried having location="classpath:data.json" location="classpath:/data.json" all produce the same results.

    If anyone knows what I've done wrong here i would be greatful if you could point it out.
    Thanks,
    Graeme.

  2. #2
    Join Date
    May 2006
    Posts
    4

    Default

    Hi Graeme

    Are you using spring-data-commons-core version '1.4.0.RELEASE'?

    If so there seems to be a bug, The attribute for the file path is defined in 'location' defined in the xsd for <repository:jackson-populator /> however the ResourceReaderRepositoryPopulatorBeanDefinitionPar ser used to parse the context is looking for a 'locations' attribute. There seems to be a bit of a mis match here.

    I'm not 100% sure on this I have not had time to test properly but this looks to be an issue. Sorry I cant be more help than that.

    Thanks

    Chris

  3. #3
    Join Date
    May 2006
    Posts
    4

  4. #4

    Default

    Quote Originally Posted by k209310 View Post
    Looks good, kind of you for sharing this.

  5. #5
    Join Date
    Dec 2012
    Posts
    3

    Default

    I am using 1.4 and so that bug seems like it must be the problem.

    Thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •