eclipse / jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Injecting repository during JerseyTest

donatellosantoro opened this issue · comments

Hi,
we are trying to executing a simple test using JerseyTest. However we notice that the CDI is not able to properly injecting the Repository implementation.
In particular, we are using:

  • jersey
  • weld as CDI, using "org.glassfish.jersey.inject:jersey-cdi2-se:+"
  • jersey-test-framework (org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2)
  • of course jnosql

In this case, in a simple test like the following, the Repository is never bind to any implementation.

public class TestJerseyRepository extends JerseyTest {
    protected Application configure() {
        return new ResourceConfig(UserRepository.class);
    }
    @Test
    public void testSelect() {
        UserRepository userRepository = CDI.current().select(UserRepository.class).get();
    }
}

we got the exception: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001334: Unsatisfied dependencies for type UserRepository with qualifiers

Other beans are instead injected fine. And also running the app in Tomcat works as expected.

In beans.xml we also enabled bean-discovery-mode="all"

Are we missing something?
Thanks

The cod looks ok, it version are you using?
Btw: I'll release the newest version this weekend.

Ciao Donatello, como está?

Could you update to the newest version and tell me if that works?
Thank you.

Ciao Otávio!
Thanks for your time and update! JNoSql is really helping us!

We tried the latest version, but we still have the same issue. Currently, we are using

  • jnosqlVersion = '1.0.0-b2'
  • jerseyVersion = '2.31'

We also prepared a very small project, to test the issue. If you have time you can have a look here
https://github.com/donatellosantoro/jsersey-test

There is a single resource (HelloWorldResource) that needs a repository (UserRepository). Deploying the app on tomcat (./gradlew war) works fine. However, if we try to inject the repository inside tests we still have the WELD-001408 exception. You can easily test using the command ./gradlew test --info

Thanks in advance

I trying, I'm not familiar with this tool, but so far what I know is it is not scanning the JNoSQL extensions.
It supposed to load the entity and I did not find a log such this:

INFO: Scanned com.example.User loaded with time 13 ms

Furthermore, It does not find the Repository with a log like this:

INFO: Starting to process on documents: 0 databases crud 1 

Thanks anyway Otávio.
In the output log, I can see the message

org.eclipse.jnosql.artemis.document.spi.DocumentExtension onAfterBeanDiscovery
INFO: Starting to process on documents: 0 databases crud 0

So it seems that the extension is loaded, but then it was not able to find any bean to handle.

Hi Otávio,
we tried to remove JNoSQL from the example, asking to inject only the User bean into HelloWorldResource and we still have the same issue during test.

So it is not a problem of JNoSQL. We can close the issue. Thanks again