Locating configuration resources with tomcat6 and spring3
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
add a comment |
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
add a comment |
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
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
tomcat6 spring-3 spring-mybatis
edited Nov 13 '18 at 15:57
asked Nov 12 '18 at 14:03
mapto
234415
234415
add a comment |
add a comment |
0
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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