eclipse-ee4j / eclipse-ee4j/jersey

@ApplicationPath value ignored by GrizzlyHttpContainer (SE deployment)

Open
#4,205 8 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Problem: ```@ApplicationPath``` value is not being used when deploying JAX-RS app in SE environment using GrizzlyHttpContainer module.

Environment:
Jersey framework: 2.28
Java VM:
> java version "11.0.2" 2019-01-15 LTS
> Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
> Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

JAX-RS root resource

```java

@Path("hello")
public class HelloResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String get() {
return "hello world";
}
}
```

JAX-RS Application

```java
@ApplicationPath("api")

public class AppConfig extends Application {

public AppConfig() {
super();
}

@Override
public Set> getClasses() {
Set> classes = new HashSet<>();

classes.add(HelloResource.class);

return classes;
}
}
```

JAX-RS SE deployment using Jersey framework containers (grizzly)

```java
public static void main( String[] args ) throws Exception
{
URI baseUrl = URI.create("http://localhost:80");

// Jersey
ResourceConfig rc = ResourceConfig.forApplicationClass(AppConfig.class);

// container (GrizzlyHttpContainer) + server (Grizzly HttpServer)
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUrl, rc, false);

server.start();
System.in.read();
server.shutdown();
}
```

output:

```curl -i 'http://localhost:80/api/hello``` -> ```404 Not Found```

```curl -i 'http://localhost:80/hello``` -> ```hello world```

maven

```xml



org.glassfish.jersey
jersey-bom
2.28
import
pom



org.glassfish.jaxb
jaxb-bom
2.3.2
import
pom



org.glassfish.jersey.containers
jersey-container-grizzly2-http



org.glassfish.jersey.inject
jersey-hk2
runtime



org.glassfish.jaxb
jaxb-runtime
runtime

```

Contributor guide

Open the contributing guide

Research direction

Start with the GrizzlyHttpServerFactory.createHttpServer call and the ResourceConfig.forApplicationClass(AppConfig.class) setup shown in the report. Reproduce the deployment with @ApplicationPath("api") and verify that /api/hello responds instead of only /hello; done means the declared application path is honored in the SE Grizzly deployment.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.