It seems simple but ...
I'm just starting to learn liberty profile.
I can't use shared library.
here's documentation: https://www.ibm.com/support/knowledgecenter/SSD28V_liberty/com.ibm.websphere.wlp.core.doc/ae/cwlp_sharedlibrary.html
so in server.xml I put (and restart server), for example:
<library>
<folder dir="C:/libs/gson/"></folder>
<!-- or even <file name="C:/libs/gson/gson-2.3.1.jar" /> -->
</library>
Anyway at runtime I receive: "java.lang.NoClassDefFoundError: com/google/gson/Gson"
On a servlet I just have the import and a simple use:
...
import com.google.gson.Gson;
...
@WebServlet("/")
public class HelloWorld extends HttpServlet {
...
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Serialization
Gson gson = new Gson();
...
What I'm missing?
The part you are missing is that the application needs to be configured to reference the library. There are a few ways to do this:
Then, simply change your library ID to global
like this:
<library id="global">
<classloader commonLibraryRef="..."/>
as described in @njr's answer