如何在WebSphere中管理ClassPath [英] How do I manage the ClassPath in WebSphere

查看:685
本文介绍了如何在WebSphere中管理ClassPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Websphere v6.1中遇到了我的Web模块类路径问题。

I have a problem with my web module classpath in Websphere v6.1.

在我的WEB-INF / lib中,我有大量的jar文件,包括xercesImpl.jar和xmlparserv2.jar。我需要两个罐子都存在,但它们似乎互相矛盾。具体来说,每个jar包含一个META-INF / services目录,因此,当我们尝试通过JAXP获取DocumentBuilderFactory的实例时,我们得到的实例取决于这两个jar在类路径中出现的顺序。

In my WEB-INF/lib I have a largish number of jar files which include xercesImpl.jar and xmlparserv2.jar. I need both jars to be present, but they appear to confict with each other. Specifically, each jar contains a META-INF/services directory so, when we try to get an instance of a DocumentBuilderFactory via JAXP, which instance we get depends upon the order in which these two jars appear in the classpath.

总是想要使用DocumentBuildFactory的xerces实例,所以我想将xercesImpl.jar推送到类路径的前面。我试图通过在war文件的Manifest文件中指定Class-Path部分来实现这一点,但是我在WAS Module Compound CLass Loader中实际获得的类路径非常奇怪。我似乎得到了WAS提出的一些标准内容,其后是按字母顺序排列的WEB-INF lib的内容,接着是Manifest文件指定的类路径。

I always want to use the xerces instance of the DocumentBuildFactory, so I want to push xercesImpl.jar to the front of the classpath. I've tried to do this by specifying a Class-Path section in the Manifest file for the war file, but the class path that I actually get in my WAS Module Compound CLass Loader in is very strange. I seem to get some standard stuff that WAS puts on, followed by the contents of WEB-INF lib in alphabetical order, followed by the classpath specified by the Manifest file.

如果我没有将清单文件放入战争中,我会得到标准的东西,然后是WEB-INF / lib的内容,但是以任意顺序。

If I don't put a manifest file into the war at all, I get the standard stuff followed by the contents of WEB-INF/lib but in an arbitrary order.

我错过了什么?有没有办法可以将类路径设置为我想要的?

What am I missing? Is there a way in which I can set the class path up to be exactly what I want?

Dave

推荐答案

我认为,WebSphere是指常规J2EE应用服务器(而不是社区版; WebSphere是应用于许多IBM产品的品牌名称)。

I assume by WebSphere, you mean the regular J2EE Application Server (and not something like Community Edition; WebSphere is a brand name applied to a number of IBM products).

我认为您的选择有限。由于依赖关系看起来非常明确,我更倾向于采用编程方法而不是依赖于类路径的变幻莫测(比如显式创建工厂实例而不是依赖SPI)。

I think your options are limited. Since the dependencies look quite explicit, I would prefer a programmatic approach rather than relying on the vagaries of the classpath (like creating factory instances explicitly rather than relying on the SPI).

如果这不是一个选项,您可能希望查看使其中一个依赖项成为EAR项目实用程序JAR,并使用WAR上的PARENT_LAST类加载策略配置MODULE类加载。这可以通过浏览器管理控制台进行配置(或者如果您使用的话,可以通过 RAD 工具进行配置) 。

If that isn't an option, you might want to look at making one of your dependencies an EAR project utility JAR and configure MODULE classloading with a PARENT_LAST classloading policy on the WAR. This can be configured via the browser admin console (or via the RAD tooling if you use it).

我要看的另一件事是WAS 共享库功能(在浏览器管理控制台中的 Environment 下)。这些可以是与服务器相关联申请。缺点是需要更多配置。

Another thing I'd look at is the WAS Shared Libraries feature (under Environment in the browser admin console). These can be associated with servers or applications. The downside is that this requires more configuration.

这篇关于如何在WebSphere中管理ClassPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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