What I\'m trying to do is to update my database after a period of time. So I\'m using java scheduler and connection pooling. I don\'t know why but my code only working once. It
This error shows that your jdbc resource is not registered! Where did you put your context.xml
?
The context.xml
file must be in the META-INF
directory of the war file. It must not be in the classes directory or in a jar file.
Put the META-INF
directory with the context.xml
in the directory containing the root of the webapp in your source folder tree.
I had the same problem which dragged on for two painful days. I Re-read tomcat documentation about JNDI, confirmed all my server.xml
, context.xml
,web.xml
configuration and the code to access the naming object... still no progress.
It turned out to be a dependency in my project that was interfering with the naming context - axis2. A simple move from axis2-1.6.0 to axis2-1.6.2 caused my problem.
This problem is likely to arise when two versions of a same module are present.
Kindly check the lib
folder for multiple versions of the same module.
Remove the version that you don't need and restart the server.
In my case it was servlet-api
present in two versions servlet-api.jar
servlet-api-2.jar
Hope this solves your problem. Good day!
Try stopping and restarting your server (I assume you are using Eclipse and a Tomcat server). Maybe when you created your context xml file as it did was empty initially, your server was not able to synchronize its contents hence its inability to find the database connection resource name you later specified in the context.xml file.
i.e. if you have not already solved this problem.
It's not java:/comp/env
but java:comp/env
.
I just ran in the same issue. In my case there was nothing wrong with my tomcat configuration files or my project but I had to restart my postgres service instance as my tomcat was running and it would somehow pick up the change and the exception disappeared. I had to restart windows for the problem to go away completely. No idea why!