2 Replies Latest reply on Oct 16, 2008 5:51 PM by Scott Stark

    Should @Inject find an alias?

    Scott Stark Master

      I'm seeing a failure to inject a bean by its alias. Given this bean:

       <!-- An InitialContextFactory that uses the NamingContext.getLocal() Naming -->
       <bean name="InitialContextFactory#1" class="org.jboss.naming.InitialContextFactoryBean">
       <alias>InitialContextFactory</alias>
       <property name="env">
       <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
       <entry>
       <key>java.naming.factory.initial</key>
       <value>org.jnp.interfaces.LocalOnlyContextFactory</value>
       </entry>
       <entry>
       <key>java.naming.factory.url</key>
       <value>org.jboss.naming:org.jnp.interfaces</value>
       </entry>
       </map>
       </property>
       <depends>testLocaNamingBeanImpl#1</depends>
       </bean>
      


      This injection into a unit test:
       @Inject(bean="InitialContextFactory", property="ctx")
       public void setInitialContext(InitialContext ctx)
       {
       this.ctx = ctx;
       }
      


      fails with:
      java.lang.IllegalStateException: Incompletely deployed:
      
      *** DEPLOYMENTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
      b4fb6399-bd84-41be-a3bc-4a0ddc0da8e6 -> InitialContextFactory{Installed:** NOT FOUND **}
      
       at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:290)
       at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:174)
       at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.validate(MicrocontainerTestDelegate.java:262)
       at org.jboss.test.kernel.junit.MicrocontainerTest.afterSetUp(MicrocontainerTest.java:117)
       at org.jboss.test.kernel.junit.MicrocontainerTest.setUp(MicrocontainerTest.java:91)