I am following a Struts2 tutorial. It tells me to import the listed classes. But it does not tell me which jar files to put in the lib folder under
These are the import statements that I have in my action class:
import com.opensymphony.xwork2.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import java.util.List; import javax.servlet.http.HttpServletRequest; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping;
I have the following jars in the lib folder. But apparently these are not enough.
Commons-IO 2.2 Commons-lang3-3.0 Commons-logging-1.1.3 Commons-fileupload-1.2 Freemarker-2.3.19 Javaassist- 3.12.1 GA Ognl-3.0.6 Sqljdbc4 Org.apache.commons.io-2.4 Struts2-core 2.3.16 Xwork-core 2.3.16
Can someone tell me which jars I should put in the lib folder?
In the import statement you are using servlet API. So, you need to add Java EE dependencies. But it should be available on classpath only at compile time. It means that you should add this jars to the build path but not to the
WEB-INF/lib. Servlet API jars contain in every web server which is running a servlet container. These classes already loaded by the web server before your application is deployed. And it doesn’t allowed to load them twice. That’s why you shouldn’t put them to
WEB-INF/lib. What should you use from Java EE package
javax.servlet.jar javax.servlet.jsp.jar javax.servlet.jsp.jstl.jar
You can also check this answer if you are not using Maven to get a clue about libraries used with Struts2 project.
If you are using Maven, then use this jars with the scope
provided. More details are here.
Finally, you are using Struts 1 classes in import, so if you want to use these classes with Struts2 project then you need additionally