设为首页 加入收藏

TOP

维护一个新浪微博同步的代码(三)
2014-02-08 13:36:39 来源: 作者: 【 】 浏览:315
Tags:维护 一个 新浪 同步 代码

 

  先找到这条:Unsupported major.minor version 51.0,有相关解释:

  the version number shown describes the version of the JRE the class file is compatible with.The reported major numbers are:

  J2SE 8 = 52,

  J2SE 7 = 51,

  J2SE 6.0 = 50,

  J2SE 5.0 = 49,

  JDK 1.4 = 48,

  JDK 1.3 = 47,

  JDK 1.2 = 46,

  JDK 1.1 = 45

  (source: http://en.wikipedia.org/wiki/Java_class_file )

  To fix the actual problem you should try to either run the Java code with newer version Java JRE or

  specify target parameter to the Java compiler to instruct the compiler to create code compatible with

  earlier Java versions.

  For example in order to to generate class files compatible with Java 1.4, use the following command line:

  javac -source 1.4 HelloWorld.java

  With newer versions of Java compiler you are likely to get a warning about bootstrap class path not

  being set. More information about this error is available at:

  https://blogs.oracle.com/darcy/entry/bootclasspath_older_source

  了解了51.0 这个数字的意义后,继续google,看到这条:解决Unsupported major.minor version 51.0问题的感悟,涉及到build path 和compiler compliance level的问题:

  build path的JDK版本是你开发的时候编译器需要使用到的,就是你在eclipse中开发代码,给你提示报错的,编译的过程;java compiler compliance level中配置的编译版本号,这个编译版本号的作用是,你这个项目将来开发完毕之后,要放到服务器上运行,那个服务器上JDK的运行版本。如果build path中配置1.7的JDK,java compiler compliance level中配置的1.7,但是服务器上是1.6的JDK,就报了那个错误,说是编译所用的jdk(1.7)比运行所用的jdk(1.6)高了,这是错误的。
因此,只要build path的JDK版本低于或等于java compiler compliance level里面的级别都可以。

  由于项目中pom.xml配置的targetJdk为1.6,如果选择1.7的,就会出现上面的问题。然后选择1.6,又会使用默认的1.6.0_13这个有问题的jdk,就会报出PKIX path validation failed问题了。

  好了,既然找到了根源,重新把java compiler compliance level设置为1.6,然后下个更新版的1.6 JDK解决。

PKIX  path validation failed - qinguan0619 - 我是天空的一片云

  昨天偶然又维护一个新浪微博同步的代码,突然发现自己的测试类同步不出去了~,报错如下:

  1ERROR: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: basic constraints check failed: pathLenConstraint violated - this cert must be the last cert in the certification path

  看见security下面的异常就心里一紧,这貌似是oauth2.0协议的https请求导致的,而且请求没有发送出去就报错了。然后google,百度,微博各种搜索

  微博的开放平台提问上看到有大神回复:强制httpclient信任任何证书就可以了。

  但是纯文字的微博我用的jdk里的urlconnection,不知道怎么强制信任证书,http头文件中也没找到相关设置,大神们看到可以教下小菜我试一下这个方法可不可行。

  这个代码在生产环境一直正常运行这,后来联系到以前做这个功能的同事,原来是jdk版本的问题

  我使用的是jdk 1.6.0_17,这个jdk版本存在bug,升级到jdk 1.6.0_20就不会出现相同问题了

      

首页 上一页 1 2 3 4 下一页 尾页 3/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇做一次BFS 预处理格子着火时.. 下一篇利用树状数组求交点有多少

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Libevent C++ 高并发 (2025-12-26 00:49:30)
·C++ dll 设计接口时 (2025-12-26 00:49:28)
·透彻理解 C 语言指针 (2025-12-26 00:22:52)
·C语言指针详解 (经典 (2025-12-26 00:22:49)
·C 指针 | 菜鸟教程 (2025-12-26 00:22:46)