java.lang.ClassNotFoundException: org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory

StackOverflow https://stackoverflow.com/questions/23447443

  •  14-07-2023
  •  | 
  •  

Question

When I publish an application on a server GlassFish 4.0, I am getting following exception:

Caused by: java.lang.RuntimeException: 
com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.ExceptionHandlerFactory' was not configured properly.     
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:273)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5362)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:743)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5898)
... 44 more Caused by: com.sun.faces.config.ConfigurationException:
Factory 'javax.faces.context.ExceptionHandlerFactory' was not configured properly.  
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:330)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:435)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
... 47 more Caused by: javax.faces.FacesException:
org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory  
at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:710)
at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:572)
at javax.faces.FactoryFinder.access$500(FactoryFinder.java:140)     
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1120)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)     
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
... 50 more Caused by: java.lang.ClassNotFoundException:
org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory  
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1761)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1611)
at java.lang.Class.forName0(Native Method)  
at java.lang.Class.forName(Class.java:270)  
at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:685)
... 55 more

How do I fix the error?

Was it helpful?

Solution

java.lang.ClassNotFoundException: org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory

The ClassNotFoundException means that the mentioned class, or at least the JAR file containing the mentioned class, isn't present in the current runtime classpath.

When deployed as a WAR file, the webapp's runtime classpath covers among others the following paths:

  • WAR's /WEB-INF/classes - for loose .class files (usually, IDE will do it automatically for source files in the src folder of the project).
  • WAR's /WEB-INF/lib - for JAR files (if you're not using a dependency management framework such as Maven, then you need to manually drop JARs there).
  • Server's /lib folder - for server-specific libraries, or for libraries which needs to be shared across all webapps (folder name depends on server used).
  • JRE's (or JDK's) /lib and /lib/ext folders - never ever put anything there, unless you need to fix some bugs in JRE/JDK itself.

Usually, you only go for the first two options. Do it in the WAR only and not elsewhere.

The package name of the mentioned class, org.omnifaces, hints that it's part of OmniFaces. You can download the JAR over there and according to its installation instructions, you need to drop it in /WEB-INF/lib.


As per your comment:

The problem was solved after I added in src/main/webapp/WEB-INF/lib several libraries - omnifaces-1.7.jar and primefaces-4.0.jar. Although these libraries were in classpath. Not sure about this decision optimal.

Sorry, but what you're stating there is just not true. The exception clearly tells that they were not in the classpath. ClassNotFoundException. Simple as that. At least not in the webapp's runtime classpath in any of the aforementioned paths. Most likely you incorrectly assumed the %CLASSPATH% environment variable, or the Build Path property of the project for the webapp's runtime classpath.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top