ysdk配置錯誤怎麼回事
『壹』 Caused by: java.lang.NoClassDefFoundError: Failed resolution of:Lcom/tencent/ysdk/framework/hotfix
NoClassDefFoundError 問題原因1:缺少jar包
首先最常見的原因是classpath的配置問題。例子程序:
本例子程序嘗試創建一個新的CallerClassA實例,然後執行他的一個方法,此方法引用了類ReferencingClassA,本例子演示了classpath問題導致的NoClassDefFoundError ,本例子還列印了當前的classloader chain的情況,以便進一步的分析。這個列印信息對你以後分析此類問題也很有幫助的:
程序
Java代碼 收藏代碼
public class NoClassDefFoundErrorSimulator {
public static void main(String[] args) {
System.out
.println("java.lang.NoClassDefFoundError Simulator");
// Print current Classloader context
System.out.println("\nCurrent ClassLoader chain: "
+ ClassloaderUtil.getCurrentClassloaderDetail());
// 1. Create a new instance of CallerClassA
CallerClassA caller = new CallerClassA();
// 2. Execute method of the caller
caller.doSomething();
System.out.println("done!");
}
}
Java代碼 收藏代碼
public class CallerClassA {
private final static String CLAZZ = CallerClassA.class.getName();
static {
System.out.println("Classloading of " + CLAZZ + " in progress..."
+ ClassloaderUtil.getCurrentClassloaderDetail());
}
public CallerClassA() {
System.out.println("Creating a new instance of "
+ CallerClassA.class.getName() + "...");
}
public void doSomething() {
// Create a new instance of ReferencingClassA
ReferencingClassA referencingClass = new ReferencingClassA();
}
}
Java代碼 收藏代碼
public class ReferencingClassA {
private final static String CLAZZ = ReferencingClassA.class.getName();
static {
System.out.println("Classloading of " + CLAZZ + " in progress..."
+ ClassloaderUtil.getCurrentClassloaderDetail());
}
public ReferencingClassA() {
System.out.println("Creating a new instance of "
+ ReferencingClassA.class.getName() + "...");
Maps.newHashMap();
}
public void doSomething() {
// nothing to do...
}
}
列印classloader工具類:
Java代碼 收藏代碼
public class ClassloaderUtil {
public static String getCurrentClassloaderDetail() {
StringBuffer classLoaderDetail = new StringBuffer();
Stack<ClassLoader> classLoaderStack = new Stack<ClassLoader>();
ClassLoader currentClassLoader = Thread.currentThread()
.getContextClassLoader();
classLoaderDetail
.append("\n-----------------------------------------------------------------\n");
// Build a Stack of the current ClassLoader chain
while (currentClassLoader != null) {
classLoaderStack.push(currentClassLoader);
currentClassLoader = currentClassLoader.getParent();
}
// Print ClassLoader parent chain
while (classLoaderStack.size() > 0) {
ClassLoader classLoader = classLoaderStack.pop();
// Print current
classLoaderDetail.append(classLoader);
if (classLoaderStack.size() > 0) {
classLoaderDetail.append("\n--- delegation ---\n");
} else {
classLoaderDetail.append(" **Current ClassLoader**");
}
}
classLoaderDetail
.append("\n-----------------------------------------------------------------\n");
return classLoaderDetail.toString();
}
}
正常運行:
Java代碼 收藏代碼
java -classpath .;../guava-12.0.jar NoClassDefFoundError.NoClassDefFoundErrorSimulator
java.lang.NoClassDefFoundError Simulator
Current ClassLoader chain:
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@addbf1
--- delegation ---
sun.misc.Launcher$AppClassLoader@19821f **Current ClassLoader**
-----------------------------------------------------------------
Classloading of NoClassDefFoundError.CallerClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@addbf1
--- delegation ---
sun.misc.Launcher$AppClassLoader@19821f **Current ClassLoader**
-----------------------------------------------------------------
Creating a new instance of NoClassDefFoundError.CallerClassA...
Classloading of NoClassDefFoundError.ReferencingClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@addbf1
--- delegation ---
sun.misc.Launcher$AppClassLoader@19821f **Current ClassLoader**
-----------------------------------------------------------------
Creating a new instance of NoClassDefFoundError.ReferencingClassA...
done!
異常重現:
Java代碼 收藏代碼
java -classpath . NoClassDefFoundError.NoCl
java.lang.NoClassDefFoundError Simulator
Current ClassLoader chain:
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@addbf1
--- delegation ---
sun.misc.Launcher$AppClassLoader@19821f **Current ClassLoader**
-----------------------------------------------------------------
Classloading of NoClassDefFoundError.CallerClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@addbf1
--- delegation ---
sun.misc.Launcher$AppClassLoader@19821f **Current ClassLoader**
-----------------------------------------------------------------
Creating a new instance of NoClassDefFoundError.CallerClassA...
Classloading of NoClassDefFoundError.ReferencingClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@addbf1
--- delegation ---
sun.misc.Launcher$AppClassLoader@19821f **Current ClassLoader**
-----------------------------------------------------------------
Creating a new instance of NoClassDefFoundError.ReferencingClassA...
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at NoClassDefFoundError.ReferencingClassA.<init>(ReferencingClassA.java:28)
at NoClassDefFoundError.CallerClassA.doSomething(CallerClassA.java:31)
at NoClassDefFoundError.NoClassDefFoundErrorSimulator.main(NoClassDefFoundErrorSimulator.jav
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 3 more
發生了什麼?當你在classpath中不包含guava的引用的時候,由於ReferencingClassA在運行期引用了此類,導致了classloader報告找不到此類,從而出現NoClassDefFoundError。
classloader分析
注意:
Java代碼 收藏代碼
Classloading of NoClassDefFoundError.CallerClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@addbf1
--- delegation ---
sun.misc.Launcher$AppClassLoader@19821f **Current ClassLoader**
-------------------------
sun.misc.Launcher$AppClassLoader是系統的classloader,負責根據classpath設置在啟動的時候載入應用需要的class。
sun.misc.Launcher$ExtClassLoader是擴展classloader,負責從java_home/lib/etc以及其他使用java.ext.dirs配置的目錄從載入擴展java class。
從列印結果可以看出,sun.misc.Launcher$ExtClassLoader是系統classloader的實際父類。
建議處理策略
分析異常堆棧,找到缺少的java類名稱,在classpath中驗證,確保編譯和運行期都能找到此類。
『貳』 不管我怎麼設置電腦都提示DNS配置錯誤呢
你是通過路由器連接上網呢,還是直接連接貓上網呢,如果連接路由器,你只設置電腦的DNS意義不大,需要修改路由器的設置才行。
『叄』 騰訊游戲助手登錄手游出現ysdk配置發生錯誤怎麼辦
發生錯誤怎麼辦
『肆』 Dns 配置 錯誤什麼原因
就是DNS被劫持了。
可以先修復下看看,如果不行就得找個能上網的電腦,下載LSP修復工具。
修復後,重置下網路就可以了。
使用命令重置網路。
1. 在「開始」菜單找到「運行「
2. 然後在裡面輸入cmd
3. 出現的命令提示框內輸入「netsh winsock reset"按」Enter「鍵。
重啟計算機後生效。
『伍』 dns配置錯誤是怎麼導致的
一、突然斷網,重新連接的時候導致獲取DNS配置錯誤
二、不正常的系統操作導致
三、路由器問題,類似一(我之前沒用路由器時就沒出過錯)
四、其他
總之,不可能中毒就是了。病毒獲取資料必須要網路,單純的破壞系統沒必要給你斷個網