eladchen / rest-easy-cdi

An example of JAX-RS using RestEasy with CDI using Weld
GNU General Public License v3.0
4 stars 1 forks source link

Injection not working #2

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi, I'm trying to achieve the same setup as you did, I cloned your repos, and start the server in debug mode (in Intellij) and realize the Injection is not working either (TextProcessing into EchoResource for example). I'm facing the exact same problem.

Do you have a recommendation?

eladchen commented 5 years ago

Hi,

I would love to help ! I just ran the latest on the master branch and the unit test in there are working fine for me.

Few questions:

  1. Are the test failing for you?
  2. Is there an error being thrown? Did modify the code in someway? If so I'll need to see an example so I can tell help you troubleshoot the issue at hand.
ghost commented 5 years ago

Cloning the repos then running ./gradlew clean build run:

I got all tests failling:

java.lang.RuntimeException: java.lang.IllegalStateException: WELD-ENV-002009: Weld SE container cannot be initialized - no bean archives found at com.example.UndertowServer.start(UndertowServer.java:90) at com.example.TestCDI.assignAndStartApp(TestCDI.java:36) at com.example.TestCDI.testHttpServletCDI(TestCDI.java:79)

eladchen commented 5 years ago

Hi,

There is something off. Could you please checkout the cdi-jpa branch and run that?

ghost commented 5 years ago

I have testCDI() failling:

org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Unsatisfied dependencies for type TextProcessing with qualifiers @Named at injection point [BackedAnnotatedField] @Inject @Named com.example.servlets.http.EchoServlet.upperCaseTextProcessing at com.example.servlets.http.EchoServlet.upperCaseTextProcessing(EchoServlet.java:0)

Looks like this one is also failing on master

eladchen commented 5 years ago

This is baffling. I did a fresh checkout, the tests are passing & even the jar is executed and working..

Are you sure you're running ./gradlew and not gradle?

Could you provide the complete terminal command and the output?

ghost commented 5 years ago

:D

jderuere@jderuere-ThinkCentre-M910q:~/Repository/rest-easy-cdi$ git status
On branch cdi-jpa
Your branch is up to date with 'origin/cdi-jpa'.

nothing to commit, working tree clean
jderuere@jderuere-ThinkCentre-M910q:~/Repository/rest-easy-cdi$ ./gradlew clean build run

> Task :test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/home/jderuere/.gradle/caches/modules-2/files-2.1/org.jboss.xnio/xnio-nio/3.3.8.Final/8dafaf230666e526c53e544ab6a9d6ecfcbab4ee/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

com.example.Tests > testCDI() FAILED
    org.opentest4j.AssertionFailedError at Tests.java:53

2 tests completed, 1 failed

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/jderuere/Repository/rest-easy-cdi/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
9 actionable tasks: 9 executed
eladchen commented 5 years ago

Are you using a JDK (Oracle?) > 8?

ghost commented 5 years ago

I was exactly thinking of this! Indeed, I'm on the last version, looks like Gradle 5 has just been released and support java 11. I'll give a try.