Skip to content
Abhishek Khare edited this page Aug 16, 2017 · 5 revisions

Functional programming

In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions[1] or declarations[2] instead of statements. In functional code, the output value of a function depends only on the arguments that are passed to the function, so calling a function f twice with the same value for an argument x will produce the same result f(x) each time; this is in contrast to procedures depending on a local or global state, which may produce different results at different times when called with the same arguments but a different program state. Eliminating side effects, i.e. changes in state that do not depend on the function inputs, can make it much easier to understand and predict the behavior of a program, which is one of the key motivations for the development of functional programming.

Class Loader

  • CL1

  • CL2

  • A common reason for same classes present in more than one classloader is when different versions of the same library is bundled in different places–e.g. the application server and the web application. This typically happens with de facto standard libraries like log4j or hibernate. In that case the solution is either unbundling the library from the web application or taking painstaking care to avoid using the classes from the parent classloader.

  • ClassNotFoundException is an exception that occurs when you try to load a class at run time using Class.forName() or loadClass() methods and mentioned classes are not found in the classpath.

  • NoClassDefFoundError is an error that occurs when a particular class is present at compile time, but was missing at run time.

Class Loader Problems and solution

  • NoClassDefFoundError - Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

To figure out where the resources are loaded from is to use jconsole utility to attach to the container JVM process in order to inspect the class path.

  • NoSuchMethodError - Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

We can use javap utility to decompile the class – then we can see if the required method actually exists or not. javap -private {fully qualified path}/HelloWorldService.class

  • LinkageError - Subclasses of LinkageError indicate that a class has some dependency on another class; however, the latter class has incompatibly changed after the compilation of the former class.

  • IllegalAccessError - Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

Clone this wiki locally