Locating configuration resources with tomcat6 and spring3










0














I have a legacy web application using the following setup:



  • Spring 3.1.0

  • Mybatis 3.0.3

  • Tomcat 6.0.43

The project deploys a web application (.war) with multiple maven modules (i.e. .jar dependencies). Now I am struggling to let Tomcat detect mybatis mapper .xml's both in the application and the dependencies.



I have the following definition:



<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath*:*-mappers.xml" />
</bean>


This works fine for detecting the .xml's in the module that is being built as .war. If I replace this with the absolute path to the .xml resources in the .jar, this successfully detects these other resources:



<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="jar:file:/my-repository/my-project/my-app/target/my-app-1.0.0/WEB-INF/lib/my-dependency.jar!/*-mappers.xml" />
</bean>


However, this formulation is way too explicit in that it needs to point both to the path to my dependencies in the deployed application, and the dependency name as well. Furthermore, this second formulation excludes the resources found in the main web application.



So my question is: how should I define my mapperLocations so that it can find the .xml resources both in the .war application and the dependent .jar's, or a full list of dependencies.



I'm debugging the contents of the array that on startup arrives as a parameter into org.mybatis.spring.SqlSessionFactory.setMapperLocations(Resources). This allows me to see what mybatis mapper .xml's are being detected.



A few further details:



  • Te first generic classpath reference successfully detects both resource locations with tomcat8.

  • Even with tomcat6, classes from the .jar dependency are loaded fine. However, apparently tomcat6 has a different way of resolving resources from the classpath.

Update: I've seen that PathMatchingResourcePatternResolver does not tokenise the value of mapperLocations, thus providing multiple values will not be parsed successfully.



Update2: I've extracted the related question of how to make the path pattern as a relative path in a separate question.










share|improve this question




























    0














    I have a legacy web application using the following setup:



    • Spring 3.1.0

    • Mybatis 3.0.3

    • Tomcat 6.0.43

    The project deploys a web application (.war) with multiple maven modules (i.e. .jar dependencies). Now I am struggling to let Tomcat detect mybatis mapper .xml's both in the application and the dependencies.



    I have the following definition:



    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations" value="classpath*:*-mappers.xml" />
    </bean>


    This works fine for detecting the .xml's in the module that is being built as .war. If I replace this with the absolute path to the .xml resources in the .jar, this successfully detects these other resources:



    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations" value="jar:file:/my-repository/my-project/my-app/target/my-app-1.0.0/WEB-INF/lib/my-dependency.jar!/*-mappers.xml" />
    </bean>


    However, this formulation is way too explicit in that it needs to point both to the path to my dependencies in the deployed application, and the dependency name as well. Furthermore, this second formulation excludes the resources found in the main web application.



    So my question is: how should I define my mapperLocations so that it can find the .xml resources both in the .war application and the dependent .jar's, or a full list of dependencies.



    I'm debugging the contents of the array that on startup arrives as a parameter into org.mybatis.spring.SqlSessionFactory.setMapperLocations(Resources). This allows me to see what mybatis mapper .xml's are being detected.



    A few further details:



    • Te first generic classpath reference successfully detects both resource locations with tomcat8.

    • Even with tomcat6, classes from the .jar dependency are loaded fine. However, apparently tomcat6 has a different way of resolving resources from the classpath.

    Update: I've seen that PathMatchingResourcePatternResolver does not tokenise the value of mapperLocations, thus providing multiple values will not be parsed successfully.



    Update2: I've extracted the related question of how to make the path pattern as a relative path in a separate question.










    share|improve this question


























      0












      0








      0







      I have a legacy web application using the following setup:



      • Spring 3.1.0

      • Mybatis 3.0.3

      • Tomcat 6.0.43

      The project deploys a web application (.war) with multiple maven modules (i.e. .jar dependencies). Now I am struggling to let Tomcat detect mybatis mapper .xml's both in the application and the dependencies.



      I have the following definition:



      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="mapperLocations" value="classpath*:*-mappers.xml" />
      </bean>


      This works fine for detecting the .xml's in the module that is being built as .war. If I replace this with the absolute path to the .xml resources in the .jar, this successfully detects these other resources:



      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="mapperLocations" value="jar:file:/my-repository/my-project/my-app/target/my-app-1.0.0/WEB-INF/lib/my-dependency.jar!/*-mappers.xml" />
      </bean>


      However, this formulation is way too explicit in that it needs to point both to the path to my dependencies in the deployed application, and the dependency name as well. Furthermore, this second formulation excludes the resources found in the main web application.



      So my question is: how should I define my mapperLocations so that it can find the .xml resources both in the .war application and the dependent .jar's, or a full list of dependencies.



      I'm debugging the contents of the array that on startup arrives as a parameter into org.mybatis.spring.SqlSessionFactory.setMapperLocations(Resources). This allows me to see what mybatis mapper .xml's are being detected.



      A few further details:



      • Te first generic classpath reference successfully detects both resource locations with tomcat8.

      • Even with tomcat6, classes from the .jar dependency are loaded fine. However, apparently tomcat6 has a different way of resolving resources from the classpath.

      Update: I've seen that PathMatchingResourcePatternResolver does not tokenise the value of mapperLocations, thus providing multiple values will not be parsed successfully.



      Update2: I've extracted the related question of how to make the path pattern as a relative path in a separate question.










      share|improve this question















      I have a legacy web application using the following setup:



      • Spring 3.1.0

      • Mybatis 3.0.3

      • Tomcat 6.0.43

      The project deploys a web application (.war) with multiple maven modules (i.e. .jar dependencies). Now I am struggling to let Tomcat detect mybatis mapper .xml's both in the application and the dependencies.



      I have the following definition:



      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="mapperLocations" value="classpath*:*-mappers.xml" />
      </bean>


      This works fine for detecting the .xml's in the module that is being built as .war. If I replace this with the absolute path to the .xml resources in the .jar, this successfully detects these other resources:



      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="mapperLocations" value="jar:file:/my-repository/my-project/my-app/target/my-app-1.0.0/WEB-INF/lib/my-dependency.jar!/*-mappers.xml" />
      </bean>


      However, this formulation is way too explicit in that it needs to point both to the path to my dependencies in the deployed application, and the dependency name as well. Furthermore, this second formulation excludes the resources found in the main web application.



      So my question is: how should I define my mapperLocations so that it can find the .xml resources both in the .war application and the dependent .jar's, or a full list of dependencies.



      I'm debugging the contents of the array that on startup arrives as a parameter into org.mybatis.spring.SqlSessionFactory.setMapperLocations(Resources). This allows me to see what mybatis mapper .xml's are being detected.



      A few further details:



      • Te first generic classpath reference successfully detects both resource locations with tomcat8.

      • Even with tomcat6, classes from the .jar dependency are loaded fine. However, apparently tomcat6 has a different way of resolving resources from the classpath.

      Update: I've seen that PathMatchingResourcePatternResolver does not tokenise the value of mapperLocations, thus providing multiple values will not be parsed successfully.



      Update2: I've extracted the related question of how to make the path pattern as a relative path in a separate question.







      tomcat6 spring-3 spring-mybatis






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 at 15:57

























      asked Nov 12 at 14:03









      mapto

      234415




      234415



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263803%2flocating-configuration-resources-with-tomcat6-and-spring3%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263803%2flocating-configuration-resources-with-tomcat6-and-spring3%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党