Я создаю службы Resteasy с MongoDb в качестве базы данных.
Он отлично работает на моем Mac, но на Fedora 15 тестового сервера выдает ошибку следующим образом:
07:20:15,060 WARNING [com.mongodb.tcp] (http--0.0.0.0-8000-1) Exception determining maxBSON size using0: java.io.IOException: couldn't connect to [eid/67.215.65.132:27017] bc:java.net.ConnectException: Connection timed out
at com.mongodb.DBPort._open(DBPort.java:228) [mongo-2.7.0.jar:]
at com.mongodb.DBPort.go(DBPort.java:112) [mongo-2.7.0.jar:]
at com.mongodb.DBPort.go(DBPort.java:93) [mongo-2.7.0.jar:]
at com.mongodb.DBPort.findOne(DBPort.java:146) [mongo-2.7.0.jar:]
at com.mongodb.DBPort.runCommand(DBPort.java:157) [mongo-2.7.0.jar:]
at com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize(DBTCPConnector.java:457) [mongo-2.7.0.jar:]
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:444) [mongo-2.7.0.jar:]
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:209) [mongo-2.7.0.jar:]
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305) [mongo-2.7.0.jar:]
at com.mongodb.DBCursor._check(DBCursor.java:369) [mongo-2.7.0.jar:]
at com.mongodb.DBCursor._hasNext(DBCursor.java:498) [mongo-2.7.0.jar:]
at com.mongodb.DBCursor.hasNext(DBCursor.java:523) [mongo-2.7.0.jar:]
at eid.ariel.TestService.getAllUsers(TestService.java:39) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_22]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_22]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_22]
at java.lang.reflect.Method.invoke(Method.java:616) [:1.6.0_22]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.2.1.GA.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.2.1.GA.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at java.lang.Thread.run(Thread.java:679) [:1.6.0_22]
Код доступа к БД:
public List<DBObject> getAllUsers() throws UnknownHostException, MongoException, FileNotFoundException{
Mongo mongo = new Mongo("localhost");
DBCollection collection = mongo.getDB("eid_security_dev").getCollection("users");
DBCursor cur = collection.find();
List<DBObject> result = new ArrayList<DBObject>();
while (cur.hasNext()){
result.add(cur.next());
}
return result;
}
Использование драйвера Mongo 2.7.0 и сервера mongodb 2.0.0