Maven - jar built using maven-assembly-plug in not always deployable

I can build the deployed jar on my local machine, but when I try to use the jar built on our server, even if I explicitly call the command manually, the jar will not work. At first it turned out that it did not include the files I had in my classpath / Resources directory, but after adding the inline linker module, it now includes them correctly. However, it still won't work. I would like to know more about how to debug this, how to spot the differences in an attempt to see what is happening locally versus the server. Here's the relevant POM section for the fork

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<executions>
 <execution>
  <goals>
   <goal>attached</goal>
  </goals>
  <phase>package</phase>
  <configuration>
   <descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
   </descriptorRefs>
   <archive>
    <manifest>

     <mainClass>com.medialets.service.PostEC</mainClass>
    </manifest>
   </archive>
  </configuration>
 </execution>
</executions>

      

Sorry if this is a really simple question; I'm relatively new to maven and haven't found a good answer anywhere. Perhaps because it is more fundamental than I understand. Thank.

+2


source to share


2 answers


This is an assumption based on my own experience, if this is not a solution, can you post your POM? this can help diagnose the problem.

Is the server a * nix server and your local windows machine? If you need to remember that when specifying the additional resources folder, you must use forward slashes and not backslashes for the path separator. Slashes work on both Windows and * nix, while backslashes are silently ignored in * nix blocks.

So your buildhelper config should look like this:



  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.3</version>
    <executions>
      <execution>
        <id>add-resource</id>
        <phase>generate-resources</phase>
        <goals>
          <goal>add-resource</goal>
        </goals>
        <configuration>
          <resources>
            <resource>
              <directory>classpath/Resources</directory>
              <targetPath>/</targetPath>
            </resource>
          </resources>
        </configuration>
      </execution>
    </executions>
  </plugin>

      

As an aside, if you can follow the Maven conventions, it's worth doing it. By default, resources should be located in src / main / resources. Some plugins will not handle resources added by the build-helpr plugin as expected.

0


source


You can also try running the plugin help: effective-pom to see if there are any differences in the POM that maven resolves.



0


source







All Articles