eclipse-ee4j / eclipse-ee4j/jersey

hk2-cdi bridge doesn't work correkt

Open
#3,427 3 comments 1 reaction 0 assignees View on GitHub
Component: containers Component: extensions Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

( With maven i use

```

org.glassfish.jersey.containers.glassfish
jersey-gf-cdi
2.14

```

)

If i register a concrete resource class, injection works correct e.g.:

```
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(RootResource.class);
```
```
public class RootResource
{
@Inject
@SimpleDb(value="mariadb")
private EntityManager em;

@GET
@Produces({ "text/plain" })
public final String getValue()
{
...............................
```

But now, i load a resource class dynamically, with

```
c = Class.forName(.....);
and register ist with
resourceConfig.register(c);
```

or

```
resourceConfig.registerInstances(c.newInstance());
```

But, it doesn't work and crashes with error

Unknown HK2 failure detected:
MultiException stack 1 of 1
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl .......................

Have u overseen something, or is it not possible to use
such anonymous classes?
#### Environment
Java SE 1.8.0_92-b14
Windows 7
#### Affected Versions
[2.14]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.