mongodb socket中的java.lang.Throwable错误是什么意思?

时间:2016-01-13 11:42:05

标签: java mongodb amazon-web-services glassfish

我试图了解那个错误是什么。当我将mongoDB放在另一个实例中时,它就开始发生了。

错误有一个很大的信息,但它没有说什么,而且没有任何行动可以触发它。

2016年1月12日星期二19:34:31 UTC  BY:[java.lang.Thread.getStackTrace(Thread.java:1552),com.sun.enterprise.loader.ASURLClassLoader.done(ASURLClassLoader.java:216),com.sun.enterprise.loader.ASURLClassLoader.preDestroy(ASURLClassLoader) .java:184),org.glassfish.javaee.full.deployment.EarClassLoader.preDestroy(EarClassLoader.java:114),org.jvnet.hk2.internal.ServiceLocatorImpl.preDestroy(ServiceLocatorImpl.java:956),org.jvnet。 hk2.internal.ServiceLocatorImpl.preDestroy(ServiceLocatorImpl.java:940),org.glassfish.internal.data.ApplicationInfo.clean(ApplicationInfo.java:451),com.sun.enterprise.v3.server.ApplicationLifecycle.unload(ApplicationLifecycle。 java:1071),com.sun.enterprise.v3.server.ApplicationLifecycle.undeploy(ApplicationLifecycle.java:1099),org.glassfish.deployment.admin.UndeployCommand.execute(UndeployCommand.java:412),com.sun.enterprise .v3.admin.CommandRunnerImpl $ 2 $ 1.run(CommandRunnerImpl.java:539),com.sun.enterprise.v3.admin.CommandRunnerImpl $ 2 $ 1.run(CommandRunnerImpl.java:535),java.security.AccessContr oller.doPrivileged(Native Method),javax.security.auth.Subject.doAs(Subject.java:360),com.sun.enterprise.v3.admin.CommandRunnerImpl $ 2.execute(CommandRunnerImpl.java:534),com.sun .enterprise.v3.admin.CommandRunnerImpl $ 3.run(CommandRunnerImpl.java:565),com.sun.enterprise.v3.admin.CommandRunnerImpl $ 3.run(CommandRunnerImpl.java:557),java.security.AccessController.doPrivileged(Native方法),javax.security.auth.Subject.doAs(Subject.java:360),com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556),com.sun.enterprise.v3.admin .CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464),com.sun.enterprise.v3.admin.CommandRunnerImpl.access $ 1300(CommandRunnerImpl.java:109),com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute( CommandRunnerImpl.java:1846),com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1722),org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java: 4 04),org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234),sun.reflect.GeneratedMethodAccessor419.invoke(Unknown Source),sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43),java.lang.reflect.Method.invoke(Method.java:497),org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory $ 1.invoke(ResourceMethodInvocationHandlerFactory.java:81),org.glassfish.jersey。 server.model.internal.AbstractJavaResourceMethodDispatcher $ 1.run(AbstractJavaResourceMethodDispatcher.java:151),org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171),org.glassfish.jersey.server.model .internal.JavaResourceMethodDispatcherProvider $ ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152),org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDisp atcher.java:104),org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:387),org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:331),org .glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:103),org.glassfish.jersey.server.ServerRuntime $ 1.run(ServerRuntime.java:271),org.glassfish.jersey.internal.Errors $ 1 .call(Errors.java:271),org.glassfish.jersey.internal.Errors $ 1.call(Errors.java:267),org.glassfish.jersey.internal.Errors.process(Errors.java:315),org .glassfish.jersey.internal.Errors.process(Errors.java:297),org.glassfish.jersey.internal.Errors.process(Errors.java:267),org.glassfish.jersey.process.internal.RequestScope.runInScope (RequestScope.java:297),org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254),org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028),org.glassfish。 jersey.grizzly2.httpserver.GrizzlyHttpContainer.se rvice(GrizzlyHttpContainer.java:365),org.glassfish.admin.rest.adapter.JerseyContainerCommandService $ 3.service(JerseyContainerCommandService.java:173),org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179 ),com.sun.enterprise.v3.services.impl.ContainerMapper $ HttpHandlerCallable.call(ContainerMapper.java:459),com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167), org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201),org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175),org.glassfish.grizzly.http。 server.HttpServerFilter.handleRead(HttpServerFilter.java:235),org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119),org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284 ),org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201),org.glassfish.grizzly.filterchain.DefaultFilter Chain.execute(DefaultFilterChain.java:133),org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112),org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77),org.glassfish .grizzly.portunif.PUFilter.handleRead(PUFilter.java:231),org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119),org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain。 java:284),org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201),org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133),org.glassfish.grizzly.filterchain .DefaultFilterChain.process(DefaultFilterChain.java:112),org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77),org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231),org。 glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119),org.glassfish。 grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284),org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201),org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java: 133),org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112),org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77),org.glassfish.grizzly.nio.transport.TCPNIOTransport .fireIOEvent(TCPNIOTransport.java:561),org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112),org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117),org。 glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:56),org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137),org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker .doWor k(AbstractThreadPool.java:565),org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:545),java.lang.Thread.run(Thread.java:745)] Parent - > org.glassfish.internal.api.DelegatingClassLoader@7cbe8ac6  在从以下堆栈跟踪调用完成后,请求查找类org.bson.codecs.EncoderContext $ 1 java.lang.Throwable中     at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:825)     在com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)     at org.bson.codecs.EncoderContext。(EncoderContext.java:27)     at org.bson.codecs.EncoderContext $ Builder.build(EncoderContext.java:67)     在com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:168)     在com.mongodb.connection.CommandMessage.encodeMessageBody(CommandMessage.java:69)     在com.mongodb.connection.RequestMessage.encode(RequestMessage.java:132)     在com.mongodb.connection.CommandHelper.sendMessage(CommandHelper.java:88)     在com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)     在com.mongodb.connection.DefaultServerMonitor $ ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:186)     在com.mongodb.connection.DefaultServerMonitor $ ServerMonitorRunnable.run(DefaultServerMonitor.java:134)     在java.lang.Thread.run(Thread.java:745) ]

