0

First off, its not a window server, its Linux.

I'm getting this errors thrown by the following code:

javax.naming.NameNotFoundException: Name comp is not bound in this Context

The error leads back to a class I have. The class is called like so:

ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);      
stpe.scheduleAtFixedRate(new UpdateHistory(), 0, 30, TimeUnit.MINUTES);

And this is the class:

class Update implements Runnable {
    UpdateHistory upH = new UpdateHistory ();

    public void run() {

        try {

            upH.update();
        } catch (SQLException | NamingException | InterruptedException e) {
            e.printStackTrace();
        }
    }
} 

This class' code is inside my main class call myServlet.class. But it produces a second .class file so on my server directory I have:

myServlet.class
myServlet$Update.class

I think this is due to the context not transferring or something, I'm not 100% sure. Should I allowLinking in my settings to make sure the scheduled class can obtain the context?

Edit full stacktrace:

javax.naming.NameNotFoundException: Name comp is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at my.package.database.DatabaseManager.connect(DatabaseManager.java:66)
    at my.package.database.DatabaseManager.returnHistory(DatabaseManager.java:209)
    at my.package.UpdateHistory.upH(update.java:89)
    at my.package.myServlet$UpdateHistory.run(myServlet.java:76)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    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)
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
James MV
  • 8,569
  • 17
  • 65
  • 96
  • There's not enough information here to help you. What stacktrace do you get, and what does `UpdateHistory` look like? – gustafc Apr 19 '13 at 14:53
  • UpdateHistory runs some database code. It actually does it fine, it just throws the error also. The database code has been extensively tested on its own and is also working fine. I'll update with the main stack trace. – James MV Apr 19 '13 at 14:55
  • I would say NO, because: http://tomcat.10.x6.nabble.com/no-luck-with-allowLinking-quot-true-quot-td1981735.html#a1981746 – Hydroid Apr 19 '13 at 15:06
  • Thanks Gustafc, I think I may have a duplicate server related jar file in the web-inf/lib. I'll remove it and see if that helps. – James MV Apr 19 '13 at 15:14

0 Answers0