当前位置: 首页 > 知识库问答 >
问题:

等待与WritableServerSelector匹配的服务器时在30000 ms后超时

孔鸿宝
2023-03-14
   MongoClient mongoClient = new MongoClient();

    // Now connect to your database
    DB db = mongoClient.getDB("test");
    System.out.println("connect to database successfully");

    DBCollection coll = db.createCollection("mycol", null);
    System.out.println("Collection created successfully");

    DBCollection colReceived = db.getCollection("mycol");
    System.out.println("Collection mycol selected successfully");

    BasicDBObject doc = new BasicDBObject("title", "MongoDB").append("description", "database").append("likes", 100)
            .append("url", "http://www.tutorialspoint.com/mongodb/").append("by", "tutorials point");

    colReceived.insert(doc);
    System.out.println("Document inserted successfully");

我的pom.xml:

  <project xmlns="http://maven.apache.org/POM/4.0.0"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.objectdb.tutorial.spring</groupId>
<artifactId>Guestbook</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>Guestbook</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
    <repository>
        <id>objectdb</id>
        <name>ObjectDB Repository</name>
        <url>http://m2.objectdb.com</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.objectdb</groupId>
        <artifactId>objectdb</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>aopalliance</groupId>
        <artifactId>aopalliance</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.6.10</version>
    </dependency>

    <dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.2.2</version>
</dependency>


</dependencies>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>enhance</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.objectdb.Enhancer</mainClass>
                            <arguments>
                                <argument>guest.Guest</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.10</version>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <stopKey>foo</stopKey>
                    <stopPort>9999</stopPort>
                </configuration>
                <executions>
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <scanIntervalSeconds>0</scanIntervalSeconds>
                            <daemon>true</daemon>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
    <finalName>Guestbook</finalName>
</build>

共有1个答案

万开畅
2023-03-14

如果你的mongod日志中也有以下错误...(或类似)

错误:日志文件可用空间不足请在/var/lib/mongoDb/journal中至少提供3379MB,或者使用--smallfiles

您可以通过将mongo作为mongod--smallfiles运行来修复此错误

 类似资料:
  • 我正在mongo服务器上尝试简单的CRUD,我得到了这个 MongotieOutException:在等待与WritableServerSelector匹配的服务器时,在30000 ms后超时。群集状态的客户端视图为{type=replica_set,servers=[{address=mongod.mydomain.com:27017,type=replica_set_secondary,rou

  • 我已经在我的Windows7机器上安装了WebLogic12C(12.1.3)。在创建管理服务器并登录之后,我试图创建一个新的托管服务器。但是当我按下create按钮时,显示加载符号需要花费大量时间,最后给出等待完成的错误超时:Activate state:STATE_DISTRIBUTED Target Servers states:AdminServer STATE_DISTRIBUTED。早

  • 无法启动边缘驱动程序,我得到下面提到的错误和代码,我使用的是下面。请帮忙

  • 在遵循WebDriverJs留档的“入门”部分中的说明并从他们的网站运行此片段后: 我得到这个错误: 我正在使用这里找到的ChromeDriver的mac32版本运行OSX Mavericks。chromedriver可执行文件位于my目录下,可以在my路径下访问。 我注意到的一点是,当我从命令行运行chromedriver时,它在端口9515上运行,而节点代码在60065上查找它。然而,仅仅使用

  • 问题内容: 我正在测试AngularJS应用程序,并且对量角器非常新。每次我打开浏览器时,它都会打开,然后等待超时,然后在cmd上引发以下错误。 我尝试增加超时限制,但始终会收到此错误。我也尝试过使用所有这些: 该页面正确加载,并且如果我使用Eclipse和Selenium与按钮对象进行交互,则可以正常工作。 只有量角器出现同步问题。请帮忙。 问题答案: 量角器超时的可能原因: 您的网页未以预期的

  • 我已经尝试了Stackoverflow主题中告诉我的一切。我通过jenkins在远程从机上运行java selenium测试。荒谬的是,第一个测试总是运行,浏览器打开,所有其他测试都给我“等待驱动服务器启动超时”。 错误: 到目前为止我尝试过的所有解决方案: 更新Java1_8_271 更新硒4 更新ChromeDriver 87 用rawcap检查localhost流量 检查localhostd