Announcement Announcement Module
Collapse
No announcement yet.
Problems with referencing config files that are in a jar file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with referencing config files that are in a jar file

    Hi,

    I have a main applicationContext.xml file with similar content (several imports):

    Code:
    <beans>
    	<import resource="base.xml"/> <!-- it's in a jar-->
    
    	<import resource="masterdata.xml"/><!-- it's placed to ../WEB-INF/classes-->
    </beans>
    I get an error

    Code:
    "Invalid relative resource location 'base.xml'	applicationContext.xml...".
    It seems to me that the plugin only looks into ../WEB-INF/classes and do not fetch the file from the lib that's on the classpath too. The application works fine, but the message is annoying.

    Do you have a clue on that (other than filter out Spring-API messages from Problems view)?

    Thanks,

    Gabor

  • #2
    Gabor,

    yes, the current version of Spring IDE is not able to handle imported config files. Only imported config files which are located relatively to the main config are detected. Detecting means only the existance of the include file is checked.

    Classpath resources (if indicated by the prefix "classpath:") are ignored.

    With the next version of Spring IDE we will skip include statements during validation.

    As a workaround for the current version of Spring IDE use a config set containing all the included config files (don't add the main config file).

    Cheers
    Torsten

    Comment


    • #3
      Config Set Problem

      I have two config files (one in a jar and one under my WEB-INF) and I created a config set for them. I would like the config in my jar to recognize the beans in my WEB-INF, but SpringIDE and Spring aren't finding them. Attached is a screenshot of my dilemma. You can see that I have a bean called dataSource and my external config is complaining about not finding dataSource, and they are both in the same config set.

      Note that I do not use the import and am not sure if I need to. I have this in my WEB-INF:
      Code:
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml,classpath*:applicationContext.xml</param-value>
      </context-param>
      ...
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      I started off with only the applicationContext.xml in my jar and this picked it up fine. When I moved some of the beans into a config under the WEB-INF, they could not be found.
      Any guidance?

      Comment


      • #4
        Originally posted by qkerby
        and I created a config set for them.
        How did you create a config set containing a config file stored in a jar file? Spring IDE is only able to handle config files stored in the filesystem.

        Originally posted by qkerby
        Attached is a screenshot of my dilemma. You can see that I have a bean called dataSource and my external config is complaining about not finding dataSource, and they are both in the same config set.
        The error message shown in the screenshoot is created by the XML parser while parsing your config file referencing the dataSource bean. It indicates that the referenced ID "dataSource" is not defined within the same XML document. To get rid of this error use "<[id]ref bean=" instead of "<[id]ref local=". This way the XML parser doesn't expect the referenced ID within the same XML document.

        Torsten

        Comment


        • #5
          Referencing applicationContext file from inside a jar file.

          Hello,

          I am trying to do something very similar. I have serveral layers in my application that can be packaged up differently depending on if I am testing, releasing a new product with a different mix of frameworks, like JSF, Struts, Java WebServices, EJBs, Spring, Hibernate, iBATIS. So with that said I need to be able to jar up my spring service layer (including the pplicationContext and the other related xml files i.e hibernate and iBATIS xml files) and run a standalone test program to test my Java Webservices which by the way uses my spring service layer to access my business models and data stored in a database. How do I do that? I would to keep all the spring configuration files in the jar file so it stays together with the classes.

          Thanks in Advance.

          Tonte

          Comment

          Working...
          X