Hi,
I've got a Jersey 2.4.1 app that has JPA repositories in a dependent
project listed as a dependency
in my pom.xml. We're using spring 3.2.2 and had no trouble with @Autowire
working against Jersey 1.17, but we're having fits trying to get it to work
in 2.4.1.
I've tried to do this with and without a web.xml. It seems like there's a
problem with the spring contexts of the mvn dependent projects getting
loaded properly, or perhaps getting loaded and merged with the context for
our jersey app. At first we weren't getting *any* @Autowire to work, but
we were able to get a local class (local to the Jersey project), a very
simple POJO named Foo will now @Autowire correctly, after doing the
following in our Application class:
// Get a reference to the ApplicationContext created by jersey
ApplicationContext rootCtx =
ContextLoader.getCurrentWebApplicationContext();
lager.info("ROOT CTX:::" + rootCtx);
// Create an application context and set the one created internally
by
// jersey as its parent
AnnotationConfigWebApplicationContext myCtx = new
AnnotationConfigWebApplicationContext();
myCtx.setParent(rootCtx);
myCtx.setConfigLocation("classpath:applicationContext.xml");
It seems that the rootCtx doesn't have any of our annotated beans in it,
but the AnnotationConfigWebApplicationContext one does, at least for the
local beans. Does anyone konw what's going on here?
I also tried to build against the 2.5-SNAPSHOT but to no avail. ANy help
2would be greatly appreciated, we are at a loss as to why our packages are
not getting scanned and puilled into the Spring context, aside from seeing
all the comments here and there about DI and annotation processing problems.
How do we get @Autowire working across our mvn dependencies?
Thanks!