3

In one of my project , I have used Lift 2.5 M4 and Scala 2.10.0 . In this project , I am using Jetty 8.1.10.v20130312 . But while running project through mvn jetty , I am getting unexpected exception .

I have configured jetty plugin in pom.xml in below way :

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>8.1.10.v20130312</version>
            <configuration>
                <systemProperties>
                    <systemProperty>
                        <name>org.apache.cocoon.log4j.loglevel</name>
                        <value>WARN</value>
                    </systemProperty>
                </systemProperties>
                <connectors>
                    <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                        <port>9090</port>
                        <maxIdleTime>30000</maxIdleTime>
                    </connector>
                </connectors>
                <webApp>
                    <contextPath>/</contextPath>
                </webApp>
                <scanIntervalSeconds>0</scanIntervalSeconds>
                <stopKey>stop</stopKey>
                <stopPort>9999</stopPort>
            </configuration>
</plugin>

I am getting below exception while running command :- mvn org.mortbay.jetty:jetty-maven-plugin:run

2013-04-24 06:49:39.216:WARN:oeja.AnnotationParser:EXCEPTION java.io.FileNotFoundException: /home/ayush/scala-lift/knolgame/target/classes/com/knolgame/lib/TransactionStatus$$anonfun$find$1.class (Too many open files) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(FileInputStream.java:106) at org.eclipse.jetty.util.resource.FileResource.getInputStream(FileResource.java:286) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:754) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:747) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:747) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:747) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:747)

But When I am using jetty 6.1.25 , It works fine .

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.25</version>
            <configuration>
                <systemProperties>
                    <systemProperty>
                        <name>org.apache.cocoon.log4j.loglevel</name>
                        <value>WARN</value>
                    </systemProperty>
                </systemProperties>
                <connectors>
                    <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                        <port>9090</port>
                        <maxIdleTime>30000</maxIdleTime>
                    </connector>
                </connectors>
                <contextPath>/</contextPath>
                <scanIntervalSeconds>0</scanIntervalSeconds>
                <stopKey>stop</stopKey>
                <stopPort>9999</stopPort>
            </configuration>
</plugin>

Can anyone help me to resolve this ? I have to use latest Lift , Scala and jetty version in my application .

Thanks in advance .

Regards, Ayush

4

1 回答 1

3

“打开的文件太多”通常意味着您的 java 进程不允许打开更多的文件描述符。但是,如果这发生在码头启动时没有打开任何大量连接,那么就会发生一些奇怪的事情。

首先,您可以通过$ ulimit -a在命令行上执行:检查允许的打开文件(或文件描述符)的配置软限制。

如果您需要进一步访问,请将结果粘贴到此处。

然后,您可以使用工具lsof来检查您的 java 进程因上述给定异常而失败的文件当时打开了哪些文件。$ lsof -p <pid>其中 pid 是你的 java/jetty 进程的 processId 应该给你一些提示。

如果您的软限制太小,请尝试按照互联网上的众多教程之一来提高它,例如:http ://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open- files/(我发现的第一个结果)将限制提高到适当的值。适合您的应用程序的值主要取决于您将服务的并发打开连接的数量。

于 2013-04-24T13:37:01.240 回答