0

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

Lukas
  • 2,034
  • 19
  • 27
  • 1
    Try GlassFish 4.1 as in the tutorial. If it doesn't help, please share your project on GitHub. – CrazyCoder Feb 16 '22 at 22:06
  • 1
    Glassfish 6+ uses Jakarta EE and may not work with javax.* servlets, similar to this issue, hence 404: https://stackoverflow.com/a/66808062/104891. Did you test with Glassfish 4? Does it also fail for you? – CrazyCoder Feb 17 '22 at 06:41
  • @CrazyCoder I've tried GlassFish 4 and 5, but in 4 I ended up with error `GlassFish requires Java SE version 6. Your JDK is version 0` (tried to add AS_JAVA to config file, use OpenJDK 17 or 11 - without effect). I'll try to run with Tomcat 9 – Lukas Feb 17 '22 at 07:05
  • 1
    Set AS_JAVA to JDK 1.8. – CrazyCoder Feb 17 '22 at 07:05

1 Answers1

0

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.

Lukas
  • 2,034
  • 19
  • 27