5

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

Dmitry
  • 2,943
  • 1
  • 23
  • 26
Ayush Mishra
  • 567
  • 1
  • 7
  • 19

1 Answers1

4

"Too many open files" usually means that your java process is not allowed to open any more file descriptors. However if this happens at startup of jetty w/o any big amount of connections opened something weird is going on.

First of all you can check the configured soft limit of allowed open files (or filedescriptors) by executing: $ ulimit -a on your commandline.

Please paste the results to here if you need further access.

Then you can use tools like lsof to check what files your java process failing with the given exception above has opened at that time. $ lsof -p <pid> where pid is the processId of your java/jetty process should give you some hints.

If your soft limit is just too small try raising it by following one of the many tutorials found in the internet like: http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/ (first result I found) to raise the limit to something appropriate. What value will fit your application mainly depends on the amount of concurrent open connections you'll serve.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
Thomas Becker
  • 934
  • 8
  • 16
  • Thanks for your reply . I have checked my ulimit . It is already unlimited . – Ayush Mishra Apr 25 '13 at 17:42
  • Then please use lsof as described above to check what files are opened by your jvm when this error occurs. – Thomas Becker Apr 26 '13 at 11:33
  • 1
    I encountered a similar problem upgrading from jetty 6 to 8. It seems jetty 8 does *something* that opens lots of files (though it doesn't seem any slower). I took the following two steps to resolve the issue: 1) remove the default webapps and contexts that come embedded as part of the jetty 8 install 2) up the soft files limit 4096 and the hard files limit to 10240 – Taylor Aug 13 '13 at 16:54
  • Thanks @Taylor, your suggestion worked for me as well! – idrositis Feb 19 '19 at 13:26