2013-08-16 102 views
2

我想序列化和反序列化一個對象,其中有一個Liferay用戶對象(它基本上是一個UserImpl)。序列化/反序列化發生在其他項目中使用的API庫中。反序列化拋出ClassNotFoundException在對象中的對象

這是我的目標:

public class ObjectDTO implements Serializable { 

    private static final long serialVersionUID = 1927888580878066482L; 

    private User user; 
    private String string1; 
    private String string2; 

    public ObjectDTO() { 
    } 

     //getters, setters 

} 

在序列化/反序列化時的方法:

  ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
     ObjectOutputStream oos = new ObjectOutputStream(bos); 
     oos.writeObject(obj); 

     byte[] bytes = bos.toByteArray(); 

     oos.close(); 
     bos.close(); 

     ByteArrayInputStream bis = new ByteArrayInputStream(bytes); 
     ObjectInputStream ois = new ObjectInputStream(bis); 

     Object o = ois.readObject(); 

     ois.close(); 
     bis.close(); 

     return o; 

序列化的作品,並在幾行我做了反序列化,這不工作。它爲UserImpl拋出ClassNotFoundException:

java.lang.ClassNotFoundException: com.liferay.portal.model.impl.UserImpl 
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) 
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:247) 
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604) 
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575) 
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496) 
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) 
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) 
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) 
at com.sample.services.service.ClpSerializer.translateOutputGeneric(ClpSerializer.java:431) 
at com.sample.services.service.ClpSerializer.translateOutput(ClpSerializer.java:490) 
at com.sample.services.service.EntityServiceClp.getEntityByUserId(EntityServiceClp.java:62) 
at com.sample.services.service.EntityServiceUtil.getEntityByUserId(EntityServiceUtil.java:45) 
at com.sample.portlet.Portlet.showPortlet(Portlet.java:57) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:358) 
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:345) 
at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleRender(AnnotationMethodHandlerAdapter.java:288) 
at org.springframework.web.portlet.DispatcherPortlet.doRenderService(DispatcherPortlet.java:734) 
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:522) 
at org.springframework.web.portlet.FrameworkPortlet.doDispatch(FrameworkPortlet.java:470) 
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233) 
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:101) 
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64) 
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:92) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) 
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) 
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:639) 
at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:724) 
at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:426) 
at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1387) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) 
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) 
at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:3859) 
at com.liferay.portal.util.PortalUtil.renderPortlet(PortalUtil.java:1222) 
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:160) 
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:94) 
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processTemplate(RuntimePortletUtil.java:256) 
at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processTemplate(RuntimePortletUtil.java:181) 
at org.apache.jsp.html.portal.layout.view.portlet_jsp._jspService(portlet_jsp.java:761) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) 
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) 
at com.liferay.portal.action.LayoutAction.includeLayoutContent(LayoutAction.java:364) 
at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:623) 
at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:232) 
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) 
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) 
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:154) 
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) 
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:520) 
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:497) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:309) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.themepreview.ThemePreviewFilter.processFilter(ThemePreviewFilter.java:88) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:121) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:182) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:239) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) 
at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:134) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:261) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.themepreview.ThemePreviewFilter.processFilter(ThemePreviewFilter.java:88) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:110) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:182) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:222) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:239) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) 
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) 
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) 
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:280) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.absoluteredirects.AbsoluteRedirectsFilter.processFilter(AbsoluteRedirectsFilter.java:85) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.servlet.filters.threadlocal.ThreadLocalFilter.processFilter(ThreadLocalFilter.java:52) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196) 
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) 
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) 
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) 
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
at java.lang.Thread.run(Thread.java:619) 

有關這個的任何想法或線索?

+0

請參閱我在本文中的答案,這可能有助於[反序列化二進制類文件的內容時的ClassNotFoundException](http://stackoverflow.com/a/42864331/5016427) –

回答

1

接口User包含在portal-service.jar中,該接口在全局類路徑上。實現類UserImpl位於Liferay的web應用程序的本地類路徑(例如,在WEB-INF/lib中)中的portal-impl.jar,您無法獲取它。我會說你不應該依賴序列化這個對象 - 畢竟,你永遠不會知道你是否可以反序列化它。

確切地說,在您自己的序列化對象中有純粹的userid,並且在需要反序列化時從數據庫中再次獲取它。

Liferay的服務構建器使對象可用於所有Web應用程序,儘管服務和對象的實現完全在一個應用程序中生活。

如果您試圖將portal-impl.jar添加到您自己的應用程序的類路徑中:它將不起作用!您會遇到各種其他問題,與您嘗試解決的問題無關。您需要爲潛在問題找到不同的解決方案。

1

看起來User是一個接口,並且您正在使用UserImpl作爲此接口的實現類,如果需要序列化,UserImpl也應該實現接口Serializable。

另外,如果你不希望序列化一個成員,你可以聲明它是暫時的。

乾杯!