Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-5369

Wildfly doesn't handle @Resource name attribute for DataSource type


    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 9.0.1.Final
    • Fix Version/s: No Release
    • Component/s: None
    • Labels:


      When using @Resource with name attribute to inject an object from environment naming context (ENC) into a servlet or EJB, Wildfly is producing an error.

      Here is an example from injecting into Servlet (the same is with injecting into EJBs).
      First the part that does work:

      @Resource(name="db1", lookup="java:jboss/datasources/ExampleDS", type=DataSource.class)
      public class Servlet1 extends HttpServlet {
      	public void init0() throws Exception {
      		System.out.println("___________db1: " + InitialContext.doLookup("java:comp/env/db1"));

      So we can see that the ENC entry db1 is properly defined and can be looked up.
      Now we add a field to the above class and use @Resource injection:

      DataSource ds;

      we get the this error:

      Caused by: java.lang.IllegalArgumentException: WFLYEE0047: Incompatible conflicting binding at java:module/env/db1 source: lookup (java:jboss/datasources/ExampleDS)
      	at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:221)
      	at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:183)
      	at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
      	at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:187)
      	at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:144)
      	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:156)
      	... 5 more

      Interestingly, if I change the data type of a field from DataSource to Object, things start working.

      This is a very basic functionality of Java EE and we are using it extensively to produce vendor independent deployment units that directly reference only logical ENC entries and not physical vendor specific JNDI names. Then during deployment the administrator would customize the mapping to match the application server and a specific environment.

        Gliffy Diagrams




              • Assignee:
                jason.greene Jason Greene
                user992281 Ceei Eeirr
              • Votes:
                0 Vote for this issue
                3 Start watching this issue


                • Created: