0

I'm having problems with Spring contexts when deploying an application we 5 teams are developing (I belong in one of this teams). All of us compile our own jar. When locally debugging, Spring loads the contexts with no problem.

The issue arises when deploying in the server, we've been debugging and have discovered another team's contexts was accessing my beans (cross-referencing them by id) because we both are using Mybatis framework, so by declaring their bean with the same id they were getting access to my mappers and had a conflict I guess. The server throws and error referencing some autowiring problem but doesn't give much more information.

Nonetheless, we've changed this bean ID and still have problems with Spring. ¿Do you know any other reason why the contexts are failing or why this bean crossreference? Could you recommend a tool to try to find out the error?

Some more info: we're using Atlassian tool "Bamboo" to automatize jar compilation. We've checked and our last jar version seems to be in use... I don't know what else I could tell you, I'm not an expert on this issue.

Fernando
  • 751
  • 2
  • 13
  • 27

1 Answers1

0

Based on your description and the reference to an "autowiring problem" I am assuming you are using @Autowired to inject your dependencies. This annotation alone in injecting by type so I'm wondering whether you are actually injecting by id as your intention is. To achieve this you can do either:

@Resource(name="myBeanId")
MyType myVar;

or

@Autowired
@Qualifier("myBeanId")
MyType myVar;
dimitrisli
  • 20,895
  • 12
  • 59
  • 63
  • The problem is, due to inheritance from the last years (it's quite annoying to me, actually), some beans are declared in XML (by id and reference) and others are by autowiring using spring annotation @Autowired. Those which are using this annotation are referenced from the XML by Spring default autowiring which I think is by type (property name is the same as the class but starting in lower case) – Fernando Sep 18 '15 at 08:59
  • The problem we noticed yesterday is they were accessing our mappers. We both have a bean of type sqlSessionFactory you need to use Mybatis. They have an id different from us and they reference it using this id and the property name "sqlSessionFactory". As far as I know, this property name is something internal to the bean. But their bean is crossreferencing ours. – Fernando Sep 18 '15 at 09:02