Hi all,

I've just started using OpenEJB 3.1.1 for unit testing an EJB3 Maven project that will be deployed in a GlassFish environment. OpenEJB has really simplified unit testing of EJB3s and will be saving me a lot of time in the future, however I've run into a problem when testing code using LDAP connections.

Problem: In one of my stateless bean I'm injecting an LDAP connection (DirContext) that is registered with a JNDI name in GlassFish:

@Resource(name = "ldap/userDirectory")
private DirContext ldapConn;

Whenever I run a unit test with the above code I get the following error:

WARN - Jar not loaded. classpath.ear. No provider available for resource-ref 'null' of type 'javax.naming.directory.DirContext' for 'UserServiceBean'. org.apache.openejb.OpenEJBException: No provider available for resource-ref 'null' of type 'javax.naming.directory.DirContext' for 'UserServiceBean'. at org .apache.openejb.config.AutoConfig.autoCreateResource(AutoConfig.java: 1342) at org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1335) at org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1286) at org .apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java: 799) at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:724) at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:133) at org.apache.openejb.config.ConfigurationFactory $Chain.deploy(ConfigurationFactory.java:247) at org .apache .openejb .config .ConfigurationFactory.configureApplication(ConfigurationFactory.java: 601) at org .apache .openejb .config .ConfigurationFactory.configureApplication(ConfigurationFactory.java: 551) at org .apache .openejb .config .ConfigurationFactory .getOpenEjbConfiguration(ConfigurationFactory.java:380) at org .apache .openejb .assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:292) at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:271)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)

I tried looking into ways of injecting the DirContext, but with no luck.

Anybody know how to go about this? Any help is much appreciated.

Thanks,
 Allan

Reply via email to