码头类路径问题 [英] Jetty Classpath issues

查看:123
本文介绍了码头类路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在从其附带的Jetty容器中运行Solr.通过以下命令从命令行运行时,它可以正确运行:

I'm currently running Solr out of a Jetty container that it ships with. It runs correctly when run from the command line via:

java -jar start.jar

当我与start.jar在同一目录中时.不幸的是,我需要能够从任何目录启动jetty,而不仅仅是包含start.jar的目录.我尝试了很多选择,例如:

when I'm in the same directory as start.jar. Unfortunately I need to be able to launch jetty from any directory, not just the one that contains start.jar. I've tried many options, such as:

java  -Dsolr.solr.home=~/solr/ -Djetty.home=~/solr/ -Djetty.logs=~/solr/logs/ -cp ~/solr/start.jar:~/solr/lib/jetty-util-6.1.26-patched-JETTY-1340.jar:~/solr/lib/jetty-6.1.26-patched-JETTY-1340.jar:~/solr/lib/servlet-api-2.5-20081211.jar -jar ~/solr/start.jar ~/solr/etc/jetty.xml 

每次我得到此回溯:

java.lang.ClassNotFoundException: org.mortbay.xml.XmlConfiguration
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.mortbay.start.Main.invokeMain(Main.java:179)
at org.mortbay.start.Main.start(Main.java:534)
at org.mortbay.start.Main.start(Main.java:441)
at org.mortbay.start.Main.main(Main.java:119)

推荐答案

请注意,在运行时

java  ... -cp ~/solr/start.jar:... -jar ~/solr/start.jar ~/solr/etc/jetty.xml 

-cp选项将被忽略,因为您使用了-jar选项.

the -cp option is ignored since you use the -jar option.

来自man java:

-jar

使用此选项时,JAR文件是所有用户的源 类和其他用户类路径设置将被忽略.

When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

您有两个选择:

  • 继续使用-jar选项,但是您需要在jar清单文件中提供类路径(请注意,这些类路径条目不能相对于当前路径相对,只能相对于当前路径您正在执行的jar文件)
  • 跳过-jar选项并显式提供主类.
  • Keep using the -jar option, but then you need to provide the classpath in the jar manifest file (note that these classpath entries can't be relative to the current path, only relative to the jar-file you're executing)
  • Skip the -jar option and provide the main class explicitly.

这篇关于码头类路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