Can't import another Spring configuration file

523 views
Skip to first unread message

Liu Yongjian

unread,
Jul 12, 2010, 7:50:16 PM7/12/10
to play-framework
When I start the Play! application , it complains as follows:

An unexpected error occured caused by exception BeanDefinitionParsingException:
Configuration problem: Invalid relative resource location [sub/spring-context.xml] to import bean definitions from Offending resource: resource loaded through SAX InputSource; nested exception is java.io.FileNotFoundException: Cannot create a relative resource for resource loaded through SAX InputSource

Guillaume Bort

unread,
Jul 13, 2010, 3:53:42 AM7/13/10
to play-fr...@googlegroups.com
You can probably use the ${play.path} placeholder to define an
absolute resource path.

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Liu Yongjian

unread,
Jul 13, 2010, 9:16:00 AM7/13/10
to play-fr...@googlegroups.com
${play.path}  refers to the absolute path of Play! framework
we need to specifiy the absolute path of Play! Application

Guillaume Bort

unread,
Jul 13, 2010, 9:18:23 AM7/13/10
to play-fr...@googlegroups.com
Ah yes, so ${application.path}

Liu Yongjian

unread,
Jul 13, 2010, 9:25:33 AM7/13/10
to play-fr...@googlegroups.com
Here is my examples:

Suppose I define two Spring configuration file,  one is ${myapp.path}/conf/application-context.xml and the other is ${myapp.path}/conf/finportfolio/spring-context.xml

Now I want to import spring-context.xml into application-context.xml, so I put a statement in application-context.xml :

// application-context.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:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://www.springframework.org/schema/aop
  http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <import resource="finportfolio/spring-context.xml"/>

  ....
</beans>



However, when I start the Play! application, it complains :



An unexpected error occured caused by exception BeanDefinitionParsingException:
Configuration problem: Invalid relative resource location [sub/spring-context.xml] to import bean definitions from Offending resource: resource loaded through SAX InputSource; nested exception is java.io.FileNotFoundException: Cannot create a relative resource for resource loaded through SAX InputSource



How to define an  absolute resource path for spring-context.xml???

Liu Yongjian

unread,
Jul 13, 2010, 9:26:00 AM7/13/10
to play-fr...@googlegroups.com
Let me try

Liu Yongjian

unread,
Jul 13, 2010, 9:29:44 AM7/13/10
to play-fr...@googlegroups.com
Hi Bort

 <import resource="${application.path}/finportfolio/spring-context.xml"/>   doesn't work properly. It prints the same error

Liu Yongjian

unread,
Jul 14, 2010, 3:29:39 AM7/14/10
to play-fr...@googlegroups.com
Any solution ?

Oded Peer

unread,
Jul 15, 2010, 2:11:10 AM7/15/10
to play-framework
You should mark your imported resource as a file resource.
I tried it in my server and it works fine:

<import resource="file:/${application.path}/conf/fin/spring-
context.xml"/>

Nicolas, this should also be added to the Spring plugin documentation

Nicolas Leroux

unread,
Jul 15, 2010, 7:57:03 AM7/15/10
to play-fr...@googlegroups.com
Thanks, yes this is true. I will as soon as I have 5 minutes. If someone wants to help, please contact me ;)

Nicolas

Reply all
Reply to author
Forward
0 new messages