Thursday, March 6, 2014

ClassNotFoundException


After the brother in eclipse svn plugin installed, then run the code associated with the Socket, unprovoked reported ClassNotFoundException exception, checked the path of the class, there is no problem, please help to answer the great God, brother Online<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Eclipse compile the project did wrong?
Jar package java system is generally not referenced. Eclipse is automatically referenced by default, unless the project has an error.
Reply:
I did not use the jar, the class is to write exception information is as follows

10-21 04:10:09.292: W / System.err (5324): java.lang.ClassNotFoundException: Command
10-21 04:10:09.303: W / System.err (5324): at java.lang.Class.classForName (Native Method)
10-21 04:10:09.303: W / System.err (5324): at java.lang.Class.forName (Class.java: 217)
10-21 04:10:09.303: W / System.err (5324): at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java: 2304)
10-21 04:10:09.313: W / System.err (5324): at java.io.ObjectInputStream.readNewClassDesc (ObjectInputStream.java: 1663)
10-21 04:10:09.313: W / System.err (5324): at java.io.ObjectInputStream.readClassDesc (ObjectInputStream.java: 683)
10-21 04:10:09.313: W / System.err (5324): at java.io.ObjectInputStream.readNewObject (ObjectInputStream.java: 1806)
10-21 04:10:09.313: W / System.err (5324): at java.io.ObjectInputStream.readNonPrimitiveContent (ObjectInputStream.java: 787)
10-21 04:10:09.313: W / System.err (5324): at java.io.ObjectInputStream.readObject (ObjectInputStream.java: 2006)
10-21 04:10:09.323: W / System.err (5324): at java.io.ObjectInputStream.readObject (ObjectInputStream.java: 1963)
10-21 04:10:09.323: W / System.err (5324): at com.example.testsocket.SocketUtil $ 1.run (SocketUtil.java: 69)
10-21 04:10:09.323: W / System.err (5324): at java.lang.Thread.run (Thread.java: 856)
10-21 04:10:09.333: W / System.err (5324): Caused by: java.lang.NoClassDefFoundError: Command
10-21 04:10:09.343: W / System.err (5324): ... 11 more
10-21 04:10:09.343: W / System.err (5324): Caused by: java.lang.ClassNotFoundException: Didn't find class "Command" on path: / data/app/com.example.testsocket-2 . apk
10-21 04:10:09.343: W / System.err (5324): at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java: 65)
10-21 04:10:09.353: W / System.err (5324): at java.lang.ClassLoader.loadClass (ClassLoader.java: 501)
10-21 04:10:09.353: W / System.err (5324): at java.lang.ClassLoader.loadClass (ClassLoader.java: 461)
10-21 04:10:09.353: W / System.err (5324): ... 11 more
10-21 04:10:09.353: W / System.err (5324): java.io.OptionalDataException
10-21 04:10:09.363: W / System.err (5324): at java.io.ObjectInputStream.readNonPrimitiveContent (ObjectInputStream.java: 810)
10-21 04:10:09.363: W / System.err (5324): at java.io.ObjectInputStream.readObject (ObjectInputStream.java: 2006)
10-21 04:10:09.363: W / System.err (5324): at java.io.ObjectInputStream.readObject (ObjectInputStream.java: 1963)
10-21 04:10:09.363: W / System.err (5324): at com.example.testsocket.SocketUtil $ 1.run (SocketUtil.java: 69)
10-21 04:10:09.373: W / System.err (5324): at java.lang.Thread.run (Thread.java: 856)
Compile the following information

[2013-10-21 12:10:00 - TestSocket]! Android Launch
[2013-10-21 12:10:00 - TestSocket] adb is running normally
.[2013-10-21 12:10:00 - TestSocket] Performing com.example.testsocket.MainActivity activity launch
[2013-10-21 12:10:00 - TestSocket] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'bianxin'
[2013-10-21 12:10:02 - TestSocket]. Application already deployed No need to reinstall
.[2013-10-21 12:10:02 - TestSocket] Starting activity com.example.testsocket.MainActivity on device emulator-5554
[2013-10-21 12:10:03 - TestSocket] ActivityManager: Starting: Intent {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] cmp = com.example.testsocket / .MainActivity }

Reply:
This look has no solution http://bbs.csdn.net/topics/390257670
Common causes

A need to support libraries in the wrong place, and not on the classpath (CLASSPATH environment variable) inside.
2 Using a duplicate library and inconsistent versions. Resulting in a low version is priority.
Class 3 is wrong, it is generally used Class.forName manually specify the class name of the case.
4 No import pure JAVA driver package.
3 Solutions

1 Make sure your library in the system CLASSPATH below, if it is Tomcat, you can put tomcat / lib / directory.
2 Remove duplicate libraries, leaving only the latest.
3 is not possible to use this compiler can not check for you the way.
Reply:
java.lang.ClassNotFoundException: Command
Command did not find this class.
Reply:
references, 4th Floor birdsaction reply:
java.lang.ClassNotFoundException: Command
Command did not find this class.

Command class in a package with the main program, I do not know why it can not find this kind of
Reply:
In the Android project together should be able to find it, unless it is the introduction of a third party jar files.

You are the type of sequence it? I see your error seems to be in the class of network transmission conversion.
Reply:
reference to the third floor xiongyanbing123123 reply:
facie it has no solution http://bbs.csdn.net/topics/390257670
Common causes

A need to support libraries in the wrong place, and not on the classpath (CLASSPATH environment variable) inside.
2 Using a duplicate library and inconsistent versions. Resulting in a low version is priority.
Class 3 is wrong, it is generally used Class.forName manually specify the class name of the case.
4 No import pure JAVA driver package.
3 Solutions

1 Make sure your library in the system CLASSPATH below, if it is Tomcat, you can put tomcat / lib / directory.
2 Remove duplicate libraries, leaving only the latest.
3 is not possible to use this compiler can not check for you the way.


Manually specify the class name mean?
Also I did not reference an external jar package
Reply:
reference to the 6th floor birdsaction reply:
in Android project together that should be able to find, unless it is the introduction of a third party jar files.

You are the type of sequence it? I see your error seems to be in the class of network transmission conversion.

Where to look for trouble, said the specific number
Command is indeed a serialization class, but java.io.OptionalDataException should be because the class did not find Command caused
Reply:
Oh, you want the server Command class and Android Command classes consistent need the same package name, and the same sequence of ID.

Generally the server-side classes labeled jar package, put Android libs below as a reference, do not have this problem.
Reply:
reference to the 9th floor birdsaction reply:
Oh, you want the server Command class and Android Command classes consistent need the same package name, and the same serialization ID.

Generally the server-side classes labeled jar package, put Android libs below as a reference, do not have this problem.


Congratulations, points are yours, make friends

No comments:

Post a Comment