错误消息图片:

error part 1 enter image description here

编辑:

来自Payara Server github issue的人帮我找到了问题。我在部署之前使用了ServletContextListener来杀死mongo连接。现在,我等待一段时间,看看问题是否已经解决。代码如下:

@Log
@WebListener
public class AppServletContextListener implements ServletContextListener {
    @Inject
    MongoClientProvider mongo;

    @Override
    public void contextDestroyed(ServletContextEvent arg) {
        log.info("ServletContextListener destroyed");
        DbUtils.closeMongoConnections(mongo);
    }

    @Override
    public void contextInitialized(ServletContextEvent arg) {
        log.info("ServletContextListener started");
    }
}

public class DbUtils {
    public static void closeMongoConnections(MongoClientProvider mongo) {
        mongo.getDeletedGroups().getManager().close();
        mongo.getMessages().getManager().close();
        mongo.getGameficationInfos().getManager().close();
        mongo.getDgsa().getManager().close();
        mongo.getRisa().getManager().close();
        mongo.getExpiredEmailLinks().getManager().close();
    }
}

1 个答案:

答案 0 :(得分:1)

你已经从错误中删除了有用位,但它出现在你的屏幕截图中。在AT Tue Jan 12 19:34:31 UTC 2016部分之前会有一点,它会告诉您错误来自ASURLClassLoader,告诉您有关类加载器状态的信息。

关键部分是图像中的最后一行:

...
was requested to find class org.bson.codecs.EncoderContext$1 after done was invoked from the following stack trace

它所讨论的done()方法是一个清理方法,当类加载器准备好进行垃圾回收时调用该方法。所以,此时,EncoderContext类正在尝试加载一个类,但它到达的ASURLClassLoader在被标记为清理但尚未清理之前处于这种状态。

之前我见过类似的问题,我正在调查Payara Server,它来自GlassFish。如果您可以在Payara Github存储库中提出问题,我将非常感激: https://github.com/payara/Payara/issues

,这可能是一个错误GlassFish和似鲭水狼牙鱼服务器所以大概不恰当的详尽的讨论在Q&安培;一个站点̶

编辑:实际上,仔细查看ASURLClassLoader堆栈(大屏幕截图),因为取消部署而调用了done()。因此可能是MongoDB是从一个未部署的应用程序中调用的,并且MongoDB没有被同时处理掉。

这可能是您想要的,但在这种情况下,不应该从应用程序中创建MongoDB资源。否则,在取消部署应用程序之前,需要将其正确销毁。