I have created a data source in JBoss and have confirmed that it is up by checking the
status in the Admin Console. We have a requirement of accessing the JNDI resource
during the JBoss server startup(our startup class which gets invoked during the server startup
does the JNDI lookup).
When the server comes up, I get the foll error: "JNDI resource does not exist JNDI Name=jdbc/AuditDB"
I found out that the problem was caused because the our startup class was doing the JNDI lookup even before the datasource became available. So the above error is expected at the beginning. Even though the DS is not available in the beginning of the server startup, it subsequently becomes available. We have a thread that wakes up at regular intervals and once the DS is available, I would expect the JNDI lookup to be successful in the subsequent calls. However, I still get the same error. I am not sure what causes this behavior. We saw the same problem with WebSphere but the subsequent JNDI calls were successful. I also tried one more thing. I added sufficient sleep time in the beginning of the separate thread which wakes up at regular intervals to transfer data to the DB. This was done to ensure that the first time it accesses the JNDI resource, the DS is already available. Suprisingly, this doesn't work as well. I get the same error.
The only thing that has worked is adding a dependancy for making the data source available in the jboss-service.xml file.
This would have been an accepatable solution, but then I see in the logs that binding of all the DS's seem to happen even though I specifically
want only the one I have listed as a dependancy. Am I doing something wrong?
Would appreciate any suggestions to get past this problem. Thanks!