Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext


Posted on : Tue, 15th Sep 15 08:33 am UTC
2314 votes
Stack Trace : 

SEVERE: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/Users/user/Workspace/struts2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2/WEB-INF/lib/struts2-core-2.3.20.1.jar!/struts-default.xml:82:179


Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
	at java.lang.Class.getDeclaredConstructors(Class.java:2012)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:237)
	... 20 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
	... 24 more

Sep 15, 2015 1:57:12 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/Users/user/Workspace/struts2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2/WEB-INF/lib/struts2-core-2.3.20.1.jar!/struts-default.xml:82:179


Caused by: Unable to load configuration. - bean - jar:file:/Users/user/Workspace/struts2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2/WEB-INF/lib/struts2-core-2.3.20.1.jar!/struts-default.xml:82:179
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
	at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
	... 14 more

Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/Users/user/Workspace/struts2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2/WEB-INF/lib/struts2-core-2.3.20.1.jar!/struts-default.xml:82:179
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:247)
	at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:240)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
	... 17 more

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
	at java.lang.Class.getDeclaredConstructors(Class.java:2012)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:237)
	... 20 more

Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
	... 24 more

Solution : It seems like you have missed to add commons-fileupload-x.x.x.jar dependency jar in your WEB-INF/lib folder, just add this jar, do a clean + build and things should work fine.

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +