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配置错误
二、不正常的系统操作导致
三、路由器问题,类似一(我之前没用路由器时就没出过错)
四、其他
总之,不可能中毒就是了。病毒获取资料必须要网络,单纯的破坏系统没必要给你断个网