• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why cannot create a resource instance error during run time?  RSS feed

 
Mark Curlette
Ranch Hand
Posts: 46
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,

I have a simple program in eclipse which i tried to call a resource reference that I have created in web.xml file; but it gave me an error saying that it could not create a resource instance at this line of the code in the servlet listener
mgr = (TimerManager) itx.lookup("java:comp/env/timerRef");
My question is that I did not know why it gave such error since the program only tried to look up for a resource reference NOT creating it. The error simply did not make sense.
If you know what happening , please let me know.
Thanks so much in advance!!



my web.xml






My MyServletContextListener tried to look for the resource ref in the web.xml ; but i got a run time exception error saying "can not create resource instance" . The error points to this line of the code "mgr = (TimerManager) itx.lookup("java:comp/env/timerRef");"





My StockQuote bean is

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When reporting an exception, best practice would be to give multiple lines of the EXACT exception stack trace rather than your interpretation.

Frequently there is good debugging information in a stack trace but we need the exact text.

Bill
 
Mark Curlette
Ranch Hand
Posts: 46
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bill,

Here is exception i got from console. Hope it helps.

javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:146)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:826)
at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.minh.MyServletContextListener.contextInitialized(MyServletContextListener.java:54)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
===> Stock quote is org.minh.StockQuoteTimerListener@18607df6
Jul 23, 2013 2:46:20 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.minh.MyServletContextListener
java.lang.NullPointerException
at org.minh.MyServletContextListener.contextInitialized(MyServletContextListener.java:66)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!