I am new to Tomcat , and I tried to create a school project using eclipse and Tomcat 7.0.
I received a javax.naming.NamingException: Cannot create resource instance with root cause which I think it may relate to the Tomcat server. I tried to solve it but with my limited understanding of the Tomcat server, i was not able to find a good explanation for the problem.
So i hope if you could guide me to why did i have this kind of error and how to resolve it.
My simple jsp is calling a resource reference which i declared in the web.xml file
My web.xml file which contains the above resource reference as following
I don't know why it gave the error since the jsp is calling a resource reference, and the resource reference is defined in the web.xml. The error is as followed:
I read some related article and it suggested that I need to declare the resource ref in context.xml. I don't why since I already declared it in web.xml. Is is not enough for Tomcat 7 to recognize?
If i declare it again in context.xml, then should it be exacly the same as I declared it in web.xml ?? such as the following :
Thanks for the pointer, I add the resource name reference to my context.xml but somehow Tomcat still gave me the error message saying that " javax.naming.NamingException: Cannot create resource instance with root cause".
I did not know why it did not work as it should. Please take a look to see if you could find anything unusual.
Thanks so much in advance for all of your help!!
my web.xml again is as following :
My context.xml is as the following:
and finally the following run time exception error saying it can not create the resource reference
Thank you very much Tim. You are absolutely right. I got rid of resource reference and replace it with your env-entry and it worked well.
I was able to Lookup: 4000000 from both of my jsp and eclipse console.
I would like to ask you an additional question if you don't mind relating to a class project which simply print out a stock quote and email in every ten minutes. It requires using the servlet context listener.
I would like to ask you please check my logic and please correct me if you spot any flaw in my logic.
Thanks so much for all of your helps.
I plan to do the following :
1. Create MyServletContextListener
My question is that can i replace the resource ref in the above code with the env-entry ? Please correct me if i am wrong because I think i need the resource refereence to get to the timer instance of the QuoteTimerListener in the code below.
2. Create a stock QuoteTimerListener which is called by the above MyServletContextListener
Actually, we'd prefer that when you switch topics that you start a whole new thread. It makes it easier for people to follow.
As far as I can tell, you are attempting to use the ServletContextListener to invokes functions in a servlet. Only web requests ought to do that. What I'd recommend is that the ServletContextListener construct a separate business object to manage the timer-controlled process. And make it an independent thread. The ServletContextListener (unlike servlets) is allowed to spawn threads.
subject: re: Is this javax.naming.NamingException related to error generated by Tomcat 7.0 ? and why ?