0

I'm working on a multi-module project which contains a service and an integration-tests module. In the service module there is a service for some reset password functionality, based on Spring greenhouse which is using a template file which is expected to be loaded on initialization. While trying to solve this issue I changed slightly the initialization of the class based on the loaded file and moved it to xml configuration:

<bean id="resetPasswordMailMessageConverter" class="com.myapp.service.reset.ResetPasswordMailMessageConverter">
    <constructor-arg name="resource">
        <value>classpath*:**/spring/reset-password.st</value>
    </constructor-arg>
</bean>

The service works fine once deployed and used in tomcat but there are issues when integration tests are executed : Unable to read template resource class path resource [classpath*:**/spring/reset-password.st] I placed that file in both places serviceModule/META-INF/spring/ and integrationTestsModule/META-INF/spring/ but still it can't be found.

I placed some code both in service and in integration tests where I export the result of ClassLoader.getSystemResources("META-INF") and noticed that in both cases the integrationModule/target/test-classes/META-INF and the .m2/repository/../serviceModule.jar!META-INF are included in the exported path and the file is contained inside both META-INF/spring/ but not found.

I tried also keeping the file in the same package with the converter and initializing converter's resource as new ClassPathResource("reset-password.st", getClass().getClassLoader()) or new ClassPathResource("reset-password.st") but didn't work.

The structure of the project is mainModule->[mainSubmoduleA->[serviceModule, integrationTestsModule, etc], mainSubmoduleB[other modules]]

Any idea?

There's a basic layout of the project structure enter image description here

Parts of the pom files:

main:

...........

<groupId>com.myapp</groupId>
<artifactId>mainModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
.............
<modules>
    <module>mainSubmoduleA</module>
    <module>mainSubmoduleB</module>
</modules>

mainSubmoduleA:

..............
<parent>
    <groupId>com.myapp</groupId>
    <artifactId>mainModule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
.........

<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba</groupId>
<artifactId>mainSubmoduleA</artifactId>
<packaging>pom</packaging>
<name>mainSubmoduleA</name>
..........

<modules>
  <module>subModuleAA</module>
</modules>
...............

subModuleAA:

<parent>
  <groupId>com.myapp.mainsuba</groupId>
  <artifactId>mainSubmoduleA</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba.subaa</groupId>
<artifactId>subModuleAA</artifactId>
<packaging>pom</packaging>
<name>subModuleAA</name>
..........

<modules>
  <module>service</module>
  <module>web</module>
  <module>integration</module>
</modules>

service:

<parent>
  <groupId>com.myapp.mainsuba.subaa</groupId>
  <artifactId>subModuleAA</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba.service</groupId>
<artifactId>service</artifactId>
<packaging>jar</packaging>
<name>service</name>

web:

<parent>
  <groupId>com.myapp.mainsuba.subaa</groupId>
  <artifactId>subModuleAA</artifactId>
 <version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba.web</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<name>web</name>

integration:

<parent>
  <groupId>com.myapp.mainsuba.subaa</groupId>
  <artifactId>subModuleAA</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>integration</artifactId>
<packaging>jar</packaging>
<name>integration</name>
<description>Integration Tests</description>
Chris
  • 549
  • 1
  • 5
  • 18

1 Answers1

0

Chris,

try setting the resource value without any ant-style wildcard matchers. I.e.:

<value>META-INF/spring/reset-password.st</value>

More info on wildcard restrictions can be found here: Other notes relating to wildcards