0

首先,它不是一个窗口服务器,它是 Linux。

我收到以下代码引发的错误:

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

该错误导致回到我的课程。该类的调用如下:

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

这是课程:

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

    public void run() {

        try {

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

这个类的代码在我的主类 myServlet.class 中。但它会在我的服务器目录中生成第二个 .class 文件:

myServlet.class
myServlet$Update.class

我认为这是由于上下文没有转移或其他原因,我不是 100% 确定。我应该在我的设置中允许链接以确保安排的课程可以获取上下文吗?

编辑完整的堆栈跟踪:

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)
4

0 回答 0