Domain properties in Glassfish

You can make properties files available to you WAR and EAR applications by putting the file in the folder glassfish/domains/${glassfish.domain.name}/lib/classes

You can use these in your spring configuration by prefixing the resource name with classpath:. For example:

<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <beans:property name="location" value="classpath:some.properties"/>
</beans:bean>

Configuration Properties in Spring

Make configuration properties from a properties file available in a Spring context

<bean id="propertyPlaceholderConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="locations">
      <list>
         <value>application.properties</value>
      </list>
   </property>
</bean>

m2eclipse and separate output folders

The recent versions of m2eclipse (> 0.9.3) are a nightmare to get working. The biggest issues is that if you run a command line build whilst eclipse is working, one or the other will get totally borked. there is a section in the FAQ describing how to use separate output folders. Essentially you have to tell eclipse to use a certain maven profile, which changes your project configuration.

The instructions almost work. However, some plugins need the project.build.directory variable (for example for code-generation) to be set, and the FAQ does not achieve that.

Ordinarily you would have to specify the directory element in the build section:

<directory>${basedir}/${target.dir}</directory>

If you do this however, anything you launch in eclipse will not have the correct classpath. You must fully specify the output directories:

<directory>${basedir}/${target.dir}</directory>
<outputDirectory>${basedir}/${target.dir}/classes</outputDirectory>
<testOutputDirectory>${basedir}/${target.dir}/test-classes</testOutputDirectory>

I assume this is because m2eclipse is doing some kind of parsing of the pom.xml

Maven Default Execution Ids

Maven execution IDs have changed in maven versions greater than 2.2.0.

It seems that you can disable a default a default execution by binding it to the phase “none”:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-dependency-plugin</artifactId>
   <executions>
      <execution>
         <id>default</id>
         <goals>
            <goal>unpack</goal>
         </goals>
         <phase>none</phase>
      </execution>
      <execution>
         <id>unpack</id>
         <phase>process-resources</phase>
         <goals>
            <goal>unpack</goal>
         </goals>
         <configuration>
            <artifactItems>
               <artifactItem>
                  [...]
               </artifactItem>
            </artifactItems>
         </configuration>
      </execution>
   </executions>
</plugin>

Linked Folders in Eclipse

In your .project file:

<projectDescription>
   [...]
   <linkedResources>
      <link>
         <name>target</name>
         <type>2</type>
         <locationURI>some/location</locationURI>
      </link>
   </linkedResources>
</projectDescription>

Following Redirects in Jersey REST Client

There is a method in com.sun.jersey.api.client.Client that causes the Client to follow any redirections:

 /**
  * Set if redirection should be performed or not.
  *
  * This method is the functional equivalent to setting the property
  * {@link ClientConfig#PROPERTY_FOLLOW_REDIRECTS} on the property bag
  * returned from {@link #getProperties}
  *
  * @param redirect if true then the client will automatically redirect
  *        to the URI declared in 3xx responses.
  */
 void setFollowRedirects(Boolean redirect)