ClassNotFoundException
在 java socket 通信,使用 ObjectInputStream 的 readObject 时, 出现了问题。
ServerProject 问题描述是这样的:
java.lang.ClassNotFoundException: com.tan.mychatting.domain.User
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:625)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at com.YQServer.<init>(YQServer.java:24)
at com.YQServer.main(YQServer.java:11)
为什么会出现 java.lang.ClassNotFoundException 呢, 原因是在 ServerProject 上没有找到 User,
com.tan.mychatting.domain.User
但在 ServerProject 确实存在 User。仔细检查了一下,发现在 Client 上 User 的包名 com.tan.mychatting.domain.User , 而 Server 上包名不一样, 将包名改为一致的,问题解决。
要传输的类必须在客户端和服务器端包名保持一致
ClassNotFoundException的更多相关文章
- ClassNotFoundException: org.apache.catalina.loader.DevLoader 自己摸索,丰衣足食
使用tomcat插件时遇到的问题: ClassNotFoundException: org.apache.catalina.loader.DevLoader 解决方案: 参考了许多文章,对我自己的目录 ...
- 【异常】Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException
Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException ...
- MaxTemperature程序Mapper ClassNotFoundException
错误: 执行hadoop权威指南上MaxTemperature程序出现Mapper类ClassNotFoundException异常: 解决: 将书上的 JobConf job = new JobCo ...
- 真正解决问题:maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener--转
原文地址:http://www.cnblogs.com/amosli/p/4067665.html 在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.Clas ...
- Struts2环境下Tomcat启动异常:Exception starting filter struts2,报了一个java.lang.ClassNotFoundException
在写一个struts2+hibernate整合的小例子时,启动Tomcat服务器,报了一个: 严重: Exception starting filter struts2java.lang.ClassN ...
- JAVA类的静态加载和动态加载以及NoClassDefFoundError和ClassNotFoundException
我们都知道Java初始化一个类的时候可以用new 操作符来初始化, 也可通过Class.forName()的方式来得到一个Class类型的实例,然后通过这个Class类型的实例的newInstance ...
- maven 项目启动tomcat报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
maven项目启动tomcat报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi ...
- NoClassDefFoundError vs ClassNotFoundException
我们先来认识一下Error 和Exception, 两个都是Throwable类的直接子类. Javadoc 很好的说明了Error类: An Error is a subclass of Thro ...
- maven ClassNotFoundException: org.springframework.web.context.ContextLoaderL
信息: Starting Servlet Engine: Apache Tomcat/6.0.32 2012-3-31 9:39:40 org.apache.catalina.core.Standar ...
- eclipse java项目中明明引入了jar包 为什么项目启动的时候不能找到jar包 项目中已经 引入了 com.branchitech.app 包 ,但时tomcat启动的时候还是报错? java.lang.ClassNotFoundException: com.branchitech.app.startup.AppStartupContextListener java.lang.ClassN
eclipse java项目中明明引入了jar包 为什么项目启动的时候不能找到jar包 项目中已经 引入了 com.branchitech.app 包 ,但时tomcat启动的时候还是报错?java. ...
随机推荐
- jquery easyui textbox onblur事件,textbox blur事件无效解决方案
jquery easyui textbox onblur事件,textbox blur事件无效解决方案 >>>>>>>>>>>> ...
- 网页版 treeview使用中遇到的问题
<div class="ScrollBar" id="ItemsTree"></div> var cla = $("#Item ...
- ThinkPHP调试模式与日志记录
1.可以在config.php中进行设置,默认为关闭状态. 'APP_DEBUG' => true 打开\ThinkPHP\Common\debug.php文件可以查看debug的默认设置 ...
- 关于Zen Coding:css,html缩写
zen coding 是一个俄罗斯人写的编辑器(支持大部分现下流行的编辑器)插件,其安装也是非常简单,只要安装插件,然后在项目中拷贝js文件就可以.像Webstorm6.0.2中已经包含这样的插件.什 ...
- Codeigniter-验证数据类
个人需求,仿着CI的表单验证写了一个自己的验证类 1.定义验证类 <?php if ( ! defined('BASEPATH')) exit('No direct script access ...
- JavaScript学习心得(十)
Ajax Ajax是浏览器中使用JavaScript进行服务器后台请求,读取附加信息或者导致服务器响应的过程. Ajax广泛用于从服务器读取数据,并用所得到的数据更新页面,以及向服务器发送数据 Aja ...
- 移动端消除click事件的延迟效果
https://github.com/Plaputta/jquery.event.special.fastclick 用fastclick事件,类似zepto的tap事件,若想去除连点效果,可在外层显 ...
- 帝国cms灵动标签调用tags
这个语法用来调用[指定分类][指定条件]的所有tags [e:loop={"select * from [!db.pre!]enewstags order by num desc limit ...
- Winbind authentication against active directory
Winbind authentication against active directory Description This tip will describe how to configure ...
- scrollview 例子2
代码: #import "RootViewController.h" @implementation RootViewController @synthesize scrollVi ...