Ad

Ambiguous Mapping While Deploying

- 1 answer

I'm using Jenkins 1.6.20 (Git Client Plugin 1.18.0, Git Plugin 2.4.0) to get the Java application code from bitbucket.org and deploy it to Apache Tomcat 8.0.23.

The error appears while deploying and looks like:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/spr$ public java.util.List by.ipps.accounting.ws.PositionWS.getEmployeePost(java.lang.Long) to {[/positionListJson/{id}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}: There is already 'resourceWS' bean method public by.ipps.accounting.model.Employee.EmployeePost by.ipps.accounting.ws.ResourceWS.getEmployeePost(java.lang.Long) mapped.

bla-bla-bla ... so many errors ...

Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'positionWS' bean method public java.util.List by.ipps.accounting.ws.PositionWS.getEmployeePost(java.lang.Long) to {[/positionListJson/{id}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}: There is already 'resourceWS' bean method public by.ipps.accounting.model.Employee.EmployeePost by.ipps.accounting.ws.ResourceWS.getEmployeePost(java.lang.Long) mapped.

The problem is that the class (with annotation @Controller) PositionWS with method getEmployeePost was renamed to ResourceWS a week ago, so exists no more, so I should not get this error.

To fix this I have to create a blank PositionWS controller (with no methods in it), commit & push that to bitbucket (and delete (cus i really don't need it) later and commit & push).

It seems to be like a bug in any of the applications I use. I can't find out in which app there is a bug to report it. Tell me please, if anyone faced such problems.

Ad

Answer

The heart of the issue was in incorrect configuration of Jenkins, it was my fault.

When I was configuring Jenkins I set maven goal as "install", but it must be "clean install". According to this Jenkins never deleted old files and kept them, so got a lot of issues of different kinds and with different log messages. Due to Jenkins working specialty it downloads project files and try to assemble it on path /var/lib/jenkins/jobs/<projectName>/workspace/target/.

So I've drop the data in this folder and afterwards set maven goal to "clean install" and that fixed the issue.

Ad
source: stackoverflow.com
Ad