WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

tld inside a jar not found in ibm liberty server 20.0.0.9

  • 1.  tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Mon February 14, 2022 01:38 PM
    Edited by Diane Chalmers Tue February 15, 2022 10:11 AM
    Hi, i am deploying a ear application in the liberty server using the "run applications directly from the workspace" feature of eclipse ibm developer tools.
    I noticed tlds inside a local jar existing within the same workspace were being ignored by the server, throwing this error:

    [14/02/22 9:29:27:765 CET] 00000029 webapp E com.ibm.ws.webcontainer.webapp.WebApp reportRecursiveError Excepcion de pagina de error: myapp-war-1.0/myappExcepcion de pagina de errorcom.ibm.ws.jsp.webcontainerext.JSPErrorReport: /jsp/my.jsp(0,1) --> JSPG0005E: El campo tld no se ha podido encontrar para el uri[http://mylib/mytaglib] prefijo [my]

    I also noticed tlds from jars coming from maven dependencies are being loaded succesfully.

    Reviewing the xml used to deploy the app in place i noticed local workspace jars are being added in X:\path\to\liberty\servers\defaultServer\apps\myapp.xml this way:

    <archive targetInArchive="/WEB-INF/lib/lib-with-tlds.jar">
    <dir sourceOnDisk="X:\path\to\eclipse\wslib-with-tlds\target\classes" targetInArchive="/"/>
    </archive>

    Changing it to the format used for external depedencies (i.e. maven ones)

    <file sourceOnDisk="X:\path\to\eclipse\wslib-with-tlds\target\lib-with-tlds.jar" targetInArchive="/WEB-INF/lib/lib-with-tlds.jar"/>

    makes it work.

    However in each redeploy the xml changes and the error is reproduced again.
    I searched if this is a known bug without results, help to get a better workaround or a proper fix will be very appreciated
    Thanks in advance

    ------------------------------
    Javier Neira
    Vitoria VI
    1-666-666-6666
    ------------------------------


  • 2.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Tue February 15, 2022 05:04 AM
    Hi, if you have
    <looseApplication>true</looseApplication>​


    Then remove it and it should stop Eclipse from changing it each time.

    Brian



    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 3.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Wed February 16, 2022 03:32 AM
    Many thanks for the quick response, sorry but i am not sure in which config file i should do change. In the eclipse liberty server pane there is a `Run applications directly from the workspace`, which is marked by default. Unchecking it makes the mypp.xml gone so guess it is equivalent of your suggestion.
    However, would not it affect the behaviour of the deployed application ot the performance, i mean hot code reloading of java classes, jsp and other files whitout having to redeploy the applicaction?
    Workarounds apart i think it is a bug and the tld cache engine should scan also those entries (i made sure the META-INF with all tld definitions is in X:\path\to\eclipse\wslib-with-tlds\target\classes. Where should i open a ticket about? maybe in https://github.com/OpenLiberty/open-liberty/issues?
    Thanks in advance

    ------------------------------
    Javier Neira
    Vitoria VI
    1-666-666-6666
    ------------------------------



  • 4.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Wed February 16, 2022 05:36 AM
    For hot deploying code, make sure you have the correct version of maven plugin.  You can see this article about Liberty dev mode.  and more info here.  I referred to looseApplication in the maven pom file, if you are using it. You also might be using an older version of the dev tools.  Can you make sure that you are using the latest version, which is 21.0.0.9.  

    Brian


    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 5.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Wed February 16, 2022 05:54 AM
    Hi, i am not using the maven plugin but a external liberty server installed with the ibm developer tools
    The features versions are:

    Web Development Tools 21.0.900.v20210916_2134 com.ibm.wdt.webtools.top.feature.feature.group
    IBMWebSphere® Application Server Liberty Tools 21.0.900.v20210916_2134 com.ibm.websphere.wdt.server.tools.main.feature.group
    IBMWebSphere® Application Server V8.5 Tools 21.0.900.v20210916_2134 com.ibm.websphere.wdt.st.v85.feature.group
    IBMWebSphere® Application Server V9.0 Tools 21.0.900.v20210916_2134 com.ibm.websphere.wdt.st.v9.feature.group IBM

    This is using the server version (as taken from the server log):
    Launching defaultServer (WebSphere Application Server 22.0.0.1/wlp-1.0.60.cl220120220103-1900) on IBM J9 VM, version 8.0.7.0 - pwa6480sr7-20211025_01(SR7) (en_ES)

    And the eclipse version
    Version: 2021-09 (4.21.0)Build id: 20210910-1417

    Thanks!

    ------------------------------
    Javier Neira
    Vitoria VI
    1-666-666-6666
    ------------------------------



  • 6.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Wed February 16, 2022 06:35 AM
    Ok, I tried with your method and it is working correctly for me.  And it is pulling in the resources correctly.  Where is lib-with-tlds.jar coming from?  Is it dependency you are pulling in, something you are building? 

    Brian


    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 7.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Thu February 17, 2022 03:50 PM
    Thanks for trying to reproduce. The jar is a local workspace project and it is included in the war (which in turn is deployed inside an ear) as a maven dependency. The project maven configuration is marked a resolvable in the local workspace.

    So that configuration creates in the app.xml loose application config this entry:

    <archive targetInArchive="/WEB-INF/lib/lib-with-tlds.jar">
    <dir sourceOnDisk="X:\path\to\eclipse\wslib-with-tlds\target\classes" targetInArchive="/"/>
    </archive>

    And that config is which trigger the bug in my end.

    Dependent jars not resolved inthe workspace creates other config entry

    <file sourceOnDisk="X:\path\to\eclipse\wslib-with-tlds\target\lib-with-tlds.jar" targetInArchive="/WEB-INF/lib/lib-with-tlds.jar"/>

    If i replace manually in the app.xml the latter with the former and restart the app, the tld is found.
    I can provide logs of both runs to provide more info if you think it can be useful.

    Thanks again


    ------------------------------
    Javier Neira
    Vitoria VI
    1-666-666-6666
    ------------------------------



  • 8.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Mon February 21, 2022 06:22 AM
    @Brian S Paskin
    Hi, to help to reproduce the issue i've uploaded a minimal example wich reproduces the bug for me: https://github.com/jneira/test-tlds
    It includes all the eclipse config files.
    Let me know if i can provide more info about.
    Thanks in advance


    ------------------------------
    Javier Neira
    Vitoria VI
    1-666-666-6666
    ------------------------------



  • 9.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Mon February 21, 2022 07:01 AM
    Thanks.  I will ask someone from the tools team to have a look.

    Brian

    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 10.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Mon February 21, 2022 08:12 AM
    Edited by Brian S Paskin Mon February 21, 2022 08:12 AM
    Having looked at your project, I believe the issue is with you Maven POM in the war.  It does not know where to find the lib.  If I try to compile it directly from the war's POM, it fails.  You would need a parent POM to compile them or use a module.

    mvn compile test-tld-war
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  0.087 s
    [INFO] Finished at: 2022-02-21T08:10:55-05:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/redacted/eclipse-workspace). Please verify you invoked Maven from the correct directory. -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException


    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 11.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Mon February 21, 2022 03:47 PM
    Edited by Javier Neira Mon February 21, 2022 05:23 PM
    Hi, not sure if not having a multi module pom building both artifacts is the cause:
    * i think you could install them in cascade with `cd test-tld-lib && mvn install && cd ../test-tld-war && mvn install`
    * but you can deploy an aplication and libs in liberty using the loose application feature without doing a effective install with maven, cause the developer plugin uses it to gather dependencies (doing a `mvn dependency-report` underneath) to create the xml

    In fact in all directories referenced by the xml

    <?xml version="1.0" encoding="UTF-8"?>
    <archive>
        <archive targetInArchive="/WEB-INF/lib/test-tld-lib-0.0.1.jar">
            <dir sourceOnDisk="X:\path\to\test-tlds\test-tld-lib\target\classes" targetInArchive="/"/>
            <dir sourceOnDisk="X:\path\to\test-tlds\test-tld-lib\target\test-classes" targetInArchive="/"/>
        </archive>
        <dir sourceOnDisk="X:\path\to\test-tlds\test-tld-war\src\main\webapp" targetInArchive="/"/>
        <dir sourceOnDisk="X:\path\to\test-tlds\test-tld-war\target\classes" targetInArchive="/WEB-INF/classes"/>
    </archive>
    have the needed classes, jsps, tlds, etc, when deploying the app in the server

    Thanks for checking!

    ------------------------------
    Javier Neira
    Vitoria VI
    1-666-666-6666
    ------------------------------



  • 12.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Mon February 21, 2022 05:25 PM
    It is not a good practice to reference another application and not include it properly in the POM. Creating an overall POM solved the issue for me, or adding the web assembly path to the lib also works:



    Brian

    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 13.  RE: tld inside a jar not found in ibm liberty server 20.0.0.9

    Posted Tue February 22, 2022 10:13 AM
    yeah, I usually create a multimodule pom to build all related projects but being a small somple reproducer I did no this time

    ------------------------------
    Javier Neira
    Vitoria VI
    1-666-666-6666
    ------------------------------