如何在Websphere应用程序服务器中配置Classpath?
我需要在 WAS 服务器的类路径中添加 log4j jar,但我无法放置它。请建议。 我尝试将此 jar 添加到 WAS 服务器的启动脚本中。
I need to add log4j jar in classpath of WAS server but I am unable to put it. Please suggest.
I tried to add this jar in start script of WAS server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
正如 Michael Ransley 提到的,您需要确定谁需要 log4j。如果是Web应用程序,那么WEB-INF/lib是最好的位置。
如果 EJB 组件使用它,则将 log4j 作为实用程序 jar 放置在 EAR 中。
或者,创建一个共享库并将共享库关联到您的应用程序。
另一种选择是将共享库关联到您的服务器(而不是应用程序),在这种情况下,该服务器上运行的所有应用程序都可以使用它。
存储在应用程序服务器 lib/ext 或其他基类路径中通常是一个坏主意。原因是这可能会导致冲突(log4j 不会导致冲突,但其他 Jars 可能会导致冲突),并且可能会阻止应用程序服务器启动。
另请记住,根据 log4j.jar 的保存位置(或通过共享库关联),不同的类加载器将拾取此 JAR 文件。
As Michael Ransley mentioned, you need to determine who needs log4j. If it is a web application, then WEB-INF/lib is the best location.
If it used by EJB components then place the log4j as a utility jar in the EAR.
Alternatively, create a Shared Library and associate the shared library to your application.
Another choice would be to associate the shared library to your server (instead of the application) in which case, it becomes available to all the applications that are running on that server.
Storing in the App Server lib/ext or the other base classpath(s) is usually a bad idea. The reason is this could cause conflicts (log4j does not cause conflicts but other Jars could likely cause conflicts) and might prevent the application server from even starting up.
Also remember, depending on where the log4j.jar is kept (or associated via shared libraries) different class loaders would be picking up this JAR file.
从管理控制台中,选择环境 -> 共享库,
然后在显示的页面中选择新建并按照说明添加库。
From the Admin console, select Environment->Shared Libraries
Then in the page displayed, select New and follow the directions to add you library.
这取决于您想要添加它的原因。您是否需要从应用程序内访问 log4j?如果需要,您可以将其添加到应用程序中(即在 WEB-INF/lib 目录中),如果您正在编写需要在 WebSphere 运行时内运行的组件(即 JMX库),然后您可以将其放入 WebSphere/AppServer/lib/ext.lib 中。
It depends why you want to add it. Do you need access to log4j from within your applications, if so you can add it into the application (i.e. in the WEB-INF/lib directory), if you are writing a component that needs to run within the WebSphere runtime (i.e. a JMX library) then you can put it into WebSphere/AppServer/lib/ext.
如果您有多个 Web 应用程序需要共享相同的 log4j.xml,则可以将其放在 IBM\WebSphere\PortalServer\shared\app\\ 中,
否则,将其放在 Web 应用程序的 web-inf/lib 中。
If you have multiple webapps that needs to share the same log4j.xml, you could drop it in IBM\WebSphere\PortalServer\shared\app\\
Otherwise, put it in web-inf/lib of your web app.
PROFILE_ROOT/properties
PROFILE_ROOT/properties
source