Spring and multiple portlet requestMapping in pluginsSDK [SOLVED]

thumbnail
31821, modified 15 Years ago. Expert Posts: 416 Join Date: 5/15/07 Recent Posts
Hi people:

I am working with Liferay´s pluginsSDK and I intend to develop multiple portlets bunbled in the same war file.

With Liferay IDE, I create the portlets, configure Spring conf files and create the needed controllers.

Every thing works fine with one single portlet. I created one sinple controller and decorated it with @Controller and @RequestMapping("view") annotations.

Great. But when I add a second porltet and I add its controller annotated the same way, it crashes during the deployment.
Caused by: java.lang.IllegalStateException: Cannot map handler [prueba01Plet02] to URL path [/view]: There is already handler [com.test.Prueba01Plet02@104c0de] mapped.


It sais that cannot map a handler to the URL "view" because there is a handler already mapped.

I guess that the handler already mapped is the first one and crashes when trys to map the second one.

Well as far as I know, @RequestMapping("view") at class level, means that it is mapping this controller to portlets view mode. And each porltet has its own view mode called view. How can I map each controller of each portlet?

Saying it simply: How can I decorate two controller of two different portlets with @RequestMapping("view") in a single war?

I don't know if I explained it clear enough but... I am stuck!

Thanks in advance!!
thumbnail
31821, modified 15 Years ago. Expert Posts: 416 Join Date: 5/15/07 Recent Posts
Well.. I found out the solution for my own problem.

Actually I was doing something wrong.

Each portlet had (and has) its own context descriptor xml file.

In which among other things there was a clause
<context:component-scan base-package="com.test" />


Wich defines the path of the package in which looks for components.

This clause was the same in both portlets so each portlet's DefaultAnnotationHandlerMapping tried to map all the controllers causing conflicts.

The solution is as easy as this.

I sepparated controllers in more specific packages like com.test.plet1 and com.test.plet2 and modified in consecuence each portlets context definition.

<context:component-scan base-package="com.test.plet1" />

and
<context:component-scan base-package="com.test.plet2" />



Hope it to be usefull for someone else emoticon
thumbnail
223428, modified 15 Years ago. Regular Member Posts: 191 Join Date: 10/26/07 Recent Posts
interesting question thanks
Julien ., modified 13 Years ago. New Member Posts: 15 Join Date: 3/19/12 Recent Posts
It's a shame that there is no other means to do that expect creating many spring context files (one for each portlet) ...