I'm using Spring-AOP support to inject references via @Inject into objects not managed by the Spring beanfactory. For instance:
@Configurable(preConstruction=true)
class DefaultContent implements Content
{
@Inject @Nonnull
private Site site;
@Inject @Nonnull
private ModelFactory modelFactory;
public DefaultContent (final @Nonnull FileObject file)
{
resource = modelFactory.createResource(file); // <--here
}
I'm using static code weaving.
I think I know all the related technologies well and this indeed works fine... during the normal development cycle (with Maven). Yesterday I prepared a release (with the Maven release plugin) and the binaries in the release seem to fail injection, since I get a NPE at the line marked with 'here'.
To explain better, until yesterday my project was in SNAPSHOT mode (1.0-ALPHA-2-SNAPSHOT). Binaries from the snapshot work. Binaries from 1.0-ALPHA-2, release mode, don't. Binaries in the next snapshot, 1.0-ALPHA-3-SNAPSHOT, work again. The only black hole are the released binaries. Looking with diff, there are no other differences among the SNAPSHOTs and the release but the version labels of the modules.
So far I've excluded that the problem is due to some strange thing during the Maven release process, since the binaries are buggy even when I re-create 1.0-ALPHA-2 from tagged sources in a "plain" build (that is, just mvn clean install). I've also used a Java decompiler to look at the effective source (post-waving) of the faulty class, comparing the code from 1.0-ALPHA-2 and 1.0-ALPHA-3-SNAPSHOT. They look identical. At last, I've compared the binaries (a .war file running within Jetty) and they contain the same items (that is, no missing dependencies, the only difference being my jar files with a different version).
I need some suggestion to understand better this bug because at the moment I don't know what else to try.