简体   繁体   中英

How to add a JAR file to the project classpath in IBM WebSphere server?

I have access to a project which is deployed in WebSphere. I only create .class files and put them under WEB-INF.

Now, one of my Java class requires a JAR. I don't have access to add a JAR and re-deploy. Only I need to add the JAR which is in C drive of the same machine to the class path of the project; so that it can load the JAR while loading.

How can I do this?

In traditional websphere aka "full profile":

If you don't want to place it in WEB-INF/lib during your build, you can configure it as a "shared library" in the administration console then associate it with one or more applications.

https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tcws_sharedlib.html

Since this is a GUI, I won't bother going into the details. From the toplevel of the administration console, there is an Environment > "Shared libraries" page that's basically for this exclusive purpose.

If you are using WebSphere Liberty, there is an equivalent configuration you can make directly via server.xml:

https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/cwlp_sharedlibrary.html

<library id="someLibrary">
   <!-- All the jar files in ther servers lib folder -->
   <fileset dir="${server.config.dir}/lib" includes="*.jar" scanInterval="5s" />
</library>

<application location ="webStore.war">
   <classloader commonLibraryRef="someLibrary" />
</application>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM