2 Replies Latest reply on Mar 27, 2017 6:38 AM by snarff

    Resource injection troubles

    snarff

      I configured a data source in my standalone.xml:

       

      <datasource jta="true" jndi-name="java:jboss/datasources/foobarDS" pool-name="foobarDS" enabled="true" use-ccm="true">

            <connection-url>jdbc:mysql://localhost:3306/foobar</connection-url>

            <driver>mysql</driver>

            <pool>

                 <min-pool-size>2</min-pool-size>

                 <max-pool-size>5</max-pool-size>

            </pool>

            <security>

                 <user-name>bond</user-name>

                 <password>007</password>

            </security>

      </datasource>

       

      I tested this through the WIldfly management interface, and I can successfully connect. So far, so good.

       

      In my source, I am trying to inject the data source as follows:

            @Resource(name="java:jboss/datasources/foobarDS")

         private DataSource ds;

       

      However, an attempt to deploy the application gives me the following:

       

      21:16:54,867 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."test.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "test.war"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

          at java.lang.Thread.run(Thread.java:745)

      Caused by: java.lang.IllegalArgumentException: WFLYEE0047: Incompatible conflicting binding at java:jboss/datasources/foobarDS source: lookup (java:comp/DefaultDataSource)

          at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:238)

          at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:182)

          at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)

          at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:186)

          at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:143)

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)

          ... 5 more

       

      I am totally clueless here.

      Any help is appreciated...

        • 1. Re: Resource injection troubles
          jaikiran

          Izak van Langevelde wrote:

           

           

          In my source, I am trying to inject the data source as follows:

          @Resource(name="java:jboss/datasources/foobarDS")

          private DataSource ds;

           

          Change it to:

           

          @Resource(lookup="java:jboss/datasources/foobarDS")
          

           

          (notice that you should use the lookup attribute to point to the target. The name attributes tell where to bind it in the component scoped JNDI namespace).

          • 2. Re: Resource injection troubles
            snarff

            Works for me, thanks!