AOP / Causing binding errors

104 views
Skip to first unread message

nino martinez wael

unread,
Dec 4, 2014, 4:22:51 AM12/4/14
to google-guice
Why am I getting binding errors when doing AOP?

Initially my bindings were in a private module.. The architecture
consist of this:

Parent-Injector
|---AOP Module
|---Child Injector (initially private)
|-----|-Module with AOP annotation



Last cause: Guice configuration errors:

1) Unable to create binding for
com.netdesign.dao.cisco.v7.uccx.CiscoStatisticsMapper. It was already
configured on one or more child injectors or private modules
bound at org.mybatis.guice.AbstractMyBatisModule.bindMapper(AbstractMyBatisModule.java:80)
If it was in a PrivateModule, did you forget to expose the binding?
while locating com.netdesign.dao.cisco.v7.uccx.CiscoStatisticsMapper
for field at
com.netdesign.dao.cisco.v7.uccx.CiscoWallBoardDataProvider.ciscoStatisticsMapper(CiscoWallBoardDataProvider.java:862)
while locating
com.netdesign.dao.cisco.v7.uccx.CiscoUCCX7WallBoardDataProvider$$EnhancerByGuice$$fa857977


If if do not install everything runs fine. Of course the AOP are not run..

What could be wrong?

--

Best regards / Med venlig hilsen
Nino Martinez

nino martinez wael

unread,
Dec 4, 2014, 4:11:38 PM12/4/14
to google-guice

Im thinking it has something todo with private / child injection trickery..

Like the parent AOP are not able to access the child bindings

Stuart McCulloch

unread,
Dec 4, 2014, 7:02:31 PM12/4/14
to google...@googlegroups.com
On Thursday, 4 December 2014 at 09:22, nino martinez wael wrote:
Why am I getting binding errors when doing AOP?

Initially my bindings were in a private module.. The architecture
consist of this:

Parent-Injector
|---AOP Module
|---Child Injector (initially private)
|-----|-Module with AOP annotation

Last cause: Guice configuration errors:

1) Unable to create binding for
com.netdesign.dao.cisco.v7.uccx.CiscoStatisticsMapper. It was already
configured on one or more child injectors or private modules
Best practice is to explicitly bind anything used in a child injector or private module because otherwise JIT bindings (such as injecting a concrete class) will percolate up to the root injector, as explained in https://github.com/google/guice/wiki/BindingResolution. And if multiple child injectors or private modules rely on the same JIT binding then you’ll get the above exception.

You should just need to bind(CiscoStatisticsMapper.class) in the appropriate module.

BTW, you can use this option to help identify where you need to add explicit bindings: 


bound at org.mybatis.guice.AbstractMyBatisModule.bindMapper(AbstractMyBatisModule.java:80)
If it was in a PrivateModule, did you forget to expose the binding?
while locating com.netdesign.dao.cisco.v7.uccx.CiscoStatisticsMapper
for field at
com.netdesign.dao.cisco.v7.uccx.CiscoWallBoardDataProvider.ciscoStatisticsMapper(CiscoWallBoardDataProvider.java:862)
while locating
com.netdesign.dao.cisco.v7.uccx.CiscoUCCX7WallBoardDataProvider$$EnhancerByGuice$$fa857977


If if do not install everything runs fine. Of course the AOP are not run..

What could be wrong?

--

Best regards / Med venlig hilsen
Nino Martinez

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nino martinez wael

unread,
Dec 5, 2014, 1:49:00 AM12/5/14
to google-guice

And that is where the problem comes. We are using a very pluggable architecture. Where we drop in jars/modules that then are loaded and exposes an interface (which shares data/structure), however inside the droppables which are in child injectors and private modules they may depend on something like aop in the parent injector. I think I'm pushing the limit a bit and full blown osgi might be better. Instead of this guice based one..

However im a bit sad to leave guice out because it handles a lot of boiler plate for us.. afaik it's not a good mix osgi and traditional ioc like guice?

Laszlo Ferenczi

unread,
Dec 5, 2014, 3:18:25 AM12/5/14
to google...@googlegroups.com
We have a similar architecture with guice, modules loaded dynamically using the ServiceLoader mechanism. AOP works in child injectors / private modules as long as they have an explicit binding. (in our case JPA transactional binding was failing due to missing AOP, explicit bindings are basically solving this issue)

As Stuart already mentioned the requireExplicitBindings can help with this. (you're getting an error during injector creation if a class is not explicitly bound)

--
L

nino martinez wael

unread,
Dec 13, 2014, 2:26:26 PM12/13/14
to google-guice

I was able to solve this particular problem by moving the injector to a higher tier

Reply all
Reply to author
Forward
0 new messages