JAX-RS resource returns HTTP/1.1 404 Not Found after Jakarta migration

I’ve upgraded an ‘old’ (was working) EE Application with JSON which did work with ‘javax’. Now on EE 10.x & Jakarta.

implementation("com.google.code.gson:gson:2.11.0")

Using:

import com.bewherewhen.ejb.UsersJSONEJB;

import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named
@Path("/")
public class UsersJSONController {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/get-all-users")
    public Response getAllUsersJSON() {
        LOGGER.info(">>>>> UsersJSONController getAllUsersJSON .....");

        String json = usersJSONEJB.getAllUsersJSON();
        LOGGER.info(">>>>> 1.6 UsersJSONEJB getAllUsersJSON = {}", json);

        return Response.ok(json, MediaType.APPLICATION_JSON).build();
    }
}

If I run ‘curl’ I get:

curl -v http://127.0.0.1:8080/get-all-users/
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080
> GET /get-all-users/ HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 404 Not Found
< Connection: keep-alive
< Content-Length: 74
< Content-Type: text/html
< Date: Sun, 04 Aug 2024 17:07:07 GMT
< 
* Connection #0 to host 127.0.0.1 left intact
<html><head><title>Error</title></head><body>404 - Not Found</body></html>

Using:

  • macOS Sonoma 14.6
  • gson 2.11.0
  • curl 8.9.1
  • WildFly Distribution – 33.0.0.Final
  • Jakarta EE 10.0.0 & 11.0.0-M4
  • JDK 21.0.2
  • Kotlin 2.0.0
  • Mojarra 4.1.0

TIA.

4

I added ‘ApplicationPath/ApplicationConfig’ on ‘javax’:

package com.bewherewhen.webservices;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("beWhereWhen")
public class ApplicationConfig extends Application {
    public ApplicationConfig() {
    }
}

Run:

curl -v http://localhost:8080/BeWhereWhen/beWhereWhen/get-all-users/

Gives ‘HTTP/1.1 200 OK”:

* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8080...
* connect to ::1 port 8080 from ::1 port 63674 failed: Connection refused
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080
> GET /BeWhereWhen/beWhereWhen/get-all-users/ HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: application/json
< Content-Length: 4
< Date: Tue, 06 Aug 2024 21:31:47 GMT
< 
* Connection #0 to host localhost left intact

However unable to create a version for Jakarta EE 10/11:

import jakarta.faces.application.Application;
import jakarta.ws.rs.ApplicationPath;

Error with:

error: ApplicationConfig is not abstract and does not override abstract method getValidatorIds() in Application

Unable to deploy with “jakarta.ws.rs” on EE 10/11. Selected Methods to Implement on WildFly 32.0.0. Can any suggestion or examples?

Fixed:

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
import java.util.Set;

@ApplicationPath("beWhereWhen")
public class ApplicationConfig extends Application {
    public ApplicationConfig() {
        // Default constructor
    }

    @Override
    public Set<Class<?>> getClasses() {
        // Return a non-null Set of resource and provider classes
        return Set.of(); // Replace with actual resource classes if any
    }

    //@Override
    public ActionListener getActionListener() {
        // Implement the method for the action listener
        return new MyActionListener(); // Replace with your actual listener implementation
    }

    // Define MyActionListener or replace with your actual implementation
    private static class MyActionListener implements ActionListener {
        @Override
        public void performSomeAction() {
            // Implement the action listener's functionality here
        }
    }

    // Define an interface if it's not already defined.
    // This is just an example. Replace it with the actual interface definition.
    private interface ActionListener {
        void performSomeAction();
    }
}

Run:

* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8080...
* connect to ::1 port 8080 from ::1 port 49357 failed: Connection refused
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080
> GET /BeWhereWhen/beWhereWhen/get-all-users HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: application/json
< Content-Length: 14
< Date: Fri, 09 Aug 2024 16:19:36 GMT
< 
[
  {etc ...},
  {etc ...}
* Connection #0 to host localhost left intact

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật