11 Replies Latest reply on Dec 4, 2007 9:42 PM by Abby Fichtner

    When do you need to create additional instances of a portlet

    Abby Fichtner Newbie

      I'm using JBoss 2.6.2 and I want to include the same portlet in a couple of different places in my portal. However, in each place, it would clip a different web page. In other words, each time I use the PortletBridge portlet, I'd want to set different preferences for it.

      Let's say I in one place it displays google, in the 2nd it displays yahoo.

      By default, PortletBridge (which is deployed seperately from my application on JBoss) has already created a single PortletBridgeInstance.

      Do I need to create 2 new instances of PortletBridge, so that I can set one instance's URL pref to google, the other's to yahoo?

      (and if so, where do I create them? I tried creating them in my own portal's portlet-instances.xml but it failed because it appended my portal's name to the path and so couldn't find myportal.org.portletbridge.portlet.PortletBridgePortlet)

      Or.... can I just have both places use the single PortletBridgeInstance that already exists?

      (and, if so, where would I specify the preferences in each place? Note that I need this to all be done inside of the WAR, not through the web UI)


      Thanks!
      Abby

        • 1. Re: When do you need to create additional instances of a por
          Peter Johnson Master

          Yes, you need to create 2 new instances. In your portlet-instances.xml file is the correct place to do this, then you refer to the instances in your *-object.xml file. That has always worked fine for me.

          Could you post the declarations of the instances and the windows from your portlet-instances and *-object.xml files? Don't foget to bracket the entries with the [ code ]...[ /code ] tags (without spaces).

          • 2. Re: When do you need to create additional instances of a por
            Abby Fichtner Newbie

            Thank you. Here is my portlet-instances.xml:

            <?xml version="1.0" standalone="yes"?>
            <!DOCTYPE deployments PUBLIC
             "-//JBoss Portal//DTD Portlet Instances 2.6//EN"
             "http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd">
            <deployments>
             <deployment>
             <if-exists>overwrite</if-exists>
             <instance>
             <instance-id>GooglePortletBridgeInstance</instance-id>
             <portlet-ref>org.portletbridge.portlet.PortletBridgePortlet</portlet-ref>
             </instance>
             <preferences>
             <preference>
             <name>initUrl</name>
             <value>http://www.google.com</value>
             </preference>
             </preferences>
             </deployment>
            </deployments>


            I don't think my *-object.xml is an issue becuase the above doesn't work. Instead, here is my jboss-app.xml:

            <jboss-app>
             <app-name>ehealth</app-name>
            </jboss-app>


            When I deploy, I get the following error:
            17:24:17,203 WARN [PortletAppDeployment] Failed to create instance GooglePortletBridgeInstance of portlet ehealth.org.portletbridge.portlet.PortletBridgePortlet because portlet ehealth.org.portletbridge.portlet.PortletBridgePortlet is not available


            As you can see, it appended my app name ("ehealth") to the portletbridge package name, so now it can't find it.

            Do you know how I can stop it from appending my application's name to the front so that it can find the portlet?

            Thanks!
            Abby

            • 3. Re: When do you need to create additional instances of a por
              Peter Johnson Master

              Ah, it's all coming back to me now. That's what happens when I don't deal with a problem for a while, I forget some of the hoops I jumped through.

              Try this. In your portlet.xml file, declare another portlet, say 'YetAnotherBridgePortlet' whose class is org.portletbridge.portlet.PortletBridgePortlet. Then in portlet-instance.xml, you can have:

              <instance>
               <instance-id>GooglePortletBridgeInstance</instance-id>
               <portlet-ref>YetAnotherBridgePortlet</portlet-ref>
               </instance>
               <instance>
               <instance-id>YahooPortletBridgeInstance</instance-id>
               <portlet-ref>YetAnotherBridgePortlet</portlet-ref>
               </instance>


              Then reference GooglePortletBridgeInstance and YahooPortletBridgeInstance in *-object.xml.

              Caveat: I think this is what I did; I am still looking for the files or writeup where I explained this to someone a while back. Once I find the evidence, if it is different, I will post a correction.

              • 4. Re: When do you need to create additional instances of a por
                Abby Fichtner Newbie

                Huh, interesting. Although, unfortunately it's not finding the PortletBridge even with the correct package in portlet.xml:

                <portlet>
                 <portlet-name>eHealthPortletBridge</portlet-name>
                 <portlet-class>org.portletbridge.portlet.PortletBridgePortlet</portlet-class>
                 </portlet>


                Gave me this error:
                18:07:53,906 ERROR [STDERR] org.jboss.portal.portlet.container.PortletInitializationException: Portlet class not found org.portletbridge.portlet.PortletBridgePortlet


                I tried a number of permutations, but with no better luck. Any other ideas?

                • 5. Re: When do you need to create additional instances of a por
                  Peter Johnson Master

                  Ah, class loading issues. How fun.

                  I guess the next question is where is everything deployed? In other words, where is the PortletBridge deployed and where is your portlet deployed? Are they in separate war files in the deploy directory, or is either of them in the jboss-portal.sar directory (such as in the samples directory). One possibility is including the PortletBridge portlet code in the same war as your portlet (this is what i would do because the bridge portlet is just a sample portlet from PortletSwap). Another possibility is placing both war files in the jboss-portal.sar/samples directory (not guaranteed to work, but worth a shot).


                  • 6. Re: When do you need to create additional instances of a por
                    Abby Fichtner Newbie

                    Okay, let me try a few more things. I just installed portlet-bridge seperately. I don't see a very easy way to include it in my war (it is built with maven, I'm building mine with ant, and they're both structured a little differently as far as file locations). But, maybe I can just modify the portlet-bridge WAR itself to create the instances for me.

                    This feels like a horrible hack though. There must be another way to do this.

                    I'm also going to need to create instances of NewsPortlet (a portlet that comes installed automatically in JBoss Portal), but am running into the same problems there. Do you know how I'd create instances of that? I feel like I'm just going to keep hitting the same problem...

                    • 7. Re: When do you need to create additional instances of a por
                      Peter Johnson Master

                      The procedure would be the same for any portlet (including the news portlet).

                      One of the things I did not think of is to edit the portlet-instances.xml file for the desired portlet to add the extra instances. That might be the sanest solution for now.

                      I am sitting in a hotel, attending a week-long conference, with a brand new laptop (my beloved Dell died) which I haven't had a chance to set up with my development environment. If I was at work I would continue looking for the portal where I did all of this, or at least try it again from scratch and post my findings and recommendations. I'll try setting up the laptop and see where that goes, but knowing how busy I am at this conference it might take a while before I have results. I'll keep you posted.

                      • 8. Re: When do you need to create additional instances of a por
                        Abby Fichtner Newbie

                         

                        One of the things I did not think of is to edit the portlet-instances.xml file for the desired portlet to add the extra instances. That might be the sanest solution for now.


                        I'd love to add it to the portlet-instances.xml, that was what I thought the right way to go was. However, when I tried, I got errors (see 3rd post in this thread with example). Could you maybe explain what you're thinking? I might also try a seperate thread to ask this question to clarify it based on what I've learned...


                        • 9. Re: When do you need to create additional instances of a por
                          Peter Johnson Master

                          An example to clarify what I meant: to create another instance of the news portlet, go to jboss-portal.sar/samples/portal-news-samples.war/WEB-INF/portlet-instances.xml and add the new instance there.

                          • 10. Re: When do you need to create additional instances of a por
                            Abby Fichtner Newbie

                            Oh, I see. Okay, thank you. That makes sense.

                            However, I've just learned that it isn't just creating instances of external portlets that are failing. I created a portlet inside of my war and have the same problem. It keeps appending "ehealth." to the front of everything and so can't find it.

                            I am totally banging my head against the wall. I tried blanking out the app-name in jboss-app.xml, but all that did was to start appending "." to the start of everything.

                            I've obviously got something set wrong. Do you have any idea how I can tell it that the context to start from should be blank (not "ehealth" or ".")

                            • 11. Re: When do you need to create additional instances of a por
                              Abby Fichtner Newbie

                              Oops - ignore last post. Staring at screen too long. Creating local instances works just fine.

                              Phew, okay, I think I'm good. Thanks so much for all of your help!