views:

328

answers:

2

I can build a deployable jar just fine on my local machine, but when trying to use jar built off our server, even if I explicitly invoke the command by hand, the jar will not run. At first, it appeared that it wasn't including files I'd had in my classpath/Resources directory, but after adding the builder-helper plug in, it's now including them properly. However, it still won't run. I'd like to know more about how to debug this, how to identify the differences in an effort to see what's happening locally versus the server. Here's the relevant POM section for the plug in

<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>

Pardon if this is a really simple question; I'm relatively new to maven and haven't found a good answer anywhere. Possibly because it's more fundamental than I'm realizing. Thanks.

A: 

This is a guess based on a similar experience of mine, if this is not the solution can you post your POM? it may help diagnose the issue.

Is you server a *nix box and your local machine Windows? If so be aware that when specifying the additional resources folder you should use slashes rather than backslashes for the path separator. Slashes work on both Windows and *nix, whereas backslashes are silently ignored on *nix boxes.

So your buildhelper configuration 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 is worthwhile to do so. By default resources should be located in src/main/resources. Some plugins won't process resources added by the build-helpr plugin properly.

Rich Seller
A: 

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

Ken Liu