0

I am building Resteasy services with MongoDb as the database.

It works perfectly on my Mac but on Fedora 15 of the test server, it raises a error as following:

    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]

The code which access db is :

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

Using Mongo driver 2.7.0 and mongodb server 2.0.0

2 Answers 2

1
java.io.IOException: couldn't connect to [eid/67.215.65.132:27017] bc:java.net.ConnectException: Connection timed out

It seems that your DB client could not connect to the MongoDB server. A few things to investigate:

  • Make sure that your DB server is up and running.

  • Use the mongo shell to verify that your MongoDB server is fully operational.

  • 67.215.65.132 is a public IP address. localhost should normally resolve to the loopback interface with an address of 127.0.0.1 or similar. Try using 127.0.0.1 directly, since using the public IP may imply the existence of firewall rules that block access to the DB server port. The connection timing out instead of being refused make this scenario quite probable.

Sign up to request clarification or add additional context in comments.

2 Comments

DB is up and running, mongo shell is working fine, 127.0.0.1 gives me the same result. I don't know where 67.215.65.132 comes from :(
The error just disappears after I re-install the whole server and use 127.0.0.1 this time.... Thanks for your help :)
0

See here. For example, you are using OpenDNS which returns this IP for unknown host.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.