Skip to main content

NoClassDefFoundError

Recently I faced with NoClassDefFoundErrors during unit testing despite all class files were in place. It was quite strange. Furthermore this error happened only on our CI (Linux) server, I couldn't reproduce it on desktop, neither on Windows nor on Linux.

I started to investigate the stack traces and it seemed that the native open method of the FileInputStream was failed. After more investigation by JProfiler I found, that many classLoader.getResourceAsStream invocation happens in our code, but those streams are never closed.

Meanwhile I found this nice writing about Tuning Linux applications which says: "Some Linux applications; for example, a JVM, might require a higher file descriptor limit. If an application can't open files because the file descriptor limit has been exceeded, you might get a NoClassDefFoundError error message."

Then it says how to increase number of file handlers (ulimit -n 2048), but let's rather close the resources guys. It would have been quite unlucky if the application starts saying NoClassDefFoundErrors in the wild after some days.

Comments

Popular posts from this blog

Client's transaction aborted

I've met the above error message using a Wicket 1.2 / EJB3 intranet application under Glassfish v2 . Here is the more particular head of the stack trace: javax.ejb.TransactionRolledbackLocalException: Client's transaction aborted at com.sun.ejb.containers.BaseContainer.useClientTx(BaseContainer.java:3394) at com.sun.ejb.containers.BaseContainer.preInvokeTx(BaseContainer.java:3274) at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1244) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:195) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127) This exception raised on the integration server sometimes, randomly, for simple page fetch operations. After pressing reload on the browser, the operation was usually successful. I couldn't reproduce the failure on the local machine where I regularly restart the app server and...

jxl.log

In an intranet production environment we have running a Glassfish v2 appserver with several J2EE applications which all use JexcelApi , a.k.a JXL, which is an open source library for accessing, generating or manipulating Microsoft Excel documents. We use version 2.6.3 of JXL because it's the recent one in the Maven repository which we use, however, at the official JXL site there are newer versions. Additionally we have log4j and Java Commons Logging (JCL), ignoring Glassfish's JSR-47 Java Util Logging (JUL) facility. Application #1 uses purely log4j and gets its log4j.xml config from a custom location. Application #2 runs Java Commons Logging with no explicite configuration file given, so JCL uses the default JUL facility of the appserver. Application #1 had been running for a long time without problems but when we installed #2 we realized that a jxl.log file had been created in the glassfish/domain/domain1/config directory and it's rapidly growing. As it happens, we ...

Setting up EJB3 default interceptor

It wasn't easy to find out how to configure a default interceptor in EJB3 environment. It's okay to make this snippet into the ejb-jar.xml: <assembly-descriptor> <interceptor-binding> <ejb-name>*</ejb-name> <interceptor-class>pkg.IC</interceptor-class> </interceptor-binding> </assembly-descriptor> Maybe everybody forget to mention maybe it's a Glassfish V2 trick that I get this error message during deployment: Interceptor binding contains an interceptor class name = pkg.IC that is not defined as an interceptor ...unless I register the interceptor class itself too with this: <interceptors> <interceptor> <interceptor-class>pkg.IC</interceptor-class> <around-invoke> <method-name>call</method-name> </around-invoke> </interceptor> </interceptors> <interceptors> and <as...