掲示板

Spring and multiple portlet requestMapping in pluginsSDK [SOLVED]

thumbnail
13年前 に Aritz Galdos によって更新されました。

Spring and multiple portlet requestMapping in pluginsSDK [SOLVED]

Expert 投稿: 416 参加年月日: 07/05/15 最新の投稿
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
13年前 に Aritz Galdos によって更新されました。

RE: Spring and multiple portlet requestMapping in pluginsSDK

Expert 投稿: 416 参加年月日: 07/05/15 最新の投稿
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
13年前 に Gustavo Fernández Gómez によって更新されました。

RE: Spring and multiple portlet requestMapping in pluginsSDK

Regular Member 投稿: 191 参加年月日: 07/10/26 最新の投稿
interesting question thanks
11年前 に Julien . によって更新されました。

RE: Spring and multiple portlet requestMapping in pluginsSDK [SOLVED]

New Member 投稿: 15 参加年月日: 12/03/19 最新の投稿
It's a shame that there is no other means to do that expect creating many spring context files (one for each portlet) ...