Java Websphere 7 中的共享库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24117960/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 10:16:49  来源:igfitidea点击:

Shared library in Websphere 7

javajarwebsphereear

提问by blackberry dev

I am deploying my EAR on WAS 6 having 3 modules, in all of those 3 modules there are many jar files it makes my EAR heavy, to avoid that i want to use Shared Library wizard of Websphere. Please provide me link or tell me what changes i have to make in my code or resource or any .xml files. I am using below link to configure my JARs in Websphere Websphere Shared Library link 1Link 2Link 3

我正在将我的 EAR 部署在具有 3 个模块的 WAS 6 上,在所有这 3 个模块中,有许多 jar 文件使我的 EAR 变得沉重,以避免我想使用 Websphere 的共享库向导。请提供我的链接或告诉我我必须在我的代码或资源或任何 .xml 文件中进行哪些更改。我正在使用以下链接在 Websphere Websphere Shared Library 中配置我的 JAR链接 1链接 2链接 3

Thanks in advance

提前致谢

回答by JSR

This is how shared libray is referenced.

这就是引用共享库的方式。

Logon to the Websphere Application Server console.

登录到 Websphere Application Server 控制台。

  • Go to Environment -> Shared Libraries
    1. Create your own Shared Library. Add the classpath pointing to your JAR files.
    2. Apply and save this configuration.
    3. Now, Go to Servers -> Application Servers -> Select the server-> Java and Process Management -> ClassLoader.
    4. Click on that class loader.
    5. Click on the Shared Library References
    6. Click on Add.
    7. Add your shared library.
    8. Save and restart Websphere Servers.
  • 转到环境 -> 共享库
    1. 创建您自己的共享库。添加指向 JAR 文件的类路径。
    2. 应用并保存此配置。
    3. 现在,转到服务器 -> 应用程序服务器 -> 选择服务器 -> Java 和进程管理 -> 类加载器。
    4. 单击该类加载器。
    5. 单击共享库参考
    6. 单击添加。
    7. 添加您的共享库。
    8. 保存并重新启动 Websphere 服务器。

回答by Clindo

A common problem that I faced with Shared Libraries was multiple jar occurrences. So, When installing web-apps under WAS, you can set the class loading policy in the options for that application (or globally on server/node level)

我在共享库中遇到的一个常见问题是多个 jar 出现。因此,在 WAS 下安装 Web 应用程序时,您可以在该应用程序的选项中设置类加载策略(或在服务器/节点级别全局设置)

If the policy options are (search) "parent first" / "parent last" and one class loader per application or per war. The default is "parent first / war". If your web-app comes with all jars it needs you'll be better off with the policy set to "parent last / application". Also if you edit your web.xml to reflect changes, be sure to set "use binary configuration" otherwise it will always use what it stored during install.

如果策略选项是(搜索)“父级第一”/“父级最后”和每个应用程序或每个War一个类加载器。默认为“父级优先/War”。如果您的网络应用程序随附了它需要的所有 jar,那么您最好将策略设置为“父级/应用程序”。此外,如果您编辑 web.xml 以反映更改,请确保设置“使用二进制配置”,否则它将始终使用安装期间存储的内容。

You get the class loading option under Wepsphere applications>>click on the application name there you could see the class loader option.

您可以在 Wepsphere 应用程序下获得类加载选项>>单击应用程序名称,您可以看到类加载器选项。

回答by blackberry dev

Thanks all for HELP.. Finally i found solution.

感谢大家的帮助..最后我找到了解决方案。

  1. First remove all .jar files from your EAR even from different modules.
  2. Save all .jar files in some location.
  3. Go to WAS admin console > Environment > Shared Library and give a suitable name and mention classpath of all the required jar files. eg C:/libs/ojdbc14.jar. Restart WAS.
  4. Then deploy your EAR on WAS but don't start it.
  5. Go to Admin console > Application lists > select your application > Shared Library Reference, there you will see all the modules of your EAR. Select Checkbox next to it and Click Reference Library.
  6. Here you will see all the Shared library you saved earlier, add them to all modules.
  7. Now start your application.
  1. 首先从您的 EAR 中删除所有 .jar 文件,即使是从不同的模块。
  2. 将所有 .jar 文件保存在某个位置。
  3. 转到 WAS 管理控制台 > 环境 > 共享库,并给出一个合适的名称并提及所有必需 jar 文件的类路径。例如 C:/libs/ojdbc14.jar。重新启动 WAS。
  4. 然后在 WAS 上部署您的 EAR,但不要启动它。
  5. 转到管理控制台 > 应用程序列表 > 选择您的应用程序 > 共享库参考,在那里您将看到 EAR 的所有模块。选择旁边的复选框,然后单击参考库。
  6. 在这里您将看到您之前保存的所有共享库,并将它们添加到所有模块中。
  7. 现在开始您的应用程序。