Foren

WSRP Remote Portlet: URLs in Portlet point to producer, not to consumer

thumbnail
Achim Bitzer, geändert vor 11 Jahren.

WSRP Remote Portlet: URLs in Portlet point to producer, not to consumer

New Member Beiträge: 5 Beitrittsdatum: 08.05.14 Neueste Beiträge
Hello,

Currently I'm checking out Liferay and its portlet feature, especially remote portlets via WSRP.

I've got two liferay instances running on different machines in the same network. Now I want to share a portlet from one of the liferay instances to the other, so I've installed the WSRP app on both installations and configured one of the nodes as WSRP Producer and the other as WSRP Consumer.
My WSRP Producer publishes the portlet for currency calculations (Währungsrechner in German) which is included in Liferay.
At first glance, this WSRP portlet seems to work on the WSRP consumer side - I can add it to a page of the WSRP consumer and its content (some input boxes) is displayed correctly.

But there is one problem:

The HTML form rendered by the portlet always submits to the WSRP produder's domain, not to the WSRP consumer's domain as I would expect. The action attribute of the <form> tag contains the wrong domain name.

I've also written a small portlet for debugging purposes using the Liferay UI which simply prints the output of the JSP-Tag <portlet:actionURL/>, installed it on the WSRP producer and embedded it in a page of the WSRP consumer. The URLs printed by this simple debugging portlet are always absolute URLs and point to the WSRP producer, even when the portlet is displayed on the WSRP consumer. I would expect that the URLs are either relative or that they point to the correct domain, e.g. to the WSRP consumer domain when the portlet is displayed via a page on the WSRP consumer liferay instance.

How can I fix this?
Do I need to adjust Liferay's configuration so that the WSRP Consumer replaces URLs from WSRP portlets with its own URL?
Are there other factors that affect WSRP portlets and actionURLs?
Any help on this issue would be greatly apreciated!

My setup is:
- Liferay 6.2 CE with Tomcat 7
- Database is MySQL 5.5
- Oracle Java 7
- Liferay was configured with the inbuilt installation wizard

Thanks in advance,

Achim
thumbnail
Achim Bitzer, geändert vor 11 Jahren.

RE: WSRP Remote Portlet: URLs in Portlet point to producer, not to consumer

New Member Beiträge: 5 Beitrittsdatum: 08.05.14 Neueste Beiträge
Here's some additional information:

My setup consists of two liferay instances
- the 1st one is accessible under the domain liferay.mycompany.net
- the 2nd one is accessible under the domain liferay-2.mycompany.net

The WSRP app is installed on both liferay instances.

On the 1st instance, the currency calculation portlet is made available via WSRP, so that the 1st instance acts as a WSRP producer.
The 2nd instance acts as WSRP consumer and uses the remote currency calculation portlet from the 1st instance via WSRP.

The remote currency calculation portlet can be added to sites of the 2nd liferay instance without any problems. The portlet is rendered correctly, it's form elements are displayed.

However the URL associated to the form rendered by the portlet points to liferay.mycompany.net and not to liferay-2.mycompany.net. When the submit button is clicked nothing (visible) happens, which makes the portlet quite unusable via WSRP.

The reason for my evaluation of Liferay is, that we want to check if it is a suitable solution for developing portlets and providing these portlets via WSRP for remote usage.
To further investigate the problem I've built a small debug portlet with the Liferay SDK and Eclipe Plugin. The portlet mainly consists of a simple JSP page which prints out the result of <portlet:actionURL>:


&lt;%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %&gt;
<span class="important">portlet:actionURL: </span><portlet:actionurl />


When I install this portlet on lifery.mycompany.net and publish it via the WSRP producer to liferay-2.mycompany.net, the output URL is:

http://liferay.mycompany.net:8080/de_DE/widget/web/wsrp-achimstestproducer/portlets?p_auth=0iLgJP7e&amp;p_p_id=sbdebug_WAR_sbliferaydemopluginportlet_INSTANCE_qs2S&amp;p_p_lifecycle=1&amp;p_p_state=normal&amp;p_p_mode=view 


Please note that the domain is liferay.mycompany.net instead of the expected liferay-2.mycompany.net.

Does anybody know how I can fix this?
Is there an incomapitibility between <portlet:actionURL> and WSRP which I am missing here?
Or is there some configuration option on the WSRP consumer side for rewriting the URLs in the HTML output of WSRP consumer portlets?
Luigi Leoni, geändert vor 11 Jahren.

RE: WSRP Remote Portlet: URLs in Portlet point to producer, not to consumer

New Member Beitrag: 1 Beitrittsdatum: 08.08.12 Neueste Beiträge
Hi Achim,
we have the same problem.
Taking a look on https://www.liferay.com/it/community/wiki/-/wiki/Main/Deploying+JSF+Portlets+via+WSRP
and install http://central.maven.org/maven2/com/liferay/faces/demos/jsf2-portlet/3.2.4-ga5/jsf2-portlet-3.2.4-ga5.war
on your backend instance.
You can see that all work fine.

We analysed source code and found following property on liferay-portlet.xml :

...
<remoteable>true</remoteable>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
...


Adding <requires-namespaced-parameters>false</requires-namespaced-parameters> on liferay-portlet.xml inside our portlet exposed by producer all works fine.

Hope this helps
thumbnail
Achim Bitzer, geändert vor 11 Jahren.

RE: WSRP Remote Portlet: URLs in Portlet point to producer, not to consumer

New Member Beiträge: 5 Beitrittsdatum: 08.05.14 Neueste Beiträge
Hi Luigi,

