Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injection of OSGi Services not work [PAXCDI-239] #280

Open
ops4j-issues opened this issue May 14, 2019 · 4 comments
Open

Injection of OSGi Services not work [PAXCDI-239] #280

ops4j-issues opened this issue May 14, 2019 · 4 comments
Labels

Comments

@ops4j-issues
Copy link

Alexander Rotnov created PAXCDI-239

Bug reproduced with sample bundles "pax-cdi-sample1" and "pax-cdi-sample1-web".
To reproduce get clean Karaf 4.2.5, install required features and sample bundles:

feature:install pax-http-whiteboard
feature:install pax-cdi-web-weld-jetty
feature:install war
bundle:install -s mvn:org.ops4j.pax.cdi.samples/pax-cdi-sample1/1.1.1
bundle:install -s mvn:org.ops4j.pax.cdi.samples/pax-cdi-sample1-web/1.1.1

Open URL: http://localhost:8181/sample1/ice
Result is Error 503 Service Inavailable with message:

javax.servlet.ServletException: org.eclipse.jetty.servlet.ServletHolder$1: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Unsatisfied dependencies for type IceCreamService with qualifiers @Dynamic @Service @Filter @UniqueIdentifier
  at injection point [BackedAnnotatedField] @Inject @Service @Dynamic @Filter private org.ops4j.pax.cdi.sample1.web.IceCreamServlet.chocolate
  at org.ops4j.pax.cdi.sample1.web.IceCreamServlet.chocolate(IceCreamServlet.java:0)
...

Affects: 1.0.0, 1.1.0, 1.1.1
Votes: 0, Watches: 1

@paulsp
Copy link

paulsp commented Dec 18, 2021

The issue is present in 1.1.4

The URL /sample1/ice is not present in the integration testing. Adding the following test to itest/src/it/itest-standalone/src/test/java/org/ops4j/pax/cdi/test/ServletTest.java will test OSGi Service injection.

   @Test
   public void servletServiceInjection() {
        Client client = Client.create();
        WebResource resource = client.resource(String.format("http://localhost:%s/sample1/ice", httpPort));
        assertThat(resource.get(String.class), is("Message from managed bean\r\n"));
    }

Although message text need to be corrected, the following exception is being thrown:

org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Unsatisfied dependencies for type IceCreamService with qualifiers @Dynamic @Service @Filter @UniqueIdentifier
  at injection point [BackedAnnotatedField] @Inject @Service @Dynamic @Filter private org.ops4j.pax.cdi.sample1.web.IceCreamServlet.chocolate
  at org.ops4j.pax.cdi.sample1.web.IceCreamServlet.chocolate(IceCreamServlet.java:0)

@paulsp
Copy link

paulsp commented Dec 18, 2021

See #294 related to POM issue relate to Integration Testing

@grgrzybek
Copy link
Member

I'm sorry - last time I checked, the integration tests worked fine, but I agree that the Pax Exam integration test setup is a bit fragile.

The problem is that recently (~2 years) I was refactoring Pax Web (Pax Web 8.0.0 is already released) and I realized that Pax CDI has lots of issues I'll rather won't have the time to fix. Also I was working a bit trying to make Pax Web 8 working with Aries CDI and there's one deadlock left to fix - see ops4j/org.ops4j.pax.web#1622 ;)

Because Aries CDI is an implementation of OSGi R8 CMPN CDI Specification, I'm afraid Pax CDI won't get much attention...

@paulsp
Copy link

paulsp commented Jan 10, 2022

Thank you for the status. I will keep this in mind as I use Pax CDI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants