OSX 10.9.1:“Tomcat已启动”。 localhost:8080说“没有收到数据”

时间:2014-02-12 15:10:56

标签: java macos tomcat

我花了好几个小时试图安装Tomcat并运行服务器,但仍然没有。

❯ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents

❯ bash startup.sh
Using CATALINA_BASE:   /Library/Tomcat
Using CATALINA_HOME:   /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME:        /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH:       /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
Using CATALINA_PID:    /Library/Tomcat/tomcat.pid
Existing PID file found during start.
Removing/clearing stale PID file.

Tomcat started.

/Library/Tomcat/bin
❯

localhost:8080仍然无法加载。

Chrome: "no data received"

我已经检查过了,没有其他进程正在使用该端口。 我还添加了一个虚拟用户。没什么。

<role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat,admin,manager"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>

配置测试:

❯ ./catalina.sh configtest
Using CATALINA_BASE:   /Library/Tomcat
Using CATALINA_HOME:   /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME:        /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH:       /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
Using CATALINA_PID:    /Library/Tomcat/tomcat.pid
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    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)
Configuration error detected!

❯ which java
/usr/bin/java

❯ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

然而,出于某种原因,我在系统偏好设置中显示了1.7。

Java OSX System Prefs

我甚至尝试过Tomcat控制器,但它说某些东西也没有正确配置。 如果这些错误告诉我究竟是什么问题,那将非常有用。

Tomcat Controller

随意将其移至ServerFault

1 个答案:

答案 0 :(得分:2)

您安装了两个JVM。不是启动输出中的JRE_HOME行,而是将其与其上方的JAVA_HOME路径进行比较。

您需要更新JRE_HOME环境变量和/ usr / bin中的java符号链接以指向java 7安装。