I’ve upgraded an ‘old’ (was working) EE Application with JSON which did work with ‘javax’. Now EE 10.x & Jakarta.
implementation("com.google.code.gson:gson:2.11.0")
Using:
@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 only 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
- curl 8.9.1
- WildFly Distribution – 33.0.0.Final
- Jakarta EE 10.0.0 & 11.0.0-M4
- JDK 22.0.2
- Kotlin 2.0.0
- Mojarra 4.1.0
TIA.,