在一台centos虚拟机上,安装完tomcat之后,试图启动它,屏幕上没报什么错,但无法通过浏览器访问:
[root@node18 bin]# ./startup.sh
Using CATALINA_BASE: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_HOME: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_TMPDIR: /opt/apache/apache-tomcat-7.0.22/temp
Using JRE_HOME: /usr/java/jdk1.6.0_29
Using CLASSPATH: /opt/apache/apache-tomcat-7.0.22/bin/bootstrap.jar:/opt/apache/apache-tomcat-7.0.22/bin/tomcat-juli.jar
执行关闭命令,发现tomcat根本就没有起来。
[root@node18 bin]# ./shutdown.sh
Using CATALINA_BASE: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_HOME: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_TMPDIR: /opt/apache/apache-tomcat-7.0.22/temp
Using JRE_HOME: /usr/java/jdk1.6.0_29
Using CLASSPATH: /opt/apache/apache-tomcat-7.0.22/bin/bootstrap.jar:/opt/apache/apache-tomcat-7.0.22/bin/tomcat-juli.jar
Jun 29, 2012 10:05:09 AM org.apache.catalina.startup.Catalina stopServer
涓ラ噸: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:457)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:371)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:452)
[root@node18 bin]#
检查一下日志文件,即tomcat安装目录中的catalina.out文件,发现了下面的错误信息:
java.lang.NoClassDefFoundError: javax/net/ssl/KeyManagerFactory
at org.apache.tomcat.util.net.AbstractEndpoint.<init>(AbstractEndpoint.java:638)
at org.apache.tomcat.util.net.JIoEndpoint.<init>(JIoEndpoint.java:70)
at org.apache.coyote.http11.Http11Protocol.<init>(Http11Protocol.java:58)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.connector.Connector.<init>(Connector.java:75)
解决办法,重新安装jdk。
[root@node18 setup]# rpm -qa | grep jdk
jdk-1.6.0_29-fcs
[root@node18 setup]# rpm -e jdk-1.6.0_29-fcs
[root@node18 setup]#
[root@node18 setup]#
[root@node18 setup]# ./jdk-6u29-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
replace jdk-6u29-linux-i586.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
inflating: jdk-6u29-linux-i586.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Java(TM) SE Development Kit 6 successfully installed.
Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation
Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.
For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html
Press Enter to continue.....
Done.
[root@node18 setup]#
现在来尝试一下启动和关闭,发现没有报错了。检查日志,也很正常。
[root@node18 bin]# ./startup.sh
Using CATALINA_BASE: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_HOME: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_TMPDIR: /opt/apache/apache-tomcat-7.0.22/temp
Using JRE_HOME: /usr/java/jdk1.6.0_29
Using CLASSPATH: /opt/apache/apache-tomcat-7.0.22/bin/bootstrap.jar:/opt/apache/apache-tomcat-7.0.22/bin/tomcat-juli.jar
[root@node18 bin]#
能从浏览器访问了,关闭时也很正常。
[root@node18 bin]# ./shutdown.sh
Using CATALINA_BASE: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_HOME: /opt/apache/apache-tomcat-7.0.22
Using CATALINA_TMPDIR: /opt/apache/apache-tomcat-7.0.22/temp
Using JRE_HOME: /usr/java/jdk1.6.0_29
Using CLASSPATH: /opt/apache/apache-tomcat-7.0.22/bin/bootstrap.jar:/opt/apache/apache-tomcat-7.0.22/bin/tomcat-juli.jar
[root@node18 bin]#
这种情况,以前从来没有碰到过。因为jdk是别人以前安装的,不知道中间发生了什么情况。