未授权的数据库锁类型:-1

时间:2012-01-27 13:59:32

标签: java authentication mongodb morphia

使用MongoDB进行beta测试模式的流行托管之一。

本地我的应用程序运行正常。但在托管部署后,我遇到了以下问题:

Tomcat的:

    Jan 27, 2012 1:24:32 PM org.apache.catalina.core.ApplicationContext log 
SEVERE: Exception while dispatching incoming RPC call 
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract void ...' threw an unexpected exception: com.mongodb.MongoException: unauthorized db:mongodb-logger lock type:-1 client:192.168.23.159 
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:306)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322)
at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:1688)
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) 
Caused by: com.mongodb.MongoException: unauthorized db:mongodb-logger lock type:-1 client:192.168.23.159 
at com.mongodb.MongoException.parse(MongoException.java:82) 
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:312) 
at com.mongodb.DBCursor._check(DBCursor.java:369) 
at com.mongodb.DBCursor._hasNext(DBCursor.java:498) 
at com.mongodb.DBCursor.hasNext(DBCursor.java:523) 
at com.google.code.morphia.query.MorphiaIterator.hasNext(MorphiaIterator.java:40)
at com.google.code.morphia.query.QueryImpl.asList(QueryImpl.java:234) 
... 
... 27 more

Jan 27, 2012 1:24:32 PM org.apache.catalina.core.ApplicationContext log

蒙戈:

Fri Jan 27 13:24:32 [initandlisten] connection accepted from 192.168.23.159:36649 #142 
Fri Jan 27 13:24:32 [conn142] assertion 10057 unauthorized db:mongodb-logger lock type:-1 client:192.168.23.159 ns:mongodb-logger.....com.User query:{ login: "admin" }

代码:

       mongo = new Mongo(databaseHost, databasePort);
       db = mongo.getDB(databaseName);
       boolean auth = db.authenticate(databaseUser, databasePassword);

工作正常。 auth = true。

    Morphia morphia = new Morphia();
    datastore = morphia.createDatastore(mongo, databaseHost);

也可以。

在首次查询期间看起来出现问题。

有什么建议吗?

PS:

本地数据库版本:2.0.2

托管db版本:1.8

https://jira.mongodb.org/browse/SERVER-2917

2 个答案:

答案 0 :(得分:1)

我写了一个简单的repro但是没有成功运行它有任何问题。

public static void main(String[] args) throws UnknownHostException, MongoException {
    Mongo mongo = new Mongo();
    DB db = mongo.getDB("test");
    boolean auth = db.authenticate("scott", "scott".toCharArray());
    DBCollection coll = db.getCollection("myWords");
    DBObject dbObj = (DBObject) JSON.parse("{ \"_id\" : 1.0 , \"words\" : [ \"a\" , \"b\" , \"c\"] , \"score\" : 1.1 , \"data\" : \"foo\"}");
    coll.insert(dbObj);
    System.out.print(coll.findOne().toString());

    Morphia morphia = new Morphia();
    Datastore datastore = morphia.createDatastore(mongo, "test");
    Word w = datastore.find(Word.class).get();
    System.out.print(w);

}

@Entity("myWords")
static class Word {
    @Id Double id;
    ArrayList<String> words = new ArrayList<String>();
    Double score;
    String data;

    @Override
    public String toString() {
        return this.id.toString();
    }


}

导致了这个:

{ "_id" : 1.0 , "words" : [ "a" , "b" , "c"] , "score" : 1.1 , "data" : "foo"} 
...
1.0

这似乎是正确的事情。你能运行这段代码,但用你的db / user / password代替吗?

答案 1 :(得分:0)

我和Mongolab有同样的问题。

org.springframework.data.mongodb.UncategorizedMongoDbException:未经授权的db:bacon lock类型:-1 client:YYY;嵌套异常是com.mongodb.MongoException:未经授权的db:bacon锁类型:-1 client:YYY     org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:70)     org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:1538)

如果是本地的,可能是PC,路由器或有线电视提供商的防火墙问题。

已修复对我来说,McAfee Host Intrusion Prevention(McAfeeFire.exe)要求STS.exe和Java能够访问Mongolab等远程主机。那很有效!