thanks a lot, that really helped:
The actionURLs point to the correct domain after I set <requires-namespaced-parameters>false</requires-namespaced-parameters>.

Unfortunately now I've discovered another problem:
I've got two portlets, one of them displays a list of entries. A click on one of the entries produces an event which is consumed by the second portlet. The idea is that this second portlet displays detailed information about the selected entry from the list of the first portlet.

When both portlets are installed locally on the same liferay instance, everything works fine. But when both portlets are published via WSRP and displayed on a WSRP consumer, then the second portlet does not receive the event generated by the first portlet.

I didn't have much time yet to investigate this new problem. I'll post an answer on this form entry when I've got more information (may take some days).

Thanks again,

Achim
thumbnail
Achim Bitzer, geändert vor 11 Jahren.

RE: WSRP Remote Portlet: URLs in Portlet point to producer, not to consumer

New Member Beiträge: 5 Beitrittsdatum: 08.05.14 Neueste Beiträge
Hello Luigi, hello everybody,

now I've had some time to further investigate my WSRP problem. As stated in my last comment the URLs generated with <portlet:actionURL> now point to the WSRP consumer's domain.

Unfortunately this did not really solve the problem, because the portlets processAction method does not seem to be invoked when submitting a form on such an action URL or clicking a link on such an action URL.

I've built a simple portlet for testing purposes, which consists of a simple form with one input field. When the form is submitted the portlet simply prints the value from the input field:

view.jsp looks like this:


&lt;%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %&gt;
<p>
  <portlet:actionurl var="formActionUrl" />
  </p><form action="${formActionUrl}" method="POST">
      <input type="text" value="inputfeld" name="<portlet:namespace/>test">
      <input type="submit">
  </form>
  Last input was: &lt;%= renderRequest.getParameter("test") %&gt;
<p></p>



My processAction method looks like this:


    @Override
    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException,
            PortletException
    {
        super.processAction(actionRequest, actionResponse);
        actionResponse.setRenderParameter("test", actionRequest.getParameter("test"));
    }


I've deployed this portlet on one of my Liferay instances. The portlet works fine as long as I don't use it over WSRP, embedding it in a page of the liferay instance on which the portlet is deployed, everything works fine.

But when I publish this portlet via WSRP and try to embed it in a page on the WSRP consumer liferay instance, it does not work:
- The domain of the form action URL points to the WSRP consumer liferay instance
- The page is reloaded when the form is submitted
- The processAction method is not invoked (checked with eclipse debugger)
- The value entered in the input field is not printed in the widget, the widget is rendered as if it was the first request without any POST data from the form
- I've also added some System.out.println() invocations to the processAction method. When the portlet is executed locally without WSRP the output of println() appears in catalina.out (eclipse console), but when I use the portlet via WSRP the output does not appear, neither on the WSRP consumer's log nor in the WSRP producer's log.

Am I doing something wrong here? Any ideas and hints are welcome emoticon

EDIT:
The WSRP consumer's log contains this error message:
08:57:31,914 ERROR [RuntimePageImpl-154][AdvancedPermissionChecker:971] com.liferay.portal.NoSuchResourceActionException: WSRP_7e6fde7c__0d9c__4bd6__a8e2__a2fb03f2a658#PREFERENCES
com.liferay.portal.NoSuchResourceActionException: WSRP_7e6fde7c__0d9c__4bd6__a8e2__a2fb03f2a658#PREFERENCES
        at com.liferay.portal.security.permission.ResourceActionsImpl.checkAction(ResourceActionsImpl.java:134)
        at com.liferay.portal.security.permission.ResourceActionsUtil.checkAction(ResourceActionsUtil.java:65)
        at com.liferay.portal.security.permission.AdvancedPermissionChecker.hasGuestPermission(AdvancedPermissionChecker.java:885)
        at com.liferay.portal.security.permission.AdvancedPermissionChecker.hasPermissionImpl(AdvancedPermissionChecker.java:944)
        at com.liferay.portal.security.permission.AdvancedPermissionChecker.hasPermission(AdvancedPermissionChecker.java:586)
        at com.liferay.portal.service.permission.PortletPermissionImpl.contains(PortletPermissionImpl.java:305)
        at com.liferay.portal.service.permission.PortletPermissionImpl.contains(PortletPermissionImpl.java:201)
        at com.liferay.portal.service.permission.PortletPermissionImpl.contains(PortletPermissionImpl.java:191)
        at com.liferay.portal.service.permission.PortletPermissionUtil.contains(PortletPermissionUtil.java:139)
        at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:736)


I think this exception is not directly related to my WSRP problem, it looks like this was caused by trying to configure the portlet although it does not have a preferences view. Aside from this message today's catalina.out is completely empty.

Thanks in advance,

Achim
thumbnail
Achim Bitzer, geändert vor 11 Jahren.

RE: WSRP Remote Portlet: URLs in Portlet point to producer, not to consumer (Antwort)

New Member Beiträge: 5 Beitrittsdatum: 08.05.14 Neueste Beiträge
After using this forum, several other WSRP resources on the web an search engines a lot it now works.

The following three things seemed to be the major causes for my problems with WSRP problems:

  • requires-namespaced-parameters must explicitly be set to false
  • CSRF token must be deactivated, I've did this in portlet-xml via init-param:
            <init-param>
                <name>check-auth-token</name>
                <value>false</value>
            </init-param>
  • Render parameters don't seem to be available in the view JSP when the render parameter was created in an event processing method, therefore I switched to portlet session attributes to transport data from the portlet class to the JSP view