java.lang.NoClassDefFoundError: javax/net/ssl/SSLSocket
at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:49) [na:na]
at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:306) [na:na]
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:466) [na:na]
at com.csii.router.weixin.service.impl.WeixinServiceImpl.resultForGet(WeixinServiceImpl.java:199) [na:na]
at com.csii.router.weixin.service.impl.WeixinServiceImpl.getToken(WeixinServiceImpl.java:77) [na:na]
at com.csii.router.weixin.service.impl.WeixinServiceImpl.getNickName(WeixinServiceImpl.java:42) [na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_32]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_32]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_32]
at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_32]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58) [null:1.2.1]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56) [null:1.2.1]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [null:2.5.6.SEC01]
at $Proxy64.getNickName(Unknown Source) [na:na]
at com.csii.weixin.basicservice.service.WeixinUserManager.initNickName(WeixinUserManager.java:328) [na:na]
at com.csii.weixin.basicservice.service.WeixinUserManager.initUser(WeixinUserManager.java:149) [na:na]
at com.csii.weixin.basicservice.service.WeixinUserManager.initUser(WeixinUserManager.java:100) [na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_32]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_32]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_32]
at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_32]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58) [null:1.2.1]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56) [null:1.2.1]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:582) [null:2.5.6.SEC01]
at com.csii.weixin.basicservice.service.WeixinUserManager$$EnhancerByCGLIB$$b4caaf27.initUser(<generated>) [na:na]
at com.csii.service.online.impl.TextRequestServiceImpl.query(TextRequestServiceImpl.java:139) [na:na]
at com.csii.service.online.impl.TextRequestServiceImpl.query(TextRequestServiceImpl.java:1) [na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_32]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_32]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_32]
at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_32]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58) [null:1.2.1]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56) [null:1.2.1]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [null:2.5.6.SEC01]
at $Proxy80.query(Unknown Source) [na:na]
at com.csii.online.workflow.QueryTemplate.execute(QueryTemplate.java:82) [na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_32]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_32]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_32]
at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_32]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58) [null:1.2.1]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56) [null:1.2.1]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59) [null:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) [null:2.5.6.SEC01]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) [null:2.5.6.SEC01]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [null:2.5.6.SEC01]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [null:2.5.6.SEC01]
at $Proxy39.execute(Unknown Source) [na:na]
at com.csii.pe.chain.command.DelegateCommand.execute(DelegateCommand.java:39) [null:na]
at com.csii.pe.chain.ChainImpl.execute(ChainImpl.java:114) [null:na]
at com.csii.pe.core.ServiceBasedCoreController.execute(ServiceBasedCoreController.java:229) [null:na]
at com.csii.mca.core.FCServiceBasedCoreController.execute(FCServiceBasedCoreController.java:22) [null:na]
at com.csii.pe.channel.stream.AbstractBaseHandler.handleInternal(AbstractBaseHandler.java:211) [null:na]
at com.csii.pe.channel.stream.AbstractBaseHandler.handle(AbstractBaseHandler.java:107) [null:na]
at com.csii.pe.service.comm.tcp.TcpServer.internalHandle(TcpServer.java:281) [null:na]
at com.csii.pe.service.comm.tcp.TcpServer.access$7(TcpServer.java:263) [null:na]
at com.csii.pe.service.comm.tcp.TcpServer$3.run(TcpServer.java:256) [null:na]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_32]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_32]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_32]
Caused by: java.lang.ClassNotFoundException: javax.net.ssl.SSLSocket
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772) [na:na]
at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73) [na:na]
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1685) [na:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [na:1.6.0_32]
... 108 common frames omitted
2016-10-31 16:56:27.166 [CSXML-APP-ThreadPool-1] INFO c.c.p.channel.stream.AbstractHandler - send:<?xml version="1.0" encoding="UTF-8"?>
<Message>
<Head>
<_ResponseSystemId>ONLINE</_ResponseSystemId>
<_RejCode>UNRSLT</_RejCode>
<_RejMsg>????????????????????????????????????????????????</_RejMsg>
<_TransactionId>online.TextRequest</_TransactionId>
</Head>
<Body>
</Body>
</Message>
NoClassDefFoundError错误发生的原因
NoClassDefFoundError错误的发生,是因为Java虚拟机在编译时能找到合适的类,而在运行时不能找到合适的类导致的错误。例如在运行时我们想调用某个类的方法或者访问这个类的静态成员的时候,发现这个类不可用,此时Java虚拟机就会抛出NoClassDefFoundError错误。与ClassNotFoundException的不同在于,这个错误发生只在运行时需要加载对应的类不成功,而不是编译时发生。很多Java开发者很容易在这里把这两个错误搞混。
简单总结就是,NoClassDefFoundError发生在编译时对应的类可用,而运行时在Java的classpath路径中,对应的类不可用导致的错误。发生NoClassDefFoundError错误时,你能看到如下的错误日志:Exception in thread "main" java.lang.NoClassDefFoundError
错误的信息很明显地指明main线程无法找到指定的类,而这个main线程可能时主线程或者其他子线程。如果是主线程发生错误,程序将崩溃或停止,而如果是子线程,则子线程停止,其他线程继续运行。
NoClassDefFoundError和ClassNotFoundException区别
我们经常被java.lang.ClassNotFoundException和java.lang.NoClassDefFoundError这两个错误迷惑不清,尽管他们都与Java classpath有关,但是他们完全不同。NoClassDefFoundError发生在JVM在动态运行时,根据你提供的类名,在classpath中找到对应的类进行加载,但当它找不到这个类时,就发生了java.lang.NoClassDefFoundError的错误,而ClassNotFoundException是在编译的时候在classpath中找不到对应的类而发生的错误。ClassNotFoundException比NoClassDefFoundError容易解决,是因为在编译时我们就知道错误发生,并且完全是由于环境的问题导致。而如果你在J2EE的环境下工作,并且得到NoClassDefFoundError的异常,而且对应的错误的类是确实存在的,这说明这个类对于类加载器来说,可能是不可见的。
详情可查阅:http://blog.youkuaiyun.com/jamesjxin/article/details/46606307
所以可以先确认该类所在的包javax.net.ssl是否在jar中有引用。
确认有引用之后,可以查看运行的jdk中是否有这个类。在jdk中的路径:jsse.jar!\javax\net\ssl\SSLSocket.class
如果以上都有引用则证明可能跟环境变量或者类加载器有关,对于classloader来说这个类不可见!
首先查看环境变量,linux系统下env命令查看java_home检查环境变量是否有问题?
确认运行的jdk可以 kill 3 pid 进行查看。日志:
现在可以想想我们的OSGI的类加载器的特殊性。首先先确认编译时是没有问题的,运行时报错。
我们已经知道 java 是通过 java
虚拟机来解释运行的, 也就是通过 java 命令, javac 编译生成的 .class 文件就是虚拟机要执行的代码, 称之为字节码(bytecode), 虚拟机通过 classloader 来装载这些字节码, 也就是通常意义上的类. 这里就有一个问题, classloader 从 哪里知道 java 本身的类库及用户自己的类在什么地方呢? 或者有着缺省值(当前路径) . 或者要有一个用户指定的变量来表明, 这个变量就是类路径(classpath), 或者在运行 的时候传参数给虚拟机. 这也就是指明 classpath 的三个方法. 编译的过程和运行 的过程大同小异, 只是一个是找出来编译, 另一个是找出来装载. 实际上 java 虚拟机是由 java luncher 初始化的, 也就是 java (或 java.exe) 这个程序来做的. 虚拟机按以下顺序搜索并装载所有需要的类: 1, 引导类: 组成 java 平台的类, 包含 rt.jar 和 i18n.jar 中的类. 2, 扩展类: 使用 java 扩展机制的类, 都是位于扩展目录($JAVA_HOME/jre/lib/e xt) 中的 .jar 档案包. 3, 用户类: 开发者定义的类或者没有使用 java 扩展机制的第三方产品. 你必须在 命令行中使用 -classpath 选项或者使用 CLASSPATH 环境变量来确定这些类的位置. 我 们在上面所说的用户自己的类就是特指这些类. 这样, 一般来说, 用户只需指定用户类的位置, 引导类和扩展类是 "自动 "寻找的. |
此问题得到解决!