You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by Diego Louzán <dl...@apache.org> on 2006/12/06 21:34:36 UTC

Problems trying to integrate Pluto & WSRP4J

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, I'm Diego Louzán from the Apache WSRP4J project. These days I'm
trying to add wsrp templates support to wsrp4j using pluto-1.0.1 and I
need some help from the Pluto gurus.
    The code for the wsrp templates is very dependent on the way the
portal generates the urls, so although wsrp4j tries to be
portal-agnostic, this feature requires a plugin for every portal using
it. Starting, I want to develop a plugin for PlutoPortal and Jetspeed.
    So, in the case of PlutoPortal I'm trying to get the
org.apache.pluto.portalImpl.core.PortletURL object from the current
request, and after taking a look at the code I thought I could get the
info using the org.apache.pluto.portalImpl.core.PortalEnvironment class.
This is where my problem arises, I have a code like this (assuming in
Pluto I can downcast the PortletRequest object to HttpServletRequest):

private PortletRequest request;
private PortalEnvironment portalEnv;

public PlutoPortalTemplateComposer(PortletRequest request) {
    this.request = request;
    HttpServletRequest servletRequest = (HttpServletRequest) request;
    this.portalEnv = PortalEnvironment.getPortalEnvironment(
            servletRequest);
}

    Ok, this code throws a ClassCastException due to (I think) the
following: the getPortalEnvironment() static method tries to get an
attribute from the HttpServletRequest which holds the PortalEnvironment
PlutoPortal has created. This code is fine, I checked with the debugger
and the object is correctly returned, I can even assign it to an Object
variable and call to toString(). The exception is thrown in the step of
casting the Object attribute to a PortalEnvironment inside
getPortalEnvironment:

    public static PortalEnvironment getPortalEnvironment(
            HttpServletRequest request)
    {
        return (PortalEnvironment)
                request.getAttribute(REQUEST_PORTALENV);
    }

    The problem lies in the following: the creator of that attribute is
PlutoPortal using its own pluto-portal classes inside
pluto/WEB-INF/classes, which use a classloader let's call it A. When I
access the attribute from wsrp4j, I need to use another copy of the
pluto-portal.jar, so it's another classloader B. As the type is a
combination of the classloader and the class, the PortalEnvironment is
from classloader A and I try to cast it to the class in classloader B,
so bang, ClassCastException.

    After all this, my question is: is there any way of doing this
easily? The obvious idea is to move both pluto-portal jars to
shared/lib, but that is a mess, because that forces me to also move all
pluto-portal jar dependencies there.

    Any ideas are welcome.

Thanks in advance.
Diego.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFdylcgyzZYflJelERAsLrAKCW3B5/pzS2Dl/6l6rdG3h8Fge6LwCfR1gj
wHtwQUEJsGYM4r4Xvokw2wM=
=Axn2
-----END PGP SIGNATURE-----