javamavenresources

Can't find resources from another module for maven build


Need help from a maven maven. I used ant for years and then switched to gradle on my projects, so I've never really messed much with maven. On maven projects, there was always an expert that handled it.

So now I've started a new job and have been made responsible for an old project that hasn't been built for some years. Found the source in subversion and checked it out and installed maven and am building.

The project consists of multiple modules with a parent pom. Here is the parent pom file that I've added junit-vintage to to get tests to run.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
    
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties> 
        
  <groupId>com.gs.juror.kiosk.services</groupId>
  <artifactId>KioskServices</artifactId>
  <version>2.0</version>
  <packaging>pom</packaging>

  <name>KioskServices</name>
  <url>http://maven.apache.org</url>

  <scm>
    <developerConnection>scm:svn:svn://cceballo:Superman07!@lexsvn1.gs.acs-inc.com/fedKioskWebservice/trunk/KioskServices/</developerConnection>
  </scm>

  


<repositories>
<!-- 
    <repository>
         <name>repo</name>
         <url>http://lexsvn1test:8081/artifactory/repo</url>
         <id>repo</id>
    </repository>
     -->
    <repository>
        <id>com.springsource.repository.bundles.release</id>
        <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/release</url>
    </repository>

    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>

    <repository>
        <id>central</id>
        <url>https://repo1.maven.org/maven2</url>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
   <!-- Junit dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>5.11.3</version>
        <scope>test</scope>
    </dependency>
     <!-- End of Junit dependencies -->
     <!-- logging -->
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.20.0</version>
    </dependency>
    <!-- End of logging -->
     <!-- Spring dependencies -->
   <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
  <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.0.6.RELEASE</version>
    </dependency>
     <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.0.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-websocket</artifactId>
    <version>4.0.6.RELEASE</version>
    </dependency>      
    <!-- End of spring dependencies -->
    <dependency>
        <groupId>net.sf.oval</groupId>
        <artifactId>oval</artifactId>
        <version>1.84</version>
    </dependency>
    
    
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Crypto</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Commons</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>ConfigurationEngine</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Core</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>WebREST</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gs.juror.kiosk.services</groupId>
        <artifactId>Security</artifactId>
        <version>${project.version}</version>
    </dependency>
    
    
    
  </dependencies>
</dependencyManagement>  
  
  
<dependencies>
   <!-- Junit dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
     <!-- End of Junit dependencies -->
     <!-- logging -->
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.lucee</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.20.0</version>
    </dependency>
    <!-- End of logging -->
    
     <!-- Spring dependencies -->
   <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        </dependency>
  <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        </dependency>
     <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-websocket</artifactId>
    </dependency>
    <!-- End of spring dependencies -->
    <dependency>
        <groupId>net.sf.oval</groupId>
        <artifactId>oval</artifactId>
    </dependency>
</dependencies>  
  
  
  <modules>
    <module>Crypto</module>
    <module>Commons</module>
    <module>ConfigurationEngine</module>
    <module>Core</module>
    <module>WebREST</module>
    <module>Security</module>
  </modules>
  
  
  
  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
        </plugin>
    </plugins>
  </build>
</project>

And I know that maven projects are just supposed to work, so I ran mvn deploy and it failed because the deployment isn't specified. So I ran mvn package to built the files I need to ship to the client and it failed.

Here's the summary:

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   AppTest.testConfigurationLoader_getWorkflowconfigurationByCourtLocation:33 » MissingResource Can't find bundle for base name StartupConfiguration, locale en_US
[ERROR]   AppTest.testConfigurationLoader_loadconfiguration:27 » MissingResource Can't find bundle for base name StartupConfiguration, locale en_US
[ERROR]   AppTest.testConfigurationLoader_write:21 » MissingResource Can't find bundle for base name StartupConfiguration, locale en_US
[INFO] 
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for KioskServices 2.0:
[INFO] 
[INFO] KioskServices ...................................... SUCCESS [  0.009 s]
[INFO] Crypto ............................................. SUCCESS [ 13.360 s]
[INFO] Commons ............................................ SUCCESS [  5.168 s]
[INFO] ConfigurationEngine ................................ FAILURE [  6.527 s]
[INFO] Security ........................................... SKIPPED
[INFO] Core ............................................... SKIPPED
[INFO] WebREST ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  25.727 s
[INFO] Finished at: 2024-11-12T07:29:31-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test (default-test) on project ConfigurationEngine: 

It is failing inside the test AppTest. Here's the code of the test:

public class AppTest {
  
  private static Logger logger = LogManager.getLogger();
  
    @Test
    public void testConfigurationLoader_write(){
        ConfigurationLoader configurationLoader = new XMLConfigurationLoader();  //fails here
        configurationLoader.writeGlobalConfigurationSample();
    }

And the code where the test fails is:

public XMLConfigurationLoader() {
    
    xStream = new XStream(new StaxDriver());
    
    startUpBundle = ResourceBundle.getBundle("StartupConfiguration"); //fails here

So I used IntelliJ's find and looked for StartupConfiguration and found two copies of StartupConfiguration.properties. Both in WebREST project, one in src/main/resources and the other in src/main/prod.

So now, my question is, how do I handle this? I could always just make another copy of the file, but wanted to see if there was a better way to solve this.


Solution

  • To resolve this, I ended up just adding the project to my test resources. Hope this helps someone else.