简体   繁体   中英

How to create portlets / deploy on weblogic IDE eclipse

I am learning "how to create portal application", went through some documents and tutorials. I found we need one application server, one portal container and one IDE.

please help me to understand it.

I want to create a portlet and deploy it on weblogic server. so what the things i required.

means: any plugin in eclipse portlet container application server etc.....

Thanks

I've just got the pluto portlet container up and running. The tutorials for pluto are a bit sketchy and most contain errors that can throw you off course. As such, I've made this as thorough as I can.

I've since managed to get pluto running under WebLogic, albeit not perfectly (discussed later). So, I think your aims are:

  1. Install a portlet container: eg pluto
  2. Create a HelloWorld portlet, deploy it and publish it
  3. Perhaps, deploy the portlet so that it runs under WebLogic? Not sure if this is what you intend.
  4. Portlet communication
  5. Build more heavyweight portlets that do what you want
  6. Upgrade portal implementation (eg JetSpeed)

So, here goes:

1. Install a portlet container: eg pluto

I recommend you start with the pluto portlet as this is the reference implementation and adheres to version 2 of the spec (JSR-286). Download the binary distribution from:

http://portals.apache.org/pluto/v20/getting-started.html

This comes housed within a tomcat 6 webserver. So, to run a basic portlet, you just need to configure and start tomcat. The pluto web application can be found in the webapps directory.

To understand more about tomcat, see here:

http://www.puschitz.com/InstallingTomcat.html#InstallingTomcatSoftware

Note that this is slightly complicated (for good reason) as it recommends creating separate instances of tomcat. This tutorial really only takes an hour though so I'd recommend it in advance of your portlet work so that you have a good foundation.

In simple terms though, to start up pluto (well, tomcat), you just need to set your ${CATALINA_HOME} to be your tomcat installation directoy (pluto-2.0.2) and execute {pluto_install_dir}/bin/startup.sh. You can access the pluto portal from a browser with:

http://localhost:8080/pluto/portal

2. Create a HelloWorld portlet, deploy it and publish it

Happily, the pluto tutorial is nearly good enough to get you going. Unbelievably, all the tutorials I found had flaws or errors. With a little help, you should get this going though. It is at the same place:

http://portals.apache.org/pluto/v20/deploying.html

The directory structure shown under "Portlet Assembly" is slightly wrong. The webapp folder should be at the same level as the java folder, under main.

Here is a sample HelloWorld portlet that presents using direct output in the response (like a servlet):

package com.mycompany.portlet;
//imports omitted...

public class HelloWorldPortlet extends GenericPortlet{
  protected void doView(RenderRequest request,RenderResponse response)
        throws PortletException, IOException {
      response.setContentType("text/html");
      response.getWriter().println("Hello World");
  }
}

Here's an example WEB-INF/portlet.xml:

<?xml version="1.0" encoding="UTF-8"?>

<portlet-app
    xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
    version="1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
                        http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">

    <portlet>
        <description>HelloWorld Description</description>
        <portlet-name>HelloWorldPortlet</portlet-name>
        <display-name>Hello World Display Name</display-name>
        <portlet-class>com.mycompany.portlet.HelloWorldPortlet</portlet-class>
        <expiration-cache>-1</expiration-cache>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
        </supports>
        <supported-locale>en</supported-locale>
        <portlet-info>
            <title>Hello World</title>
            <short-title>Hello World</short-title>
            <keywords>Hello,pluto</keywords>
        </portlet-info>
    </portlet>
</portlet-app>

Here's an example WEB-INF/web.xml:

<web-app id="WebApp_ID">
   <display-name>Hello World Portlet</display-name>
   <taglib>
      <taglib-uri>http://java.sun.com/portlet</taglib-uri>
      <taglib-location>tld/portlet.tld</taglib-location>
   </taglib>
</web-app>

Put portlet.tld (the prtlet 2.0 version) in your tld directory. Note we aren't using JSPs so this will be empty. For a good (but broken) JSP based tutorial, see here:

http://www.ibm.com/developerworks/java/library/j-pluto/

Build using the mvn build script supplied in:

http://portals.apache.org/pluto/v20/deploying.html

If you don't add the automatic deployment section of the build script the move the build war to your pluto (tomcat) webapps.

Within your browser, you must publish your new HelloWorld webapp from the admin page within the pluto portal (add page -> add portlet). A new tab should be added containing your portlet.

3. Deploy the portlet under WebLogic

  1. Add the pluto libraries to your WebLogic lib. I put these in your domain library directory (which contains a readme indicating this is for adding jars to be dynamically loaded on 10.2.3). This is ${MYDOMAIN}/lib. The jars to locate there are as follows:

    http://portals.apache.org/pluto/v20/embedding.html

  2. Add the pluto web application and any referenced (published) webapps into your WLS upload directory. This means including testsuite which is provided with pluto and your new helloworld webapp.

  3. Configure WLS to be able to access your portlets:

    1. The pluto webapps are security configured for users pluto and tomcat. So, you have to add a new "pluto" user to your WLS security realm [Security Realms -> myRealm]
    2. Configure webapp security to map the security role to the WLS user. This means creating ${MYUPLOAD}/pluto/WEB-INF/weblogic.xml. Here add a "security-role-assignment" entry for principal pluto (your new WebLogic user).
    3. Note that the testsuite/WEB-INF/web.xml is only authorised for user tomcat. Change this to pluto.
    4. Add portlet_2_0.tld to ${UPLOAD}/testsuite/WEB-INF/tld (make tld dir). This is available at: http://svn.apache.org/repos/asf/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/tld/portlet_2_0.tld
    5. Several of the testsuites will still fail under WLS. There are outstanding issues between apache and the community. They see it as a WLS issue (on the apache pluto jira at https://issues.apache.org/jira/browse/PLUTO-571 ).
    6. There is an issue where by the portlet is actually presented outside the portlet frame (div) when using JSP rendering. Not got to the bottom of this yet.

4. Portlet Communication

Have two portlets interoperating. Refer to:

http://publib.boulder.ibm.com/infocenter/wpexpdoc/v6r1/index.jsp?topic=/com.ibm.wp.exp.doc_v6101/dev/pltcom_pubrndrprm.html

5. Build more heavyweight portlets

Refer to more complex webapp tutorial using JSPs at:

http://www.ibm.com/developerworks/java/library/j-pluto/
//Warning: portlet 1.0 (JSR-168) and contains errors

Then try your own...

6. Upgrade portal implementation

Try out JetSpeed for example. Refer to:

http://portals.apache.org/jetspeed-2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM