Re: struts2 +rest service problem
2017-07-19 23:13 GMT+02:00 john lee: > 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) In most cases this means you have multiple versions of the same Struts JAR on classpath. Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2 +rest service problem
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{ 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 -- Sent from my C64 using a 300 baud modem
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 leewrote: > > 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{private > static final long serialVersionUID = 1L;private String id; > private Object model;private EmployeeRepository employeeRepository > = new EmployeeRepository();private static Map > 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;}@Overridepublic 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 map = new HashMap (); 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 > findAllEmployee(){return map;}} > > my configuration for struts.xml > > > > > > >/> > > > > > > > > > > > >value="/rest:rest,:struts"/> > > > > > >value="rest-default"/> > > > > > > > -- Sent from my C64 using a 300 baud modem
struts2 +rest service problem
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{ private static final long serialVersionUID = 1L; private String id; private Object model; private EmployeeRepository employeeRepository = new EmployeeRepository(); private static Mapmap; { 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 map = new HashMap (); 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 findAllEmployee(){ return map; }} my configuration for struts.xml