フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Aritz Galdos
Spring and multiple portlet requestMapping in pluginsSDK [SOLVED]
2010/09/01 5:42
答え

Aritz Galdos

ランク: Expert

投稿: 401

参加年月日: 2007/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 : 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!!
Aritz Galdos
RE: Spring and multiple portlet requestMapping in pluginsSDK
2010/09/01 5:42
答え

Aritz Galdos

ランク: Expert

投稿: 401

参加年月日: 2007/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
Gustavo Fernández Gómez
RE: Spring and multiple portlet requestMapping in pluginsSDK
2010/09/01 6:11
答え

Gustavo Fernández Gómez

ランク: Regular Member

投稿: 191

参加年月日: 2007/10/26

最近の投稿

interesting question thanks
Julien Ripault
RE: Spring and multiple portlet requestMapping in pluginsSDK [SOLVED]
2012/05/25 5:40
答え

Julien Ripault

ランク: New Member

投稿: 15

参加年月日: 2012/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) ...