Tomcat 类路径
我有一个非常烦人的问题:
我的项目(JSP、Servlet)需要Xerces-J 2.8.1 或更高版本。但在我们的服务器 (Tomcat 5.5) 上,xerces 2.6.2 总是首先出现,这会导致严重错误。
我检查了 $CLASSPATH 并做了一些清理。然而,xerces 2.6.2 仍然存在。谁能告诉我如何知道这个 xerces 2.6.2 在哪里?
I have a very annoying problem:
My project (JSP, Servlet) requires Xerces-J 2.8.1 or higher. But on our server (Tomcat 5.5) xerces 2.6.2 always comes up first and that results in a severe error.
I checked $CLASSPATH and did some clean-ups. However, xerces 2.6.2 is still there. Could anyone tell me how to know where this xerces 2.6.2 is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,环境变量
$CLASSPATH
(及其 Windows 等效变量%CLASSPATH%
)被忽略。其他 > 与 Java 运行时命令(Windows 中的java.exe
)相比,该命令在没有任何-cp
、-classpath 的情况下执行
和-jar
参数。不要将此术语与真实类路径相混淆。该环境变量的目的只是为那些不想每次都键入整个-cp
或-classpath
参数的初学者提供(较差的)便利。至于您的实际问题,Tomcat 内部还使用 Xerces 来解析 XML 文件,如 本文档。如果您对服务器有完全控制权,那么您能做的最好的事情就是将较新的 Xerces JAR 文件放置在
/common/endorsed
文件夹中,如文档中所述。First of all, the environment variable
$CLASSPATH
(and its Windows equivalent%CLASSPATH%
) is ignored by anything else than the Java runtime command (java.exe
in Windows) which is been executed without any of the-cp
,-classpath
and-jar
arguments. Don't confuse this term as being the real classpath. That environment variable is just intented as (poor) convenience for starters who doesn't want to type the whole-cp
or-classpath
argument everytime.As to your actual problem, Tomcat internally also uses Xerces to parse XML files as outlined in this document. If you have full control over the server, then best what you can do is to place the newer Xerces JAR file in the
/common/endorsed
folder, as explained in the document.如果您在 Web 应用程序中包含 Xerces jar,那么这取决于如何为您的应用程序和/或服务器配置类加载。这里有相关信息:
http://tomcat.apache。 org/tomcat-5.5-doc/class-loader-howto.html
If you're including the Xerces jar in your web app then it depends on how classloading is configured for your application and/or server. There's information about that here:
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html