I am using jboss portal 2.6.6. I have a struts portlet that works fine, except 
when I need to use prefs.store() to store preferences... I get:

Caused by: java.lang.IllegalStateException: Store must be called within the 
scope of an action request
        at 
org.jboss.portal.portlet.impl.jsr168.api.PortletPreferencesImpl.store(PortletPreferencesImpl.java:282)
        at com.portlet.data_now.action.ViewAction.execute(ViewAction.java:56)
        at 
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
        ... 

here is the source for the class I get the error from:

  | package com.portlet.data_now.action;
  | 
  | import java.io.IOException;
  | import java.security.NoSuchAlgorithmException;
  | 
  | import javax.portlet.PortletPreferences;
  | import javax.portlet.ReadOnlyException;
  | import javax.portlet.RenderRequest;
  | import javax.portlet.RenderResponse;
  | import javax.portlet.ValidatorException;
  | import javax.servlet.http.HttpServletRequest;
  | import javax.servlet.http.HttpServletResponse;
  | 
  | import org.apache.struts.action.Action;
  | import org.apache.struts.action.ActionForm;
  | import org.apache.struts.action.ActionForward;
  | import org.apache.struts.action.ActionMapping;
  | 
  | import com.firescope.data_now.FileCreator;
  | 
  | public class ViewAction extends Action {
  |     public ActionForward execute(ActionMapping mapping, ActionForm form,
  |                     HttpServletRequest req, HttpServletResponse res) {
  |             RenderRequest pReq = (RenderRequest) 
req.getAttribute("javax.portlet.request");
  |             RenderResponse rRes = (RenderResponse) 
req.getAttribute("javax.portlet.response");
  |             PortletPreferences pr = (PortletPreferences) 
pReq.getPreferences();
  |             String fwd = "portlet.data_now.view";
  |             String alreadyOK = pr.getValue("verified", "");
  |             String isOK = null;
  |             String keytext = req.getParameter("licenseKey");
  |             
  |             if ((null != keytext) && (!keytext.equals(""))) {
  |                     FileCreator fc = new FileCreator();
  |                     String success = null;
  |                     try {
  |                             success = fc.makeKeyFile(keytext);
  |                     } catch (IOException e) {
  |                             System.out.println("Error writing key file: 
"+e);
  |                     }
  |             }
  | 
  |             if ((alreadyOK == null) || (!alreadyOK.equals("1"))) {
  |                     FileReader fr = new FileReader();
  |                     try {
  |                             isOK = fr.getLines(pReq, rRes);
  |                     } catch (NoSuchAlgorithmException e) {
  |                             e.printStackTrace();
  |                     } catch (ReadOnlyException e) {
  |                             e.printStackTrace();
  |                     } catch (ValidatorException e) {
  |                             e.printStackTrace();
  |                     } finally {
  |                             if((null != isOK)&&(isOK.equals("1"))){
  |                                     try {
  |                                             pr.setValue("verified", "1");
  |                                             pr.store();
  |                                             return mapping.findForward(fwd);
  |                                     } catch (ReadOnlyException e) {
  |                                             e.printStackTrace();
  |                                     }
  |                             }
  |                     }
  |             } else {
  |                     isOK = "1";
  |             }
  |             if ((null == isOK) || (!isOK.equals("1"))) {
  |                     fwd = "portlet.data_now.license";
  |             }
  |             return mapping.findForward(fwd);
  |     }
  | }
  | 
  | 

This same code works perfectly in another portal and I am trying to port this 
to jboss... any help here?

Bryancan

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4174205#4174205

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4174205
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to