Nexus启动报错: Unsupported major.minor version 51.0
1.遇到问题
今天搭建Nexus私服,出现了以前没遇到过的错误。
a).采用console-nexus.bat开启报错:
- wrapper | --> Wrapper Started as Console
- wrapper | Launching a JVM...
- jvm 1 | java.lang.UnsupportedClassVersionError: org/sonatype/nexus/bootstrap/
- jsw/JswLauncher : Unsupported major.minor version 51.0
- jvm 1 | at java.lang.ClassLoader.defineClass1(Native Method)
- jvm 1 | at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
- jvm 1 | at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
- jvm 1 | at java.security.SecureClassLoader.defineClass(SecureClassLoader
- .java:141)
- jvm 1 | at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
- jvm 1 | at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
- jvm 1 | at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
- jvm 1 | at java.security.AccessController.doPrivileged(Native Method)
- jvm 1 | at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
- jvm 1 | at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
- jvm 1 | at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
- jvm 1 | at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
- jvm 1 | Could not find the main class: org.sonatype.nexus.bootstrap.jsw.JswLa
- uncher. Program will exit.
- jvm 1 | Exception in thread "main"
- wrapper | JVM exited while loading the application.
- wrapper | Reloading Wrapper configuration...
- wrapper | Launching a JVM...
b).采用install-nexus.bat、start-nexus.bat开启报错:
- wrapper | Starting the nexus service...
- wrapper | Waiting to start...
- wrapper | Waiting to start...
- wrapper | Waiting to start...
- wrapper | The nexus service was launched, but failed to start.
2.分析问题
看日志的问题,大概就是版本存在问题,找不到Java虚拟机。
Java版本:1.6.0_45
Nexus版本: 2.7.2-03
按照网上的办法是修改bin\jsw\conf\wrapper.conf中的wrapper.java.command
- wrapper.java.command=C:\Lynch\Develop\Java\jdk1.6\bin\java.exe
指向自己的jdk,似乎在特俗的Nexus版本可以解决,这里我还是不行。
(事后经验补充:当console-nexus.bat方式启动正常,而将nexus设置为windows系统服务后,
如果启动失败,按照此方法修改...报错提示:Unable to start the service - 系统找不到指定的文件。)
3.解决问题
最终查询文档得到思路
- Sonatype Nexus 2.6.0
- Java 6 Support EOL
- Oracle's support for Java 6 ended in February 2013. Consequentially as of version 2.6 Nexus now requires a Java 7 JRE to run.
- Sonatype Nexus OSS 2.5.0
- Java 6 Support is Deprecated
- Java 6 reached Official EOL on February 2013. Since it is no longer receiving updates we are deprecating support for running Nexus with Java 6 in the 2.5 release, and will be removing it in the upcoming 2.6 release.
- Sonatype Nexus 2.0 Release Notes
- JDK 7 Support
- Nexus 2.0 is the first version of Nexus verified to work with Java 7. The recommended versions are
- Oracle 7u2 or later *
- IBM Java 7.0 GA or later
- * Note: Nexus 2.0 will not run on versions of Oracle Java 7 prior to 7u2.
- When running with Java 6 the recommended versions are:
- Oracle Java 6u30 or later
- IBM Java 6.0.10.0 or Later
a).Nexus的2.6版本及其以后版本
使用的Java的jdk7.
b).Nexus的2.0-2.5版本
使用Java的jdk6的update30版本及其以后的jdk6版本
使用Java的jdk7的update2版本及其以后jdk7版本
c).最终解决方案
升级jdk7(注意jdk的update版本,升级最新版本就可以)
4.参考文档
https://support.sonatype.com/entries/23150053-Sonatype-Nexus-Release-Notes?__utma=246996102.1501838135.1395215985.1395815367.1395822104.4&__utmb=246996102.21.9.1395822181403&__utmc=246996102&__utmx=-&__utmz=246996102.1395822104.4.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)&__utmv=-&__utmk=14901813