CDI RequestScoped,Threading and the javax.enterprise.context.ContextNotActiveException

Accessing a CDI @RequestScoped bean:

import javax.enterprise.context.RequestScoped;

public class Greeter {
    public String hello(long number){
        return "hello, duke " + number;


import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

public class GreetingResource {
    Greeter greeter;

    public String hello() {
        var numbers  = Stream.generate(System::currentTimeMillis)
        return numbers.parallelStream() //stream() would work...
        .map(number -> this.greeter.hello(number))

may cause a javax.enterprise.context.ContextNotActiveException, like e.g.

javax.enterprise.context.ContextNotActiveException: javax.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=airhacks.Greeter, id=59c45f3d436e11499d8793e2c5fc0c26ffbe3933]
- you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding

The entire example was implemented, and explained, "from scratch":

Adding / Merging / Joining two Collections / Lists

To join to List / Collection instances, you can concat their streams:

import java.util.List;
import org.junit.jupiter.api.Test;
public class JoiningTwoLists {

    public void join() {
        var first = List.of(1,2);
        var second = List.of(3,4);
        var joinedList = Stream.concat(,;

Prints: 1 2 3 4

"I first played games I wrote" podcast

Subscribe to podcast via: spotify| iTunes| RSS

The #203 episode with Daniel Lipp (@dynamic_123) about:
SmallTalk, ugly Java, enterprise architectures, clouds and Quarkus
is available for

JSON-B / JSON-P: From TextBlock To JsonArray

You can directly convert Java TextBlocks to JsonArray with Jakarta JSON Binding (JSON-B) and Jakarta JSON Processing (JSON-P):

import org.junit.jupiter.api.Test;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.json.bind.JsonbBuilder;

public class TextBlockToJsonArray {

    public void deserializeTextBlock() {
        var input = """
                    "name": "java",
                    "age": 25
                    "name": "python",
                    "age": 52
        var  jsonArray = JsonbBuilder.create().fromJson(input, JsonArray.class);

The output:


JSON-B and JSON-P functionality comes as a single dependency:


Testing Jakarta EE, JAX-RS concurrency, Bulk Heads, Dependency Inversion, QuarkusTest, Authentication and DB, Secrets, sops, AWS KMS, SSM and SM--101st Q & A

The 101st episode with the following topics / questions:

"How to test Jakarta EE applications, JAX-RS concurrency and Bulk Heads, Java interfaces and dependency inversion, dependency on QuarkusTest, using authentication data for filtering, exposing versions, secrets, sops, AWS KMS, SSM and SM" ready to watch:

Any questions left? Ask now: and get the answers at the next

See you every first Monday of the month at 8pm CET (UTC+1:00). Show is also announced at:

Testability, Concurrency, Dependency Inversion, Authentication--101st

Questions for 101st (live

  1. 100 episodes back--the topics
  2. The story of Jakarta EE / MicroProfile testability
  3. JAX-RS and endpoint concurrency
  4. About interfaces and Dependency Inversion
  5. A portable QuarkusTest?
  6. Using authentication data for filtering in the business logic

See you every first Monday of the month at 8pm CET (UTC+1:00). Show is also announced at:

Any questions left? Ask now: and get the answers at the next

AWS Lambda, Events, Quarkus and podcast

Subscribe to podcast via: spotify| iTunes| RSS

The #202 episode with Goran Opacic (@goranopacic) about:
applying enterprise Java thinking to serverless clouds, Quarkus, AWS Lambda, consistency, DynamoDB and the "undifferentiated heavy lifting."
is available for

Superfluous "Stringification" and

The following exception:

" JsonParser#getObject() or JsonParser#getObjectStream() is valid only for START_OBJECT parser state. But current parser state is VALUE_STRING"

...can be caused by a superfluous "stringification" of regular JavaScript strings, like e.g. JSON.stringify(aString)

The JSON-P parser expects: {"hey":"duke"} but gets: "{\"hey\":\"duke\"}"

To fix the problem, remove JSON.stringify(aString); and send the string directly to the MicroProfile server:

const payload = "{"hey":"duke"}";
const response = await fetch("http://localhost:8080/imports", {
    method: 'POST',
    body: payload,
    headers: {

Testing With MicroProfile REST Client: How To Prevent WebApplicationException

An invocation of a not-existing resource / endpoint with MicroProfile REST client, like e.g.:



@RegisterRestClient(baseUri = "")
public interface ProblematicResourceClient {

    Response fetchNotExistingContent();

will cause an WebApplicationException like e.g.: Unknown error, status code 404
at org.jboss.resteasy.microprofile.client.DefaultResponseExceptionMapper.toThrowable(

To test the 404 status code:

import io.quarkus.test.junit.QuarkusTest;
import static org.junit.jupiter.api.Assertions.assertEquals;
import javax.inject.Inject;
import org.junit.jupiter.api.Test;

public class ProblematicResourceClientIT {

    ProblematicResourceClient cut;

    public void callNotExistingResource() {
        var response = this.cut.fetchNotExistingContent();
        assertEquals(response.getStatus(), 404);
} need to set the MP config parameter to true::

Now the Response contains the status code 404 and the test passes.

Write, Finish, podcast

Subscribe to podcast via: spotify| iTunes| RSS

The #201 episode with Alejandro Pablo Revilla (@apr) about:
long distance radio, early internet, opensource innovation, building Point of Sales (POS) software in Java, no-dependencies thinking and having fun with continuous improvement.
is available for

Online Workshops
...the last 150 posts
...the last 10 comments