unauthorized db lock type:-1

谁说我不能喝 提交于 2019-12-22 18:10:53

问题


One of popular hosting in beta testing mode with MongoDB.

Locally my application works fine. But after deployment in hosting I have the following problem:

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

Mongo:

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" }

Code:

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

Works fine. auth = true.

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

Works fine too.

Looks like problem occurs during first query.

Any suggestions?

PS:

local db version: 2.0.2

hosting db version: 1.8

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


回答1:


I wrote a simple repro but didn't have any problem running it successfully.

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();
    }


}

Which resulted in this:

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

Which seems like the correct thing. Can you run this code, but substitute your db/user/password?




回答2:


I am getting the same issue with Mongolab.

org.springframework.data.mongodb.UncategorizedMongoDbException: unauthorized db:bacon lock type:-1 client:YYY; nested exception is com.mongodb.MongoException: unauthorized db:bacon lock type:-1 client:YYY org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:70) org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:1538)

If it's local it could be firewall issue on the PC, Router or Cable provider.

FIXED For me, McAfee Host Intrusion Prevention (McAfeeFire.exe) required a rule for STS.exe and Java to be able to access remote hosts like Mongolab. That worked!



来源:https://stackoverflow.com/questions/9034318/unauthorized-db-lock-type-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!