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 showed me that the AS now knows an the connection-factoty
Now I'd like to use it in my beans to use file access without using 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();
}
returnnull;
}
...
Unfortunately I can't look up the ConnectionFactory 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: