Glassfish上Java8开发的Web服务调用后端时触发Queue full异常
Hey there, let's break down this confusing Queue full exception you're facing—even though you didn't explicitly use any queues in your code. This is almost always a hidden issue from the underlying Glassfish runtime or the HTTP client you're using to call your backend service. Here are the most likely causes and fixes:
Possible Causes & Solutions
1. Glassfish's HTTP Client Connection Pool/Request Queue Overflow
Glassfish's built-in HTTP clients (like JAX-RS Client or the underlying HttpURLConnection) maintain internal connection pools or request queues under the hood. When concurrent requests exceed their configured limits, you'll hit this exception.
- Check Glassfish's HTTP client config:
- Navigate to your Glassfish domain's
config/domain.xmlfile, search forconnector-connection-poolorhttp-servicerelated settings. - Adjust parameters like
max-pool-size(maximum connections) andqueue-size(pending request queue length) to match your expected traffic volume. - If you're using JAX-RS Client, explicitly configure the connection pool in code:
Client client = ClientBuilder.newBuilder() .property(ClientProperties.CONNECT_TIMEOUT, 5000) .property(ClientProperties.READ_TIMEOUT, 5000) .property("jersey.config.client.connectionPool.maxTotal", 100) // Tweak this value .build();
- Navigate to your Glassfish domain's
2. Slow Backend Responses Causing Request Backlog
Even though the backend returns a success response, if it's slow to process requests, your service's underlying queue will fill up waiting for responses.
- Optimize backend performance: Diagnose bottlenecks in the backend (like slow DB queries or IO operations) to reduce response time.
- Add timeout controls: Set reasonable connect and read timeouts when calling the backend to prevent requests from hogging queue resources indefinitely:
WebTarget target = client.target("http://your-backend-service-url"); Response response = target.request() .property(ClientProperties.CONNECT_TIMEOUT, 3000) .property(ClientProperties.READ_TIMEOUT, 10000) .get();
3. Insufficient Glassfish Web Container Thread Pool
If Glassfish's thread pool for handling web requests is maxed out, pending requests get queued—and when that queue hits its limit, you'll see this error.
- Adjust thread pool settings:
- Open the Glassfish Admin Console (default at
http://localhost:4848), go toConfigurations > server-config > Thread Pools, find thehttp-thread-pool. - Increase the
Maximum Pool SizeandQueue Sizevalues to handle your concurrent request load.
- Open the Glassfish Admin Console (default at
4. Hidden Queues in Third-Party Libraries
You might be using a logging framework, monitoring tool, or other dependency that uses internal queues under the surface, and those queues are hitting capacity.
- Audit your dependencies: Check your project's pom.xml (or build.gradle) for libraries that handle async processing or messaging—look for config settings related to queue limits.
- Enable detailed Glassfish logging: Set the log level to
FINEorFINERindomain.xmlto capture the full exception stack trace. This will show you exactly which class is throwing the queue full error, helping you pinpoint the culprit component.
内容的提问来源于stack exchange,提问作者H.I

