Search code examples
restintellij-ideajakarta-eeglassfish-6

JEE RESTfull web service tutorial ends with 404


I'm trying to run simple RESTfull service tutorial in Java Enterprise Edition and IntelliJ located here. I use GlassFish server 6.2.3 and OpenJDK 17.0.1. The application is very simple and strictly according to tutorial steps. But every time I start application the result is 404.

Server log is without errors (I can go into admin site on localhost:4848 and see my application loaded under Common tasks/Applications), but there are some errors in GlassFish Log:

Error while trying to load Bean Class com.example.restglassfishhelloworld.HelloApplication : java.lang.NoClassDefFoundError: javax/ws/rs/core/Application.]]

WELD-000119: Not generating any bean definitions from com.example.restglassfishhelloworld.HelloApplication because of underlying class loading error: Type javax.ws.rs.core.Application not found.

I suppose that this could be the reason for not working sites, but unfortunately don't understand it (the Application class exists) and don't know how to fix it. Or maybe there could be some other reason for the issue in Glassfish settings... Could somebody help me?

EDIT: link to project on GitHub


Solution

  • Based on comments from CrazyCoder (thank you) and this answer I was in the end able to run the JetBrains tutorial example with following combinations:

    • Tomcat 9 + OpenJDK 17 or OpenJDK 11 or JDK 1.8
    • Glassfish 4 + JDK 1.8

    Important note for Windows users and Glassfish scenario - AS_JAVA variable should be added to asenv.bat instead of asenv.conf, it means add i.e. set AS_JAVA=C:\Program Files\Java\jdk1.8.0_321 (depends on your JDK installation path) to <glassfish root>\glassfish\config\asenv.bat See this article.