Error: value of non-serializable attribute in ViewMap

I have the same application on two systems (laptops), but it works in one, but not in the other. I get the following error on another system. I also posted the code below. What I want to do is a cascading drop-down menu with a button that calls another managed bean method, and a placeOrder button to add an entry to the database. But at that time I get the following error: page load

WARNING: Setting non-serializable attribute value into ViewMap: (key: stockOrderBean, value class: beans.stockOrderBean)
    SEVERE: Error Rendering View[/ClientTemplate/stockTrade.xhtml]
    java.io.NotSerializableException: beans.stockOrderBean

    WARNING: JSF1087: Unable to generate Facelets error page as the response has already been committed.
    SEVERE: javax.faces.FacesException: beans.stockOrderBean

xhtmlcode:

                <h:outputText value="Exchange :"/>

                <p:selectOneMenu value="#{stockOrderBean.exchange}" style="width: 200px">
                    <f:selectItem itemLabel="Select Exchange"/>
                    <f:selectItem itemLabel="NSE" itemValue="nse"/> 
                    <f:selectItem itemLabel="BSE" itemValue="bse"/>
                    <p:ajax update="sym" listener="#{stockOrderBean.wow}"/>
                </p:selectOneMenu>
                <h:outputText value="Select ScripSymbol :"/>

                <p:selectOneMenu value="#{stockOrderBean.scripID}" style="width: 200px" id="sym">
                    <f:selectItem itemLabel="Select scrip"/>
                    <f:selectItems var="scrip" value="#{stockOrderBean.sl}" itemLabel="#{scrip.scripSymbol}" itemValue="#{scrip.scripID}"/>
                </p:selectOneMenu>

                <p:commandButton value="Get Quote"  actionListener="#{stockOrderBean.equity.setQuote}" oncomplete="cd.show()" update=":frmdialog" />

                <h:panelGrid columns="2" id="d1" style="width:565px">
                    <h:outputText value="How would you like to place order"/>                                
                    <p:selectOneRadio value="#{stockOrderBean.transType}">
                        <f:selectItem itemLabel="Market Order" itemValue="MarketOrder"/>
                        <p:ajax update="frmTrade:d1"/>
                        <f:selectItem itemLabel="Limit Order" itemValue="LimitOrder"/>
                        <p:ajax update="frmTrade:d1"/>
                   </p:selectOneRadio>                            
                   <h:outputText value="Trigger Price"/>
                   <p:inputText value="#{stockOrderBean.triggerPrice}" disabled="#{stockOrderBean.transType == 'LimitOrder'}"/>
                   <h:outputText value="Limit Price"/>
                   <p:inputText value="#{stockOrderBean.limitPrice}" disabled="#{stockOrderBean.transType == 'MarketOrder'}"/>                                
                </h:panelGrid>                

                <h:outputText value="Select your Demate Account"/>

                <p:selectOneMenu value="#{stockOrderBean.demateAccount}" style="width: 120px">
                    <f:selectItem itemLabel="#{stockOrderBean.demateAccount}" itemValue="#{stockOrderBean.demateAccount}"/>
                </p:selectOneMenu>

                <p:commandButton value="Place New Order"  actionListener="#{stockOrderBean.placeOrder}"/>
         <p:commandButton value="Reset New Order" type="reset"/>

</h:form>        
        <p:dialog widgetVar="cd" header="Scrip Quotes Detail" resizable="true">
            <h:form id="frmdialog">                        
                <table>
                            <tr>
                            <td>
                                Ask :
                            </td>
                            <td>                                        
                                <b><h:outputText value="#{stockOrderBean.equity.ask}"/></b>
                            </td>

                    </table>
               </h:form>
       </p:dialog>           

SockOrderBean Code:

    @javax.faces.bean.ManagedBean
@javax.faces.bean.ViewScoped
public class stockOrderBean{

    @WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/StatelessWebService/StatelessWebService.wsdl")
    private StatelessWebService_Service service;
//properties with getter setter
 @ManagedProperty(value="#{equtiyBean}")
    private equityBean equity = new equityBean();
public void placeOrder(...){
//method not called
}

the same code works on one system, but not on another. What could be the reason and how can I solve it?

+5
source share
3 answers

HTTP , . , , , Serializable, ObjectOutputStream Java , ObjectInputStream Java.

, HTTP, Serializable, NotSerializableException . Serializable.

public class StockOrderBean implements Serializable {
    // ...
}

JSF beans . beans Serializable. , bean Serializable. NotSerializableException, .

+11

, , . , bean , , Serializable. , .

0

Try adding the code below to your web.xml. It will store server-side session objects.

<context-param>
   <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
   <param-value>server</param-value>
</context-param>
0
source

All Articles