Announcement Announcement Module
Collapse
No announcement yet.
Spring Resources loading in dependant jars. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Resources loading in dependant jars.

    I'm trying to get a handle setting up beans within a war file containing dependant spring jars. The dependent jars don’t seem to be able to locate the Resources contained within its own jar. Any imports of spring configuration xml files referenced within the dependent jars all work - but references to resources are lost - Any ideas on how to do this?

    The assumption I'm working to is that each dependant jar contains its own configuration. All I have to do is force its spring configuration to be loaded.

    Web application module:
    - a war file with its spring configuration loaded via its web.xml
    - is dependent upon a jar packaged in its WEB-INF/lib directory
    - has its own ApplicationContext.xml containing following import which initiates context loading in the dependent jar modules.

    <import resource="classpath*:/META-INF/ApplicationContext.xml"/>


    Fragment Directory structure from a dependent jar module.


    Code:
    src/main/resources
                 subscription.xsd
                 META-INF                                                       
                      ApplicationContext.xml
    Fragment from a dependent ApplicationContext.xml
    Code:
    ....
     <bean id="jaxbMarshaller"  class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
        <property name="schema" value="subscription.xsd"/>
        <property name="contextPath" value="com.fred.ws.jaxb"/>
     </bean>            
        ......
    When I load the war in tomcat but I fail to load "jaxbMarshaller" bean because a resource is not found:-
    Resource ServletContext resource [/subscription.xsd] does not exist

    I’ve tried every permutation I can think of but I am at a loss to define the correct schema location
    value="jar:file:SubscriptionWSClient-0.0.1-SNAPSHOT.jar!/subscription.xsd"

    How do I specify the protocol / path to subscription.xsd placed within dependant. Or is there a better approach to the problem I am trying to address.
    Last edited by t2987; Mar 17th, 2011, 03:50 AM.

  • #2
    solved! - I'm sure I'd tried this already.

    solution is:

    <property name="schema" value="classpath:subscription.xsd" />

    Comment

    Working...
    X