Mongo异步线程在安全管理器权限上随机失败

时间:2015-12-08 20:41:52

标签: java mongodb security

我们使用带有RXJava和Vert.x的Mongodb异步驱动程序3.0.4来避免阻塞事件循环线程。

我们执行MongoDB的代码如下:

wasFound

有时,我以后会例外。

对于调试,我在我的java策略(默认策略)文件的末尾添加了允许所有权限的行,但是我没有改变任何东西,我仍然有一些压力加载异常。当Vert.x调用setContextClassLoader时,我还有另外一个例外(消息中也有异常)。

           myCollection.bulkWrite(myList, new SingleResultCallback<BulkWriteResult>() {
                @Override
                public void onResult(BulkWriteResult bulkWriteResult, Throwable throwable) {
                    if (throwable == null) {
                        subscriber.onNext(bulkWriteResult.getInsertedCount());
                        subscriber.onCompleted();
                        MyLogger.debug("Success"); 
                    } else {
                        MyException myException = new MyException(throwable);
                        subscriber.onError(myException);
                        MyLogger.error("Success"); 
                    }
                }

仅在Mongodb异步线程中发生。我在异步模式下使用CXF,一切正常。使用mongodb,这个问题是随机的。

欢迎任何帮助。

此致

  grant {
    permission java.security.AllPermission;
  }

setContextClassLoader异常:

    java.security.AccessControlException: access denied ("java.io.FilePermission" "/var/logs/myLogFile.log" "read")
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
        at java.security.AccessController.checkPermission(AccessController.java:884)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
        at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
        at java.io.File.length(File.java:969)
        at ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy.isTriggeringEvent(SizeBasedTriggeringPolicy.java:59)
        at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:177)
        at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103)
        at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88)
        at ch.qos.logback.core.sift.SiftingAppenderBase.append(SiftingAppenderBase.java:111)
        at ch.qos.logback.core.AppenderBase.doAppend(AppenderBase.java:85)
        at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)
        at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:273)
        at ch.qos.logback.classic.Logger.callAppenders(Logger.java:260)
        at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:442)
        at ch.qos.logback.classic.Logger.filterAndLog_1(Logger.java:414)
        at ch.qos.logback.classic.Logger.info(Logger.java:604)
      ..................................
      ..................................
        at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
        at com.mongodb.async.client.MongoClientImpl$2$2.onResult(MongoClientImpl.java:144)
        at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
        at com.mongodb.operation.OperationHelper$ConnectionReleasingWrappedCallback.onResult(OperationHelper.java:140)
        at com.mongodb.operation.MixedBulkWriteOperation$3.onResult(MixedBulkWriteOperation.java:208)
        at com.mongodb.operation.MixedBulkWriteOperation$3.onResult(MixedBulkWriteOperation.java:187)
        at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
        at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor$1.onResult(DefaultServer.java:171)
        at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:53)
        at com.mongodb.connection.InsertCommandProtocol$1.onResult(InsertCommandProtocol.java:86)
        at com.mongodb.connection.InsertCommandProtocol$1.onResult(InsertCommandProtocol.java:79)
        at com.mongodb.connection.WriteCommandProtocol.executeBatchesAsync(WriteCommandProtocol.java:154)
        at com.mongodb.connection.WriteCommandProtocol.access$000(WriteCommandProtocol.java:37)
        at com.mongodb.connection.WriteCommandProtocol$1.onResult(WriteCommandProtocol.java:145)
        at com.mongodb.connection.WriteCommandProtocol$1.onResult(WriteCommandProtocol.java:123)
        at com.mongodb.connection.CommandResultCallback.callCallback(CommandResultCallback.java:54)

0 个答案:

没有答案