OpenLiberty / guide-maven-intro

An introductory guide on how to build applications using Maven on Open Liberty: https://openliberty.io/guides/maven-intro.html
Other
20 stars 35 forks source link

The generated ServletSample.war does not work elsewhere #152

Closed NK-debug closed 1 year ago

NK-debug commented 1 year ago

"mvn package" (or "mvn liberty:package") generates "ServletSample.war" of the guide-maven-intro example. This .war file does not work if dropped into another standalone Liberty server. The index.html will display, but when you hit the link for the servlet, you get an error: Error 404: javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /servlet

jakub-pomykala commented 1 year ago

Hi @NK-debug thank you for raising this issue with us.

If you haven't already would you be able to copy over the server.xml along side the ServletSample.war the from the guide-maven-intro.

If that is what you have done already or have tried it and it was still the same issue would you be able to provide us with the server.xml that you used and also a bit more context on what commands you have used and what directories have you moved both server.xml and ServletSample.war to.

Thanks in advance!

NK-debug commented 1 year ago

There is no ServerSample.war generated; it is ServletSample.war generated by "mvn package". The Github system here does not allow .xml and .war file uploads, so... Rename server_xml.txt to server.xml Rename ServletSample.zip to ServletSample.war

Try dropping this ServletSample.war into a real IBM Websphere Liberty server's "dropins" directory. It should work with no other configuration changes, but it doesn't. (I can send you a sample tomcat .war file that will work on tomcat, Liberty, WAS, etc. web servers with no configuration changes or modifications necessary)

server_xml.txt ServletSample.zip

gkwan-ibm commented 1 year ago

hi @NK-debug

Would you confirm that server_xml.txt is from the guide and not from your IBM WebSphere Liberty server?

Does the server.xml in your IBM WebSphere Liberty server have the servlet-5.0 feature? Would you post the features list in <featureManager>...</featureManager> from it?

I tried your scenario. The app works fine to me when my server.xml includes servlet-5.0 feature as

    <featureManager>
        <feature>servlet-5.0</feature>
    </featureManager>
NK-debug commented 1 year ago

The server.xml was from the guide. This is what we use with our IBM WebSphere Liberty. It includes servlet-4.0. I will have to find another non-shared server to try servlet-5.0 😞

    <featureManager>
        <feature>webProfile-8.0</feature>
        <feature>adminCenter-1.0</feature>
    </featureManager>

It gets to index.html when I go to https://myhostname:9443/ServletSample/ But when I click on the "Click here" link from there, I get: "Error 404: javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /servlet"

gkwan-ibm commented 1 year ago

The app in this guide is for EE9. Your server.xml is for EE8. That may explain why it does not work. Would you try your scenario on a EE9 Liberty server?

NK-debug commented 1 year ago

The example/sample looked simple enough; can't imagine that servlet example .war file to print "Hello! How are you today?" via a servlet would absolutely need EE9 and not EE8 to work. It almost looked like the sample was missing a context root when used elsewhere.

It will take me a while to get an IBM WebSphere Liberty server on EE9, but I will try it there when I get one set up here.

gkwan-ibm commented 1 year ago

If you check the app source, you will see that the app is using EE9 apis.

NK-debug commented 1 year ago

I installed IBM WebSphere Liberty v23 with webProfile-9.1 (which includes servlet-5.0), and the ServletSample.war does work as packaged. Thanks @gkwan-ibm ! This issue can be closed.