3 Replies Latest reply on Mar 1, 2008 4:21 AM by Stephan Eisermann

    NullPointer: Setting portlet instance preferences via Instan

    Stephan Eisermann Newbie

      Hi using this development setup:

      * Version: jboss-portal-2.6.1.GA
      * Download Version
      * JBoss AS Version: 4.2.1.GA (build: SVNTag=JBoss_4_2_1_GA date=200707131605)]
      * Database: Mysql 5.0.51a-community-nt
      * JDBC Connector and Version: mysql-connector-java-5.0.5-bin.jar
      * OS Platform: Windows XP 32-Bit

      I have injected the InstanceContainer and set transaction support via jboss-portlet.xml:




      Reading from the portlet instnaces does work, writing to the portlet preferences creates a nullpointer, using this example code:

      //Get the instance container
      InstanceContainer instanceContainer = (InstanceContainer) this.getPortletRequest().getPortletSession().getPortletContext().getAttribute("InstanceContainer");
      InstanceDefinition id = instanceContainer.getDefinition("startPortletInstance");
      // This does work!
      PropertyMap pmap = id.getProperties();
      String uuid = ((StringValue) pmap.get("uuid")).toString();
      List tmp = new ArrayList();
      if (pmap.containsKey("uuid")) {
       PropertyChange change = PropertyChange.newUpdate("uuid", new StringValue(documentId));
      PropertyChange[] changes = (PropertyChange[]) tmp.toArray(new PropertyChange[tmp.size()]);
      //This doesn't work

      I have debugged the setProperties() method for my portlet und the admin portlet and found the problematic section:


      The following code line leads to the nullpointer:


      The problem seems to be, that the loaded (hibernate?) PersistentPortletState object is not set up correctly, most properties are empty. I have compared this to the admin-core portlet - there is the object loaded correctly.

      Some questions:

      1. Am i gettin the InstanceCotainer correctly:

      InstanceContainer instanceContainer = (InstanceContainer) this.getPortletRequest().getPortletSession().getPortletContext().getAttribute("InstanceContainer");