我在启动 apache 时收到此警告。我正在尝试使用HashMap<Integer,webservice.DataProd>
. 我尝试使 DataProd 实现可序列化,但仍然相同,所以由于我是 web 服务的新手,我不知道该怎么做。
这是数据产品
package Producto;
import java.io.Serializable;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class DataProd{
private String nombre;
private String descripcion;
private String especificacion;
private int id;
private double precio;
private int cantidadVendidos;
public DataProd(String nom, String desc, double costo, int identificador, String esp, int cantidad){
nombre = nom;
descripcion = desc;
precio = costo;
id = identificador;
especificacion = esp;
cantidadVendidos = cantidad;
}
public DataProd(){}
public String getNombre(){
return nombre;
}
public String getDescripcion(){
return descripcion;
}
public double getPrecio(){
return precio;
}
public int getCantidadVendidos(){
return cantidadVendidos;
}
public int getId(){
return id;
}
@Override
public String toString(){
return getNombre() + " - " + getId();
}
@Override
public boolean equals(Object d){
DataProd s = (DataProd) d;
return ((getNombre().equals(s.getNombre()))&&(getDescripcion().equals(s.getDescripcion()))&&(getId() == s.getId())&&(getPrecio()==s.getPrecio()));
}
@Override
public int hashCode() {
int hash = 7;
hash = 11 * hash + Objects.hashCode(this.getNombre());
hash = 11 * hash + Objects.hashCode(this.getDescripcion());
hash = 11 * hash + this.getId();
hash = 11 * hash + (int) (Double.doubleToLongBits(this.getPrecio()) ^ (Double.doubleToLongBits(this.getPrecio()) >>> 32));
return hash;
}
/**
* @param nombre the nombre to set
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}
/**
* @param descripcion the descripcion to set
*/
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
/**
* @return the especificacion
*/
public String getEspecificacion() {
return especificacion;
}
/**
* @param especificacion the especificacion to set
*/
public void setEspecificacion(String especificacion) {
this.especificacion = especificacion;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @param precio the precio to set
*/
public void setPrecio(double precio) {
this.precio = precio;
}
/**
* @param cantidadVendidos the cantidadVendidos to set
*/
public void setCantidadVendidos(int cantidadVendidos) {
this.cantidadVendidos = cantidadVendidos;
}
}
这是我的堆栈:
WARNING: Cannot serialize session attribute productos for session 5D0658D2DFB89594B8F8D19FAC54C66B
java.io.NotSerializableException: webservice.DataProd
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at java.util.HashMap.writeObject(HashMap.java:1100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1671)
at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1077)
at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:432)
at org.apache.catalina.session.StandardManager.unload(StandardManager.java:353)
at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:518)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5622)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.manager.ManagerServlet.undeploy(ManagerServlet.java:1359)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
谢谢,对不起我的英语水平。