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


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 adding 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.




Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.