I'm running a
Servlet 3.0 application on
Tomcat, using Jersey to create REST controllers and Weld for dependency injection. My controllers use repositories and my repositories use a data source.
I've configured my application so that Tomcat puts the data source into the web application context. When I look up the data source with JNDI, I can get an instance of
DataSource just fine:
Now, instead of looking up the data source from the initial context, I want to inject it into the constructors of my repository:
Weld manages to find my
DataSourceUserRepository when I try to inject it into my
UserController, but it can't satisfy the
DataSource dependency:
It doesn't matter when I change the name to
"java:comp/env/jdbc/ExampleDB",
"ExampleDB",
"exampleDB" or when I remove the annotation altogether.
Here is my
context.xml:
Does anyone know how I can fix this?