11 Replies Latest reply on Sep 24, 2004 1:13 PM by Dennis Przybyla

    Problems with persistence

    Dennis Przybyla Novice

      I am having problems with persistence. I am not sure what I am missing.

      In my jboss services module I have:

       <mbean
       code="org.jboss.nukes.addons.modules.kingpin.KingpinModule"
       name="nukes.modules:name=kingpin"
       xmbean-dd=""
       xmbean-code="org.jboss.nukes.component.NukesMBean">
       <depends>nukes.modules:name=core</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Subscription</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/DataType</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/EventLog</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Feedback</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/FtpPackage</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/KingpinExport</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/KingpinFile</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/KingpinInbox</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Measurement</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/LovValues</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Media</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Mission</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Package</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Report</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Requirement</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Signal</depends>
       <depends>jboss.j2ee:service=EJB,jndiName=nukes/kingpin/Tape</depends>
       <constructor>
       <arg type="boolean" value="true"/>
       </constructor>
       <xmbean>
       <attribute
       name="NumberPackagesPerPage"
       description="Number of packages to display in the package list">10</attribute>
       <attribute
       name="ThresholdEvent"
       description="Event to start counting from">Package Created</attribute>
       <attribute
       name="ThresholdDay1"
       description="Threashold Day to use color 1">15</attribute>
       <attribute
       name="ThresholdDay2"
       description="Threashold Day to use color 2">30</attribute>
       <attribute
       name="ThresholdDay3"
       description="Threashold Day to use color 3">60</attribute>
       <attribute
       name="ThresholdColor1"
       description="Color to use for Threshold Day 1">green</attribute>
       <attribute
       name="ThresholdColor2"
       description="Color to use for Threshold Day 2">yellow</attribute>
       <attribute
       name="ThresholdColor3"
       description="Color to use for Threshold Day 3">red</attribute>
       <attribute name="Security">
       <security>
       <permission group="User" pattern=".*:.*:.*" level="READ"/>
       <permission group="Admins" pattern=".*:.*:.*" level="ADMIN"/>
       </security>
       </attribute>
       <attribute name="Configuration">
       <module>
       <operation
       name="main"
       display-name="Kingpin"
       description="Kingpin module"
       image=""
       hint=""/>
       </module>
       </attribute>
       </xmbean>
       </mbean>
      


      In my module I have:

       private int numberPackagesPerPage = 10;
       private long analysisSourceSeqNum = 0;
       private String thresholdEvent;
       private int thresholdDay1;
       private int thresholdDay2;
       private int thresholdDay3;
       private String thresholdColor1;
       private String thresholdColor2;
       private String thresholdColor3;
       private String ravenFeedbackLink="";
       private String requirementsPageLink="";
      
       /**
       * numberPackagesPerPage should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setNumberPackagesPerPage(int numberPackagesPerPage)
       {
       this.numberPackagesPerPage = numberPackagesPerPage;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public int getNumberPackagesPerPage()
       {
       return numberPackagesPerPage;
       }
      
       /**
       * analysisSourceSeqNum should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setAnalysisSourceSeqNum(long analysisSourceSeqNum)
       {
       this.analysisSourceSeqNum = analysisSourceSeqNum;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public long getAnalysisSourceSeqNum()
       {
       setAnalysisSourceSeqNum(analysisSourceSeqNum + 1);
       return analysisSourceSeqNum;
       }
      
       /**
       * thresholdDay1 should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setThresholdEvent(String thresholdEvent)
       {
       this.thresholdEvent = thresholdEvent;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public String getThresholdEvent()
       {
       return thresholdEvent;
       }
      
       /**
       * thresholdDay1 should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setThresholdDay1(int thresholdDay1)
       {
       this.thresholdDay1 = thresholdDay1;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public int getThresholdDay1()
       {
       return thresholdDay1;
       }
      
       /**
       * thresholdDay2 should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setThresholdDay2(int thresholdDay2)
       {
       this.thresholdDay2 = thresholdDay2;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public int getThresholdDay2()
       {
       return thresholdDay2;
       }
      
       /**
       * thresholdDay2 should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setThresholdDay3(int thresholdDay3)
       {
       this.thresholdDay3 = thresholdDay3;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public int getThresholdDay3()
       {
       return thresholdDay3;
       }
      
       /**
       * thresholdColor1 should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setThresholdColor1(String thresholdColor1)
       {
       this.thresholdColor1 = thresholdColor1;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public String getThresholdColor1()
       {
       return thresholdColor1;
       }
      
       /**
       * thresholdColor2 should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setThresholdColor2(String thresholdColor2)
       {
       this.thresholdColor2 = thresholdColor2;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public String getThresholdColor2()
       {
       return thresholdColor2;
       }
      
       /**
       * thresholdColor3 should be accessible from jmx-console
       *
       * @param value DOCUMENT ME!
       */
       public void setThresholdColor3(String thresholdColor3)
       {
       this.thresholdColor3 = thresholdColor3;
       }
      
       /**
       * DOCUMENT ME!
       *
       * @return DOCUMENT ME!
       */
       public String getThresholdColor3()
       {
       return thresholdColor3;
       }
       /**
       * @return
       */
       public String getRavenFeedbackLink()
       {
       return ravenFeedbackLink;
       }
      
       /**
       * @param string
       */
       public void setRavenFeedbackLink(String ravenFeedbackLink)
       {
       this.ravenFeedbackLink = ravenFeedbackLink;
       }
      
       /**
       * @return
       */
       public String getRequirementsPageLink()
       {
       return requirementsPageLink;
       }
      
       /**
       * @param string
       */
       public void setRequirementsPageLink(String requirementsPageLink)
       {
       this.requirementsPageLink = requirementsPageLink;
       }
      


      The problem is when I call the set functions of any of these jmx variables in my module, It doesn't update the entry in the nukes.nuke_services_attributes table. What am I doing wrong?

        • 1. Location for module generic but Oracle specific SQL scripts?
          Dennis Przybyla Novice

          I'm looking for some kind of consensus as to an appropriate location for database specific but module generic one-time use SQL scripts? The reasoning is that any changes to indexing, triggers, etc would be reflected in the setup.xml file -but- for existing installations, the end user would obviously not want to re-run setup.ddl so we need a way to provide an "upgrade" path. For example, I would create a file like 'nukes10.sql' in cvs head (2.0) to indicate an upgrade script from Nukes 1.0 to 2.0. My current train of thought is that these should be in:

          nukes/nukes/src/resources/oracle

          since the prepare.ddl file lives there. Let me know your thoughts on that. Thanks!

          • 2. Re: Problems with persistence
            Viet Master

            did you call the constructor of the parent class with persistent = true ?

            • 3. 3725105
              Viet Master

              did you call the constructor of the parent class with persistent = true ?

              • 4. Re: Problems with persistence
                Dennis Przybyla Novice

                Here are my constructers

                 /**
                 * Default Constructor
                 */
                 public KingpinModule()
                 {
                 // setup the module name
                 this("kingpin", false);
                 }
                
                 /**
                 * Constructor which you can set the JNDI name of the class. Using this
                 * constructor defaults to no persistance.
                 * @param name the JNDI name of this class.
                 */
                 public KingpinModule(String name)
                 {
                 this(name, false);
                 }
                
                 /**
                 * Constructor which you can set persistance of the class.
                 * @param persistent Does this class persist if the server is shutdown.
                 */
                 public KingpinModule(boolean persistent)
                 {
                 this("kingpin", persistent);
                 }
                
                 /**
                 * Constructor which you can set the JNDI name of the class and if it is persistant.
                 * @param name the JNDI name of this class.
                 * @param persistent Does this class persist if the server is shutdown.
                 * @return The object at the top of this stack.
                 * @exception NoSuchElementException if this stack is empty.
                 */
                 public KingpinModule(String name, boolean persistent)
                 {
                 // setup the module name
                 super(name, persistent);
                 System.out.println("********** persistent = " + persistent);
                 CLLoader loader = new CLLoader("org/jboss/nukes/addons/modules/kingpin/templates");
                 repository = new TemplateLoader(loader);
                 }
                
                


                The System.out.println prints out persistent = true.

                • 5. Re: Problems with persistence
                  Dennis Przybyla Novice

                  I removed the JMX module and it removed this exception but I still am not getting persistence

                  • 6. Re: Problems with persistence
                    Dennis Przybyla Novice

                    Here are the functions in my module that call the setters and getters:

                     public void displayConfiguration(Page page)
                     {
                     if (!secAuthAction("configuration::", Constants.SEC_ACCESS_ADMIN))
                     {
                     displayError(page, "${kingpin.NO_AUTH}");
                     return;
                     }
                    
                     String authId = getApi().generateAuthKey(getName()),
                     newNumberPackagesPerPage =
                     page.getParameter("numberPackagesPerPage", Integer.toString(getNumberPackagesPerPage())),
                     newThresholdEvent = page.getParameter("thresholdEvent", getThresholdEvent()),
                     newThresholdDay1 = page.getParameter("thresholdDay1", Integer.toString(getThresholdDay1())),
                     newThresholdDay2 = page.getParameter("thresholdDay2", Integer.toString(getThresholdDay2())),
                     newThresholdDay3 = page.getParameter("thresholdDay3", Integer.toString(getThresholdDay3())),
                     newThresholdColor1 = page.getParameter("thresholdColor1", getThresholdColor1()),
                     newThresholdColor2 = page.getParameter("thresholdColor2", getThresholdColor2()),
                     newThresholdColor3 = page.getParameter("thresholdColor3", getThresholdColor3()),
                     newRavenFeedbackLink = page.getParameter("ravenFeedbackLink", getRavenFeedbackLink()),
                     newRequirementsPageLink = page.getParameter("requirementsPageLink", getRavenFeedbackLink());
                     DelegateContext configurationContext = new DelegateContext();
                    
                     configurationContext.put("NUMBER_PACKAGES_PER_PAGE", newNumberPackagesPerPage);
                     configurationContext.put("THRESHOLD_EVENT", newThresholdEvent);
                     configurationContext.put("THRESHOLD_DAY_1", newThresholdDay1);
                     configurationContext.put("THRESHOLD_DAY_2", newThresholdDay2);
                     configurationContext.put("THRESHOLD_DAY_3", newThresholdDay3);
                     configurationContext.put("THRESHOLD_COLOR_1", newThresholdColor1);
                     configurationContext.put("THRESHOLD_COLOR_2", newThresholdColor2);
                     configurationContext.put("THRESHOLD_COLOR_3", newThresholdColor3);
                     configurationContext.put("RAVEN_FEEDBACK_LINK", newRavenFeedbackLink);
                     configurationContext.put("REQUIREMENTS_PAGE_LINK", newRequirementsPageLink);
                    
                     configurationTemplate.render(configurationContext, page.getBodyWriter());
                     }
                    
                     public void configure(Page page)
                     {
                     if (!secAuthAction("configuration::", Constants.SEC_ACCESS_ADMIN))
                     {
                     displayError(page, "${kingpin.NO_AUTH}");
                     return;
                     }
                    
                     String authId = getApi().generateAuthKey(getName()),
                     newNumberPackagesPerPage = page.getParameter("numberPackagesPerPage", ""),
                     newThresholdEvent = page.getParameter("thresholdEvent", ""),
                     newThresholdDay1 = page.getParameter("thresholdDay1", ""),
                     newThresholdDay2 = page.getParameter("thresholdDay2", ""),
                     newThresholdDay3 = page.getParameter("thresholdDay3", ""),
                     newThresholdColor1 = page.getParameter("thresholdColor1", ""),
                     newThresholdColor2 = page.getParameter("thresholdColor2", ""),
                     newThresholdColor3 = page.getParameter("thresholdColor3", ""),
                     newRavenFeedbackLink = page.getParameter("ravenFeedbackLink",""),
                     newRequirementsPageLink = page.getParameter("requirementsPageLink","");
                    
                     if (newNumberPackagesPerPage.equals(""))
                     {
                     displayConfiguration(page);
                    
                     DelegateContext errorContext = new DelegateContext();
                    
                     if (newNumberPackagesPerPage.equals("")
                     || newNumberPackagesPerPage.equals("0")
                     || newThresholdEvent.equals("")
                     || newThresholdDay1.equals("")
                     || newThresholdDay2.equals("")
                     || newThresholdDay3.equals("")
                     || newThresholdColor1.equals("")
                     || newThresholdColor2.equals("")
                     || newThresholdColor3.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Number Packages Per Page must be greater than 0 and not null.");
                     }
                     if (newThresholdEvent.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Threshold Event can not be null.");
                     }
                     if (newThresholdDay1.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Threshold Day 1 can not be null.");
                     }
                     if (newThresholdDay2.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Threshold Day 2 can not be null.");
                     }
                     if (newThresholdDay3.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Threshold Day 3 can not be null.");
                     }
                     if (newThresholdColor1.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Threshold Color 1 can not be null.");
                     }
                     if (newThresholdColor2.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Threshold Color 2 can not be null.");
                     }
                     if (newThresholdColor3.equals(""))
                     {
                     DelegateContext errorMessageContext = errorContext.next("errorMessageLoop");
                     errorMessageContext.put("ERROR_TEXT", "Threshold Color 3 can not be null.");
                     }
                    
                     errorDisplayTemplate.render(errorContext, page.getBodyWriter());
                    
                     return;
                     }
                     setNumberPackagesPerPage(Integer.parseInt(newNumberPackagesPerPage));
                     setThresholdEvent(newThresholdEvent);
                     setThresholdDay1(Integer.parseInt(newThresholdDay1));
                     setThresholdDay2(Integer.parseInt(newThresholdDay2));
                     setThresholdDay3(Integer.parseInt(newThresholdDay3));
                     setThresholdColor1(newThresholdColor1);
                     setThresholdColor2(newThresholdColor2);
                     setThresholdColor3(newThresholdColor3);
                     setRavenFeedbackLink(newRavenFeedbackLink);
                     setRequirementsPageLink(newRequirementsPageLink);
                    
                     page.sendHTMLRedirect(
                     "Modified configuration completed successfully",
                     "index.html?module=html&op=main&authid=" + getApi().generateAuthKey("kingpin"));
                     }
                    


                    When I use the configuration page to set the values this is what I see:

                    1) In the JMX module the values are changed
                    2) In the nukes.nuke_services_attributes table the values are not changed
                    3) The values are changed on my configuration page

                    When I use the JMX module to change the values this is what I see:

                    1) In the JMX module the values are changed
                    2) In the nukes.nuke_services_attributes table the values are changed
                    3) The values are changed on my configuration page

                    Why does it work in the JMX module but the getters and setters are not setting the values in the database?

                    • 7. Re: Problems with persistence
                      Dennis Przybyla Novice

                      If I do this instead of calling a settter in the Kingpin Module it works:

                       try
                       {
                       ObjectName name = new ObjectName("nukes.modules:name=kingpin");
                       String att = "NumberPackagesPerPage";
                       String type = "int";
                       Object value = null;
                       value = Tools.fromString(type, newNumberPackagesPerPage);
                       System.out.println("++++++++ value = " + value.toString());
                      
                       server.setAttribute(name, new Attribute(att, value));
                       }
                       catch (Exception e)
                       {
                       page.reset();
                       page.sendError(e);
                       }
                      


                      Any Ideas?

                      • 8. Re: Problems with persistence
                        Viet Master

                        you were modifying attributes within the module itself with somehting like :

                        { this.myfield = "some value"; }
                        ?

                        • 9. Re: Problems with persistence
                          Dennis Przybyla Novice

                          I created the jmx values in my module doing this (also setting up the jboss_services.xml file):




                          private int packagesPerPage = 0;
                          
                          public int getPackagesPerPage()
                          {
                           return packagesPerPage;
                          }
                          
                          public void setPackagesPerPage(int packagesPerPage)
                          {
                           this.packagesPerPage = packagesPerPage;
                          }
                          


                          then in a configuration page to change the values I would do something like this:

                          public void displayConfiguration(Page page)
                          {
                           // Code to display configuration values and inputs to change them.
                          }
                          
                          public void configure(Page page)
                          {
                           // Check to make sure new values are good
                          
                           // Then I would use this function to change the values
                           setPackagesPerPage(newPackagesPerPage);
                          }
                          


                          • 10. Re: Problems with persistence
                            Dennis Przybyla Novice

                            I need to fix the downloads module then because I do the same thing in there.

                            • 11. Re: Problems with persistence
                              Dennis Przybyla Novice

                              I always thought it was wierd that just calling the setPackagesPerPage would take care of the persistance but I thought that it was jboss magic or somthing like that.

                              Oh well, I am learning.