我正在尝试在Cygwin上设置Apache Tomcat,当我运行configtest.sh脚本时,我收到此错误。我的环境变量似乎都是正确的,但是当java抱怨没有找到类时,它会尝试查找一些奇怪的路径,比如从当前目录开始:
Using CATALINA_BASE: C:\cygwin\usr\local\apache-tomcat-7.0.26
Using CATALINA_HOME: C:\cygwin\usr\local\apache-tomcat-7.0.26
Using CATALINA_TMPDIR: C:\cygwin\usr\local\apache-tomcat-7.0.26\temp
Using JRE_HOME: C:\Program Files (x86)\Java\jre7
Using CLASSPATH: C:\cygwin\usr\local\apache-tomcat-7.0.26\bin\bootstrap.jar;C:\cygwin\usr\local\apache-tomcat-7.0.26\bin\tomcat-juli.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/catalina/startup/Bootstrap
<<No stacktrace available>>
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.startup.Bootstrap not found in java.lang.ClassLoader$1{urls=[
file:/usr/local/apache-tomcat-7.0.26/bin/C,
file:/usr/local/apache-tomcat-7.0.26/bin/\cygwin\usr\local\apache-tomcat-7.0.26\bin\bootstrap.jar;C,
file:/usr/local/apache-tomcat-7.0.26/bin/\cygwin\usr\local\apache-tomcat-7.0.26\bin\tomcat-juli.jar], parent=null}
at java.net.URLClassLoader.findClass(URLClassLoader.java:531)
at java.lang.ClassLoader.loadClass(ClassLoader.java:341)
at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112)
at java.lang.ClassLoader.loadClass(ClassLoader.java:293)
Configuration error detected!
谁能告诉我我做错了什么?
答案 0 :(得分:0)
堆栈跟踪中显示的文件URL看起来不正确。类路径看起来像是由unix路径分隔符拆分而不是窗口分隔符,斜杠是窗口斜杠,而不是unix路径。
file:/usr/local/apache-tomcat-7.0.26/bin/C,
file:/usr/local/apache-tomcat-7.0.26/bin/\cygwin\usr\local\apache-tomcat-7.0.26\bin\bootstrap.jar;C,
file:/usr/local/apache-tomcat-7.0.26/bin/\cygwin\usr\local\apache-tomcat-7.0.26\bin\tomcat-juli.jar
如果我是你,我会尝试在cygwin中设置任何与路径相关的环境变量,而不是依赖于windows,因为你正在运行一个bash脚本。您可以使用cygpath程序使cygwin值依赖于windows变量:
export CLASSPATH=`cygpath $CLASSPATH`