I did add conventions plug-in, From: Ken McWilliams <ken.mcwilli...@gmail.com> To: Struts Users Mailing List <user@struts.apache.org>; john lee <sh_thorn_b...@yahoo.com> Sent: Wednesday, July 19, 2017 4:52 PM Subject: Re: struts2 +rest service problem As mentioned in the other thread have you added the conventions plug-in?
The indicated error indicates a failure of Struts2 to be able to find what it needs so your posted source should not be at issue. On Wed, Jul 19, 2017 at 3:13 PM, john lee <sh_thorn_b...@yahoo.com.invalid> wrote: Please help for the struts2 + rest service http://beta-dev/ecommerce/ employee.xml return the following error report Struts Problem Report Struts has detected an unhandled exception: | Messages: | - com.thoughtworks.xstream. XStream - com/thoughtworks/xstream/ XStream - java.lang.reflect. InvocationTargetException - java.lang.RuntimeException: java.lang.reflect. InvocationTargetException - java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect. InvocationTargetException - java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect. InvocationTargetException | | File: | org/apache/catalina/loader/ WebappClassLoader.java | | Line number: | 1,714 | Stacktraces java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect. InvocationTargetException com.opensymphony.xwork2. inject.ContainerImpl$ MethodInjector.inject( ContainerImpl.java:301) com.opensymphony.xwork2. inject.ContainerImpl.inject( ContainerImpl.java:492) com.opensymphony.xwork2. inject.ContainerImpl$6.call( ContainerImpl.java:530) source code: cat Employee*.java package xyz; import xyz.*; import java.util.Map; import org.apache.struts2.rest. DefaultHttpHeaders;import org.apache.struts2.rest. HttpHeaders;import com.opensymphony.xwork2. ModelDriven;public class EmployeeController implements ModelDriven<Object>{ private static final long serialVersionUID = 1L; private String id; private Object model; private EmployeeRepository employeeRepository = new EmployeeRepository(); private static Map<String,Employee> map; { map = employeeRepository. findAllEmployee(); } public HttpHeaders index() { model = map; return new DefaultHttpHeaders("index"). disableCaching(); } public String add(){ Integer empId = Integer.parseInt(id); Employee emp = new Employee(empId,"Ramesh", "PQR"); model = emp; return "SUCCESS"; } public String getId() { return id; } public void setId(String id) { model = employeeRepository. getEmployeeById(id); this.id = id; } @Override public Object getModel() { return model; }} package xyz; import java.util.*;import xyz.*; public class Employee { private Integer id; private String name; private String company; public Employee(Integer id, String name, String company){ this.id =id; this.name = name; this.company = company; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCompany() { return company; } public void setCompany(String company) { this.company = company; }} package xyz; import java.util.*;import java.sql.Timestamp;import xyz.*; import java.util.HashMap;import java.util.Map; public class EmployeeRepository { private static Map<String,Employee> map = new HashMap<String,Employee>(); public EmployeeRepository(){ map.put("111", new Employee(111, "Ram", "ABC")); map.put("222", new Employee(222, "Shyam", "EFG")); map.put("333", new Employee(333, "Mohan", "XYZ")); } public Employee getEmployeeById(String id){ return map.get(id); } public Map<String,Employee> findAllEmployee(){ return map; }} my configuration for struts.xml <include file="struts-default.xml"/> <!-- rest and regular coexist--> <constant name="struts.action.extension" value="xhtml,,xml,json,action" /> <constant name="struts.mapper.class" value="rest" /> <constant name="struts.mapper.class" value="org.apache.struts2. dispatcher.mapper. PrefixBasedActionMapper" /> <constant name="struts.mapper. prefixMapping" value="/rest:rest,:struts"/> <constant name="struts.convention. action.suffix" value="Controller"/> <constant name="struts.convention. action.mapAllMatches" value="true"/> <constant name="struts.convention. default.parent.package" value="rest-default"/> <constant name="struts.convention. package.locators" value="example"/> -- Sent from my C64 using a 300 baud modem