2 Replies Latest reply on Oct 19, 2010 9:31 AM by Jens Mander

    Another injection issue

    Jens Mander Newbie

      Hi,

       

      I'm trying to set up the "File System Adapter" like shown here http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch7.chapt.html

      First I build the rar-archive and moved it to the deploy-folder together with the MBean descriptor (notxfs-ds.xml). So far so good. The admin console and the jmx-console show me that the AS now knows the specific connection-factory

       

      JMX (jboss.jca)

       

      Admin-Console

      View by Type:

      NameTypeStatusActions
      NoTransFSNo Tx ConnectionFactory UP

       

      Now I'd like to use it in my beans to set up file access without relying on java.io.* so I used the following code:

       

       

      import javax.annotation.Resource;
      import javax.resource.cci.ConnectionFactory;
      
      ...
      
          @Resource(name="NoTransFS")
          private DirContextFactory dcf;
      
          public String action() {
              try {
                  DirContext dc = dcf.getConnection();
                  NamingEnumeration<SearchResult> res = dc.search("myFile", null);
                  while (res.hasMore()) {
                      System.out.println(res.next().toString());
                  }
              } catch (NamingException e) {
                  e.printStackTrace();
              }
              return null;
          }
      
      ...   
      

       

      Unfortunately I can't look up the ConnectionFactory via JDNI so I'll always receive a NullPointerException.I tried several kinds of the @Resource annotation but nothing works out. Maybe the JNDIView helps somebody to give me some hints:

       

       

      java: Namespace
        +- securityManagement (class: org.jboss.security.integration.JNDIBasedSecurityManagement)
        +- comp (class: javax.namingMain.Context)
        +- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
        +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
        +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
        +- authDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
        +- policyRegistration (class: org.jboss.security.plugins.JBossPolicyRegistration)
        +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
        +- app (class: org.jnp.interfaces.NamingContext)
        |   +- Manager (class: javax.inject.manager.Manager)
        +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
        +- Mail (class: javax.mail.Session)
        +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
        +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
        +- jaas (class: javax.naming.Context)   |   +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
        |   +- profileservice (class: org.jboss.security.plugins.SecurityDomainContext)
        |   +- jboss-web-policy (class: org.jboss.security.plugins.SecurityDomainContext)
        +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
        +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
        +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
        +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)   +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
        +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
        +- NoTransFS (class: org.jboss.chap7.ex1.ra.DirContextFactoryImpl)
      
      
      

       

      May anybody help me with this problem?`Thanks a lot