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 To: Struts Users Mailing List ; john lee 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 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 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 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 -- 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 lee 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 > 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
Re: Struts2 Rest Mapper Taking Over Non Rest Json Result
To solve a similar issue I ended up creating my own ContentTypeHandler. As you already have a result it should be pretty easy to wrap (at least I found it so). The problem is that after doing so all JSON will be handled by your new Content type... While this link shows how to use Jackson, you can create your own implementation and then apply your own configuration in the same way: http://struts.apache.org/docs/rest-plugin.html#RESTPlugin-UseJacksonframeworkasJSONContentTypeHandler On Tue, Sep 20, 2016 at 12:34 PM, Paul Zepernick < paul.zepern...@healthsmart.com> wrote: > Thanks Martin, it was getting to the correct action class buy it was not > using the result I defined in the action. It was going to its own result > implementation based on the fact that I am requesting an application/json > data type. I found out that if I add ".action" to the url it processes > everything correctly and goes to the correct result. I am not sure if that > is the intended behavior, a setup issue on my part, or a bug? > > -Original Message- > From: Martin Gainty [mailto:mgai...@hotmail.com] > Sent: Tuesday, September 20, 2016 2:24 PM > To: Struts Users Mailing List > Subject: RE: Struts2 Rest Mapper Taking Over Non Rest Json Result > > to control navigation why not map it? className="org.healthsmart.NonRestfulAction"> name="id">{1}... > GET: /grid/method="index"when you reference /grid/ struts will call > org.healthsmart.NonRestfulAction index method https://struts.apache.org/ > docs/restfulactionmapper.html > > or use DMI > > > /WEB-INF/content/hello.jsp name="redisplay" type="redirectAction">hello > add > https://struts.apache.org/docs/action-configuration. > html#ActionConfiguration-ActionMappings > I would check struts.mapper.prefixMapping for normal "rest prefixMapping > vs struts prefixMapping" configurationhttps://struts.apache.org/docs/ > restfulactionmapper.html > if that looks ok as a last result you can implement a custom mapper which > will read the URL and redirect to correct class programaticallyhttp:// > stackoverflow.com/questions/17697432/struts2-rest-plugin-making- > both-struts-actions-rest-actions-work-together-but > Martin > __ > > > > > From: paul.zepern...@healthsmart.com > > To: user@struts.apache.org > > Subject: Struts2 Rest Mapper Taking Over Non Rest Json Result > > Date: Tue, 20 Sep 2016 15:28:42 + > > > > This was also posted to stackoverflow and relevant config information > can be seen in the post: http://stackoverflow.com/ > questions/39593721/struts2-rest-mapper-taking-over-non-rest-json-result > > > > I am working with the DataTables JS library and am trying to write > actions for the grid. I have a api in place that creates the json for me > already and I just need to stream it back. I created a custom result to > handle this, but the result mapped in the action never runs. No matter what > the result type, the REST mapper tries to handle it as soon as it sees that > application/json has been requested from the client. I have used the prefix > mapping in the configuration to have all url's using /grid to bypass the > rest mapper. It seems to be working in some capacity because it runs the > correct interceptor stack and is using the @Action annotation information > to map the url. However, the result specified is NOT running and is instead > being provided by the rest mapper based on the stack trace I am receiving. > I would like to completely bypass the rest mapper for any actions in the > /grid namespace. Have I done something wrong in the configuration that is > still causing rest to be involved in the request to those actions? > > > > Paul R. Zepernick > > Sr. Programmer Analyst > > > > > > > > > > > > > > Disclaimer: This communication and any files transmitted with it may > contain information that is privileged, confidential and/or exempt from > disclosure under applicable law. If you are not the intended recipient, you > are hereby notified that any disclosure, copying, distribution, or use of > the information contained herein (including any reliance thereon) is > strictly prohibited. If you received this communication in error, please > immediately contact the sender and destroy the material in its entirety, > whether in electronic or hard copy format. Thank you. > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Sent from my C64 using a 300 baud modem
RE: Struts2 Rest Mapper Taking Over Non Rest Json Result
Thanks Martin, it was getting to the correct action class buy it was not using the result I defined in the action. It was going to its own result implementation based on the fact that I am requesting an application/json data type. I found out that if I add ".action" to the url it processes everything correctly and goes to the correct result. I am not sure if that is the intended behavior, a setup issue on my part, or a bug? -Original Message- From: Martin Gainty [mailto:mgai...@hotmail.com] Sent: Tuesday, September 20, 2016 2:24 PM To: Struts Users Mailing List Subject: RE: Struts2 Rest Mapper Taking Over Non Rest Json Result to control navigation why not map it?{1} ... GET: /grid/method="index"when you reference /grid/ struts will call org.healthsmart.NonRestfulAction index method https://struts.apache.org/docs/restfulactionmapper.html or use DMI /WEB-INF/content/hello.jsphello add https://struts.apache.org/docs/action-configuration.html#ActionConfiguration-ActionMappings I would check struts.mapper.prefixMapping for normal "rest prefixMapping vs struts prefixMapping" configurationhttps://struts.apache.org/docs/restfulactionmapper.html if that looks ok as a last result you can implement a custom mapper which will read the URL and redirect to correct class programaticallyhttp://stackoverflow.com/questions/17697432/struts2-rest-plugin-making-both-struts-actions-rest-actions-work-together-but Martin __ > From: paul.zepern...@healthsmart.com > To: user@struts.apache.org > Subject: Struts2 Rest Mapper Taking Over Non Rest Json Result > Date: Tue, 20 Sep 2016 15:28:42 + > > This was also posted to stackoverflow and relevant config information can be > seen in the post: > http://stackoverflow.com/questions/39593721/struts2-rest-mapper-taking-over-non-rest-json-result > > I am working with the DataTables JS library and am trying to write actions > for the grid. I have a api in place that creates the json for me already and > I just need to stream it back. I created a custom result to handle this, but > the result mapped in the action never runs. No matter what the result type, > the REST mapper tries to handle it as soon as it sees that application/json > has been requested from the client. I have used the prefix mapping in the > configuration to have all url's using /grid to bypass the rest mapper. It > seems to be working in some capacity because it runs the correct interceptor > stack and is using the @Action annotation information to map the url. > However, the result specified is NOT running and is instead being provided by > the rest mapper based on the stack trace I am receiving. I would like to > completely bypass the rest mapper for any actions in the /grid namespace. > Have I done something wrong in the configuration that is still causing rest > to be involved in the request to those actions? > > Paul R. Zepernick > Sr. Programmer Analyst > > > > > > > Disclaimer: This communication and any files transmitted with it may contain > information that is privileged, confidential and/or exempt from disclosure > under applicable law. If you are not the intended recipient, you are hereby > notified that any disclosure, copying, distribution, or use of the > information contained herein (including any reliance thereon) is strictly > prohibited. If you received this communication in error, please immediately > contact the sender and destroy the material in its entirety, whether in > electronic or hard copy format. Thank you. > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Struts2 Rest Mapper Taking Over Non Rest Json Result
to control navigation why not map it?{1} ... GET: /grid/method="index"when you reference /grid/ struts will call org.healthsmart.NonRestfulAction index method https://struts.apache.org/docs/restfulactionmapper.html or use DMI /WEB-INF/content/hello.jsphello add https://struts.apache.org/docs/action-configuration.html#ActionConfiguration-ActionMappings I would check struts.mapper.prefixMapping for normal "rest prefixMapping vs struts prefixMapping" configurationhttps://struts.apache.org/docs/restfulactionmapper.html if that looks ok as a last result you can implement a custom mapper which will read the URL and redirect to correct class programaticallyhttp://stackoverflow.com/questions/17697432/struts2-rest-plugin-making-both-struts-actions-rest-actions-work-together-but Martin __ > From: paul.zepern...@healthsmart.com > To: user@struts.apache.org > Subject: Struts2 Rest Mapper Taking Over Non Rest Json Result > Date: Tue, 20 Sep 2016 15:28:42 + > > This was also posted to stackoverflow and relevant config information can be > seen in the post: > http://stackoverflow.com/questions/39593721/struts2-rest-mapper-taking-over-non-rest-json-result > > I am working with the DataTables JS library and am trying to write actions > for the grid. I have a api in place that creates the json for me already and > I just need to stream it back. I created a custom result to handle this, but > the result mapped in the action never runs. No matter what the result type, > the REST mapper tries to handle it as soon as it sees that application/json > has been requested from the client. I have used the prefix mapping in the > configuration to have all url's using /grid to bypass the rest mapper. It > seems to be working in some capacity because it runs the correct interceptor > stack and is using the @Action annotation information to map the url. > However, the result specified is NOT running and is instead being provided by > the rest mapper based on the stack trace I am receiving. I would like to > completely bypass the rest mapper for any actions in the /grid namespace. > Have I done something wrong in the configuration that is still causing rest > to be involved in the request to those actions? > > Paul R. Zepernick > Sr. Programmer Analyst > > > > > > > Disclaimer: This communication and any files transmitted with it may contain > information that is privileged, confidential and/or exempt from disclosure > under applicable law. If you are not the intended recipient, you are hereby > notified that any disclosure, copying, distribution, or use of the > information contained herein (including any reliance thereon) is strictly > prohibited. If you received this communication in error, please immediately > contact the sender and destroy the material in its entirety, whether in > electronic or hard copy format. Thank you. > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: struts2-rest-plugin issues getting non-restful urls to cooperate
Hey Ken, Can you be more specific about PUT method isn't working like it should? (some code, links to SO questions) >Struts2 has ActionSupport, it would be nice if similar interfaces already existed for the rest-result type Actually there is RestActionSupport - https://github.com/apache/struts/blob/master/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionSupport.java Although it has only index method, so having a dedicated interface for rest crud methods is a nice idea. >The documentation shows model driven, so I assume that is the suggested method of use The model driven approach is convenient, sometimes. But that's it. Nothing stops you from throwing it away and use actions w/o it. :) --- Regards, Aleksandr - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2-rest-plugin issues getting non-restful urls to cooperate
I have not forgotten about this but in setting up a project I like everything to work well, the restful urls and non-restful urls are more less happy. My issue was with POST and PUT requests. The Action uses model-driven, and with POST which calls create() all is well, while PUT which calls update() and has almost identical code did not (there are a few questions on StackOverflow with several different answers). The put method also sets an id, and then decides to use model driven. I'm not sure what I did wrong, anyways it somehow was solved out of frustration when I re-implemented org.apache.struts2.rest.handler.ContentTypeHandler to use FlexJson. So a couple observations as a first time user of the struts2-rest-plugin: - I like the Idea of this extension of conventions, adding constraints can make you think along certain tried and true methods and make work faster. - It would be nice if somehow this plugin directly required the conventions plugin such that it also was able to incorporate the convention annotations; that is, while these restful conventions are good being able to override the result with a tiles result (and all the other conventions overrides afforded with the well though out annotations provided by the conventions plugin) would be particularly interesting. - Since I couldn't get such annotations working I need non-restful urls to render the views, which then call the service provided by the rest-plugin, that really isn't a big deal. - Back to results, the rest-plugin seems to favor ContentTypeHandlers... which I was not familiar with until I ran into an issue where I didn't like what it was producing. I found that I could recycle the code of my FlexJsonResult type, if I used ActionContext to get the action (I forget why right now, but there is a difference in method arguments) then I had enough information to render what was needed. - In using the rest-plugin for crud operations, I felt the need to create interfaces so I would be forced/reminded of what needs to be implemented, Struts2 has ActionSupport, it would be nice if similar interfaces already existed for the rest-result type as there are a lot more methods which typically need to be implemented. - The documentation shows model driven, so I assume that is the suggested method of use: I really don't like how the models type is required to be Object because we are to support the index() method, which returns List while the rest of the methods return T. So there are more often than not a ternary operator in the getModel() method. On Mon, May 30, 2016 at 12:18 AM, Lukasz Lenart wrote: > 2016-05-27 17:41 GMT+02:00 Ken McWilliams : > > I got it working but I think the documentation could be made with more > > "hand holding". I'll post a "How to set up struts2 with conventions and > > both restful and non-restful urls". Then self-answer the question this > > weekend with all the configuration and project set-up steps and then post > > the link here for review, in-case there are any > differences/recommendations > > in setup. > > Great! Looking forward :) > > > Best > -- > Ł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 > > -- Sent from my C64 using a 300 baud modem
RE: struts2-rest-plugin issues getting non-restful urls to cooperate
> From: lukaszlen...@apache.org > Date: Mon, 30 May 2016 08:18:28 +0200 > Subject: Re: struts2-rest-plugin issues getting non-restful urls to cooperate > To: user@struts.apache.org > > 2016-05-27 17:41 GMT+02:00 Ken McWilliams : > > I got it working but I think the documentation could be made with more > > "hand holding". I'll post a "How to set up struts2 with conventions and > > both restful and non-restful urls". Then self-answer the question this > > weekend with all the configuration and project set-up steps and then post > > the link here for review, in-case there are any differences/recommendations > > in setup. MG>REST response will be plain HTML MG>non rest SOAP response will be XML so client will need a parser MG>DOM/SAX/StAX ??MG>thanks ken and lukasz > > Great! Looking forward :) > > > Best > -- > Ł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-plugin issues getting non-restful urls to cooperate
2016-05-27 17:41 GMT+02:00 Ken McWilliams : > I got it working but I think the documentation could be made with more > "hand holding". I'll post a "How to set up struts2 with conventions and > both restful and non-restful urls". Then self-answer the question this > weekend with all the configuration and project set-up steps and then post > the link here for review, in-case there are any differences/recommendations > in setup. Great! Looking forward :) Best -- Ł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-plugin issues getting non-restful urls to cooperate
I got it working but I think the documentation could be made with more "hand holding". I'll post a "How to set up struts2 with conventions and both restful and non-restful urls". Then self-answer the question this weekend with all the configuration and project set-up steps and then post the link here for review, in-case there are any differences/recommendations in setup. On Thu, May 26, 2016 at 1:17 PM, Aleksandr Mashchenko < amashche...@apache.org> wrote: > Working fine in my project. Can you show your project configuration? > > --- > Regards, > Aleksandr > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Sent from my C64 using a 300 baud modem
RE: struts2-rest-plugin issues getting non-restful urls to cooperate
Working fine in my project. Can you show your project configuration? --- Regards, Aleksandr - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Rest/Non-Rest Actions
2015-03-10 23:17 GMT+01:00 CRANFORD, CHRIS : > What could I missing to where I could have both RESTful and non-RESTful > action code reside in the same action class with varying annotations? I think this isn't possible, there is rest-showcase demo app, did you try it? 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 Plugin
2012/11/30 Davis, Chad : > >> I think, the basic idea was to allow cooperate the REST plugin with the >> Convention plugin and code behind is a deprecated plugin that will be >> discarded soon (with 3.x) > > 1) So, it doesn't "depend" on it, in any technical sense? Yes > 2) But it's made to work with the convention plugin, if that plugin is also > installed? Yes, but using Convention plugin with REST is the preferred way. 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 Plugin
> I think, the basic idea was to allow cooperate the REST plugin with the > Convention plugin and code behind is a deprecated plugin that will be > discarded soon (with 3.x) 1) So, it doesn't "depend" on it, in any technical sense? 2) But it's made to work with the convention plugin, if that plugin is also installed? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Rest Plugin
2012/11/28 Davis, Chad : > The docs for the REST plugin talk about how it builds on the Convention > plugin ( sometimes it says "code behind" ). However, I don't see that using > the REST plugin pulls in either of these plugins . . . in what sense does it > "build" on them? I think, the basic idea was to allow cooperate the REST plugin with the Convention plugin and code behind is a deprecated plugin that will be discarded soon (with 3.x) 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 Plugin
Just a guess but I want conventions like configuration extended though to tiles results, a lot of the work is done in ConventionUnknownHandler, it looks a bit tricky to keep that functionality without just copying it and adding changes within that code. I'm guessing that is what they did. On Wed, Nov 28, 2012 at 2:04 PM, Davis, Chad wrote: > Hi! > > The docs for the REST plugin talk about how it builds on the Convention > plugin ( sometimes it says "code behind" ). However, I don't see that > using the REST plugin pulls in either of these plugins . . . in what sense > does it "build" on them? > > Thanks, > Chad >
Re: Struts2 REST plugin: Passing array in JSON
Hi Chris, It's just: Method public java.lang.String org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on net.sf.json.JSONException: Error while setting property=arrayListStr type interface java.util.List The program crapped out in JsonLibHandler.. Shaun On Thu, Oct 11, 2012 at 12:48 PM, Chris Pratt wrote: > I was more looking for the output of all the System.out.println's > (*Chris*) > On Oct 11, 2012 12:40 PM, "Shaun Lim" wrote: > > > By the way, mapping to a simple String[] works, but I'm finding it hard > to > > believe that the plugin does not know how to handle conversions to List.. > > > > On Thu, Oct 11, 2012 at 11:54 AM, Shaun Lim > > wrote: > > > > > Method public java.lang.String > > > > > > org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) > > > threw an exception when invoked on net.sf.json.JSONException: Error > while > > > setting property=arrayListStr type interface java.util.List > > > > > > > > > On Thu, Oct 11, 2012 at 11:19 AM, Chris Pratt > >wrote: > > > > > >> What's the output of the run with this class & JSON? > > >> (*Chris*) > > >> > > >> On Thu, Oct 11, 2012 at 10:52 AM, Shaun Lim > > >> wrote: > > >> > > >> > Hi Chris, > > >> > > > >> > I did start off with a List implementation but started > > changing > > >> > stuff around in futile attempts to get something working. Anyway I > > tried > > >> > your suggestion, and am still getting the same error: > > >> > > > >> > //I've a whole bunch of different fields here cause i was testing > > >> various > > >> > things, but "arrayListStr" follows your recommendation > > >> > > > >> > public class Test { > > >> > private String name; > > >> > private String description; > > >> > private List countries; > > >> > > > >> > private String[] array; > > >> > > > >> > private TestChild testChild; > > >> > private ArrayList arrayList; > > >> > private List arrayListStr; > > >> > > > >> > public Test() { > > >> > arrayList = new ArrayList(); > > >> > arrayListStr = new ArrayList(); > > >> > } > > >> > > > >> > public String getName() { > > >> > return name; > > >> > } > > >> > > > >> > public void setName(String name) { > > >> > System.out.println("setting name"); > > >> > this.name = name; > > >> > } > > >> > > > >> > public String getDescription() { > > >> > System.out.println("getting desc"); > > >> > return description; > > >> > } > > >> > > > >> > public void setDescription(String description) { > > >> > System.out.println("settings description"); > > >> > this.description = description; > > >> > } > > >> > > > >> > public List getCountries() { > > >> > return countries; > > >> > } > > >> > > > >> > public void setCountries(List countries) { > > >> > System.out.println("settings countries"); > > >> > this.countries = countries; > > >> > } > > >> > > > >> > public TestChild getTestChild() { > > >> > return testChild; > > >> > } > > >> > > > >> > public void setTestChild(TestChild testChild) { > > >> > System.out.println("setting testchild"); > > >> > this.testChild = testChild; > > >> > } > > >> > > > >> > public String[] getArray() { > > >> > return array; > > >> > } > > >> > > > >> > public void setArray(String[] array) { > > >> > System.out.println("setting arr"); > > >> > this.array = array; > > >> > } > > >> > > > >> > public ArrayList getArrayList() { > > >> > return arrayList; > > >> > } > > >> > > > >> > public void setArrayList(ArrayList arrayList) { > > >> > System.out.println("setting arrlist"); > > >> > this.arrayList = arrayList; > > >> > } > > >> > > > >> > public List getArrayListStr() { > > >> > return arrayListStr; > > >> > } > > >> > > > >> > public void setArrayListStr(List arrayListStr) { > > >> > System.out.println("setting arrliststr"); > > >> > this.arrayListStr = arrayListStr; > > >> > } > > >> > } > > >> > > > >> > And the JSON: > > >> > > > >> > {"testChild": {"description":"kid"},"description":"whee", "name": > > >> > "foo","array":["CA","SG"],"arrayListStr":["CA","SG"]} > > >> > > > >> > Thanks for your help! > > >> > > > >> > Shaun > > >> > > > >> > On Wed, Oct 10, 2012 at 11:33 PM, Chris Pratt < > > thechrispr...@gmail.com > > >> > >wrote: > > >> > > > >> > > You *might* need to initialize the countries array. I wouldn't be > > >> > > surprised if internally the JSON library is doing a > > >> > > getCountries().add("CA") and throwing a null pointer exception > > because > > >> > > getCountries is returning a null. > > >> > > > > >> > > Also, you should really be programming to interfaces, not > > >> > implementations. > > >> > > Define your methods to take and return the List interfac
Re: Struts2 REST plugin: Passing array in JSON
I was more looking for the output of all the System.out.println's (*Chris*) On Oct 11, 2012 12:40 PM, "Shaun Lim" wrote: > By the way, mapping to a simple String[] works, but I'm finding it hard to > believe that the plugin does not know how to handle conversions to List.. > > On Thu, Oct 11, 2012 at 11:54 AM, Shaun Lim > wrote: > > > Method public java.lang.String > > > org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) > > threw an exception when invoked on net.sf.json.JSONException: Error while > > setting property=arrayListStr type interface java.util.List > > > > > > On Thu, Oct 11, 2012 at 11:19 AM, Chris Pratt >wrote: > > > >> What's the output of the run with this class & JSON? > >> (*Chris*) > >> > >> On Thu, Oct 11, 2012 at 10:52 AM, Shaun Lim > >> wrote: > >> > >> > Hi Chris, > >> > > >> > I did start off with a List implementation but started > changing > >> > stuff around in futile attempts to get something working. Anyway I > tried > >> > your suggestion, and am still getting the same error: > >> > > >> > //I've a whole bunch of different fields here cause i was testing > >> various > >> > things, but "arrayListStr" follows your recommendation > >> > > >> > public class Test { > >> > private String name; > >> > private String description; > >> > private List countries; > >> > > >> > private String[] array; > >> > > >> > private TestChild testChild; > >> > private ArrayList arrayList; > >> > private List arrayListStr; > >> > > >> > public Test() { > >> > arrayList = new ArrayList(); > >> > arrayListStr = new ArrayList(); > >> > } > >> > > >> > public String getName() { > >> > return name; > >> > } > >> > > >> > public void setName(String name) { > >> > System.out.println("setting name"); > >> > this.name = name; > >> > } > >> > > >> > public String getDescription() { > >> > System.out.println("getting desc"); > >> > return description; > >> > } > >> > > >> > public void setDescription(String description) { > >> > System.out.println("settings description"); > >> > this.description = description; > >> > } > >> > > >> > public List getCountries() { > >> > return countries; > >> > } > >> > > >> > public void setCountries(List countries) { > >> > System.out.println("settings countries"); > >> > this.countries = countries; > >> > } > >> > > >> > public TestChild getTestChild() { > >> > return testChild; > >> > } > >> > > >> > public void setTestChild(TestChild testChild) { > >> > System.out.println("setting testchild"); > >> > this.testChild = testChild; > >> > } > >> > > >> > public String[] getArray() { > >> > return array; > >> > } > >> > > >> > public void setArray(String[] array) { > >> > System.out.println("setting arr"); > >> > this.array = array; > >> > } > >> > > >> > public ArrayList getArrayList() { > >> > return arrayList; > >> > } > >> > > >> > public void setArrayList(ArrayList arrayList) { > >> > System.out.println("setting arrlist"); > >> > this.arrayList = arrayList; > >> > } > >> > > >> > public List getArrayListStr() { > >> > return arrayListStr; > >> > } > >> > > >> > public void setArrayListStr(List arrayListStr) { > >> > System.out.println("setting arrliststr"); > >> > this.arrayListStr = arrayListStr; > >> > } > >> > } > >> > > >> > And the JSON: > >> > > >> > {"testChild": {"description":"kid"},"description":"whee", "name": > >> > "foo","array":["CA","SG"],"arrayListStr":["CA","SG"]} > >> > > >> > Thanks for your help! > >> > > >> > Shaun > >> > > >> > On Wed, Oct 10, 2012 at 11:33 PM, Chris Pratt < > thechrispr...@gmail.com > >> > >wrote: > >> > > >> > > You *might* need to initialize the countries array. I wouldn't be > >> > > surprised if internally the JSON library is doing a > >> > > getCountries().add("CA") and throwing a null pointer exception > because > >> > > getCountries is returning a null. > >> > > > >> > > Also, you should really be programming to interfaces, not > >> > implementations. > >> > > Define your methods to take and return the List interface > >> instead > >> > > of the ArrayList specific implementation and your programs > >> will > >> > be > >> > > much more flexible and reusable in the future. See if this works > >> better: > >> > > (*Chris*) > >> > > > >> > > public class Test { > >> > > private String name; > >> > > private String description; > >> > > private List countries; > >> > > > >> > > public Test() { > >> > >countries = new ArrayList<>(); > >> > > } > >> > > > >> > > public String getName() { > >> > > return name; > >> > > } > >> > > > >> > > public void setName(String name) { > >> > > this.name = name; > >> > >
Re: Struts2 REST plugin: Passing array in JSON
2012/10/11 Shaun Lim : > By the way, mapping to a simple String[] works, but I'm finding it hard to > believe that the plugin does not know how to handle conversions to List.. Could you prepare a full Maven base example ? Thanks in advance -- Ł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 plugin: Passing array in JSON
By the way, mapping to a simple String[] works, but I'm finding it hard to believe that the plugin does not know how to handle conversions to List.. On Thu, Oct 11, 2012 at 11:54 AM, Shaun Lim wrote: > Method public java.lang.String > org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) > threw an exception when invoked on net.sf.json.JSONException: Error while > setting property=arrayListStr type interface java.util.List > > > On Thu, Oct 11, 2012 at 11:19 AM, Chris Pratt wrote: > >> What's the output of the run with this class & JSON? >> (*Chris*) >> >> On Thu, Oct 11, 2012 at 10:52 AM, Shaun Lim >> wrote: >> >> > Hi Chris, >> > >> > I did start off with a List implementation but started changing >> > stuff around in futile attempts to get something working. Anyway I tried >> > your suggestion, and am still getting the same error: >> > >> > //I've a whole bunch of different fields here cause i was testing >> various >> > things, but "arrayListStr" follows your recommendation >> > >> > public class Test { >> > private String name; >> > private String description; >> > private List countries; >> > >> > private String[] array; >> > >> > private TestChild testChild; >> > private ArrayList arrayList; >> > private List arrayListStr; >> > >> > public Test() { >> > arrayList = new ArrayList(); >> > arrayListStr = new ArrayList(); >> > } >> > >> > public String getName() { >> > return name; >> > } >> > >> > public void setName(String name) { >> > System.out.println("setting name"); >> > this.name = name; >> > } >> > >> > public String getDescription() { >> > System.out.println("getting desc"); >> > return description; >> > } >> > >> > public void setDescription(String description) { >> > System.out.println("settings description"); >> > this.description = description; >> > } >> > >> > public List getCountries() { >> > return countries; >> > } >> > >> > public void setCountries(List countries) { >> > System.out.println("settings countries"); >> > this.countries = countries; >> > } >> > >> > public TestChild getTestChild() { >> > return testChild; >> > } >> > >> > public void setTestChild(TestChild testChild) { >> > System.out.println("setting testchild"); >> > this.testChild = testChild; >> > } >> > >> > public String[] getArray() { >> > return array; >> > } >> > >> > public void setArray(String[] array) { >> > System.out.println("setting arr"); >> > this.array = array; >> > } >> > >> > public ArrayList getArrayList() { >> > return arrayList; >> > } >> > >> > public void setArrayList(ArrayList arrayList) { >> > System.out.println("setting arrlist"); >> > this.arrayList = arrayList; >> > } >> > >> > public List getArrayListStr() { >> > return arrayListStr; >> > } >> > >> > public void setArrayListStr(List arrayListStr) { >> > System.out.println("setting arrliststr"); >> > this.arrayListStr = arrayListStr; >> > } >> > } >> > >> > And the JSON: >> > >> > {"testChild": {"description":"kid"},"description":"whee", "name": >> > "foo","array":["CA","SG"],"arrayListStr":["CA","SG"]} >> > >> > Thanks for your help! >> > >> > Shaun >> > >> > On Wed, Oct 10, 2012 at 11:33 PM, Chris Pratt > > >wrote: >> > >> > > You *might* need to initialize the countries array. I wouldn't be >> > > surprised if internally the JSON library is doing a >> > > getCountries().add("CA") and throwing a null pointer exception because >> > > getCountries is returning a null. >> > > >> > > Also, you should really be programming to interfaces, not >> > implementations. >> > > Define your methods to take and return the List interface >> instead >> > > of the ArrayList specific implementation and your programs >> will >> > be >> > > much more flexible and reusable in the future. See if this works >> better: >> > > (*Chris*) >> > > >> > > public class Test { >> > > private String name; >> > > private String description; >> > > private List countries; >> > > >> > > public Test() { >> > >countries = new ArrayList<>(); >> > > } >> > > >> > > public String getName() { >> > > return name; >> > > } >> > > >> > > public void setName(String name) { >> > > this.name = name; >> > > } >> > > >> > > public String getDescription() { >> > > return description; >> > > } >> > > >> > > public void setDescription(String description) { >> > > this.description = description; >> > > } >> > > >> > > public List getCountries() { >> > > return countries; >> > > } >> > > >> > > public void setCountries(List countries) { >> > > this.countries = countries; >> > > } >> > > } >> > > >> > > On Wed,
Re: Struts2 REST plugin: Passing array in JSON
Method public java.lang.String org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on net.sf.json.JSONException: Error while setting property=arrayListStr type interface java.util.List On Thu, Oct 11, 2012 at 11:19 AM, Chris Pratt wrote: > What's the output of the run with this class & JSON? > (*Chris*) > > On Thu, Oct 11, 2012 at 10:52 AM, Shaun Lim > wrote: > > > Hi Chris, > > > > I did start off with a List implementation but started changing > > stuff around in futile attempts to get something working. Anyway I tried > > your suggestion, and am still getting the same error: > > > > //I've a whole bunch of different fields here cause i was testing various > > things, but "arrayListStr" follows your recommendation > > > > public class Test { > > private String name; > > private String description; > > private List countries; > > > > private String[] array; > > > > private TestChild testChild; > > private ArrayList arrayList; > > private List arrayListStr; > > > > public Test() { > > arrayList = new ArrayList(); > > arrayListStr = new ArrayList(); > > } > > > > public String getName() { > > return name; > > } > > > > public void setName(String name) { > > System.out.println("setting name"); > > this.name = name; > > } > > > > public String getDescription() { > > System.out.println("getting desc"); > > return description; > > } > > > > public void setDescription(String description) { > > System.out.println("settings description"); > > this.description = description; > > } > > > > public List getCountries() { > > return countries; > > } > > > > public void setCountries(List countries) { > > System.out.println("settings countries"); > > this.countries = countries; > > } > > > > public TestChild getTestChild() { > > return testChild; > > } > > > > public void setTestChild(TestChild testChild) { > > System.out.println("setting testchild"); > > this.testChild = testChild; > > } > > > > public String[] getArray() { > > return array; > > } > > > > public void setArray(String[] array) { > > System.out.println("setting arr"); > > this.array = array; > > } > > > > public ArrayList getArrayList() { > > return arrayList; > > } > > > > public void setArrayList(ArrayList arrayList) { > > System.out.println("setting arrlist"); > > this.arrayList = arrayList; > > } > > > > public List getArrayListStr() { > > return arrayListStr; > > } > > > > public void setArrayListStr(List arrayListStr) { > > System.out.println("setting arrliststr"); > > this.arrayListStr = arrayListStr; > > } > > } > > > > And the JSON: > > > > {"testChild": {"description":"kid"},"description":"whee", "name": > > "foo","array":["CA","SG"],"arrayListStr":["CA","SG"]} > > > > Thanks for your help! > > > > Shaun > > > > On Wed, Oct 10, 2012 at 11:33 PM, Chris Pratt > >wrote: > > > > > You *might* need to initialize the countries array. I wouldn't be > > > surprised if internally the JSON library is doing a > > > getCountries().add("CA") and throwing a null pointer exception because > > > getCountries is returning a null. > > > > > > Also, you should really be programming to interfaces, not > > implementations. > > > Define your methods to take and return the List interface > instead > > > of the ArrayList specific implementation and your programs will > > be > > > much more flexible and reusable in the future. See if this works > better: > > > (*Chris*) > > > > > > public class Test { > > > private String name; > > > private String description; > > > private List countries; > > > > > > public Test() { > > >countries = new ArrayList<>(); > > > } > > > > > > public String getName() { > > > return name; > > > } > > > > > > public void setName(String name) { > > > this.name = name; > > > } > > > > > > public String getDescription() { > > > return description; > > > } > > > > > > public void setDescription(String description) { > > > this.description = description; > > > } > > > > > > public List getCountries() { > > > return countries; > > > } > > > > > > public void setCountries(List countries) { > > > this.countries = countries; > > > } > > > } > > > > > > On Wed, Oct 10, 2012 at 11:23 PM, Shaun Lim > > > wrote: > > > > > > > My entity class: > > > > > > > > import java.util.ArrayList; > > > > > > > > > > > > public class Test { > > > > private String name; > > > > private String description; > > > > private ArrayList countries; > > > > > > > > public Test() { > > > > > > > > } > > > > > > > > public String getNa
Re: Struts2 REST plugin: Passing array in JSON
What's the output of the run with this class & JSON? (*Chris*) On Thu, Oct 11, 2012 at 10:52 AM, Shaun Lim wrote: > Hi Chris, > > I did start off with a List implementation but started changing > stuff around in futile attempts to get something working. Anyway I tried > your suggestion, and am still getting the same error: > > //I've a whole bunch of different fields here cause i was testing various > things, but "arrayListStr" follows your recommendation > > public class Test { > private String name; > private String description; > private List countries; > > private String[] array; > > private TestChild testChild; > private ArrayList arrayList; > private List arrayListStr; > > public Test() { > arrayList = new ArrayList(); > arrayListStr = new ArrayList(); > } > > public String getName() { > return name; > } > > public void setName(String name) { > System.out.println("setting name"); > this.name = name; > } > > public String getDescription() { > System.out.println("getting desc"); > return description; > } > > public void setDescription(String description) { > System.out.println("settings description"); > this.description = description; > } > > public List getCountries() { > return countries; > } > > public void setCountries(List countries) { > System.out.println("settings countries"); > this.countries = countries; > } > > public TestChild getTestChild() { > return testChild; > } > > public void setTestChild(TestChild testChild) { > System.out.println("setting testchild"); > this.testChild = testChild; > } > > public String[] getArray() { > return array; > } > > public void setArray(String[] array) { > System.out.println("setting arr"); > this.array = array; > } > > public ArrayList getArrayList() { > return arrayList; > } > > public void setArrayList(ArrayList arrayList) { > System.out.println("setting arrlist"); > this.arrayList = arrayList; > } > > public List getArrayListStr() { > return arrayListStr; > } > > public void setArrayListStr(List arrayListStr) { > System.out.println("setting arrliststr"); > this.arrayListStr = arrayListStr; > } > } > > And the JSON: > > {"testChild": {"description":"kid"},"description":"whee", "name": > "foo","array":["CA","SG"],"arrayListStr":["CA","SG"]} > > Thanks for your help! > > Shaun > > On Wed, Oct 10, 2012 at 11:33 PM, Chris Pratt >wrote: > > > You *might* need to initialize the countries array. I wouldn't be > > surprised if internally the JSON library is doing a > > getCountries().add("CA") and throwing a null pointer exception because > > getCountries is returning a null. > > > > Also, you should really be programming to interfaces, not > implementations. > > Define your methods to take and return the List interface instead > > of the ArrayList specific implementation and your programs will > be > > much more flexible and reusable in the future. See if this works better: > > (*Chris*) > > > > public class Test { > > private String name; > > private String description; > > private List countries; > > > > public Test() { > >countries = new ArrayList<>(); > > } > > > > public String getName() { > > return name; > > } > > > > public void setName(String name) { > > this.name = name; > > } > > > > public String getDescription() { > > return description; > > } > > > > public void setDescription(String description) { > > this.description = description; > > } > > > > public List getCountries() { > > return countries; > > } > > > > public void setCountries(List countries) { > > this.countries = countries; > > } > > } > > > > On Wed, Oct 10, 2012 at 11:23 PM, Shaun Lim > > wrote: > > > > > My entity class: > > > > > > import java.util.ArrayList; > > > > > > > > > public class Test { > > > private String name; > > > private String description; > > > private ArrayList countries; > > > > > > public Test() { > > > > > > } > > > > > > public String getName() { > > > return name; > > > } > > > > > > public void setName(String name) { > > > this.name = name; > > > } > > > > > > public String getDescription() { > > > return description; > > > } > > > > > > public void setDescription(String description) { > > > this.description = description; > > > } > > > > > > public ArrayList getCountries() { > > > return countries; > > > } > > > > > > public void setCountries(ArrayList countries) { > > > this.countries = countries; > > > } > > > } > > > > > > The JSON I'm trying to send: > > > > > > {"countries"
Re: Struts2 REST plugin: Passing array in JSON
Hi Chris, I did start off with a List implementation but started changing stuff around in futile attempts to get something working. Anyway I tried your suggestion, and am still getting the same error: //I've a whole bunch of different fields here cause i was testing various things, but "arrayListStr" follows your recommendation public class Test { private String name; private String description; private List countries; private String[] array; private TestChild testChild; private ArrayList arrayList; private List arrayListStr; public Test() { arrayList = new ArrayList(); arrayListStr = new ArrayList(); } public String getName() { return name; } public void setName(String name) { System.out.println("setting name"); this.name = name; } public String getDescription() { System.out.println("getting desc"); return description; } public void setDescription(String description) { System.out.println("settings description"); this.description = description; } public List getCountries() { return countries; } public void setCountries(List countries) { System.out.println("settings countries"); this.countries = countries; } public TestChild getTestChild() { return testChild; } public void setTestChild(TestChild testChild) { System.out.println("setting testchild"); this.testChild = testChild; } public String[] getArray() { return array; } public void setArray(String[] array) { System.out.println("setting arr"); this.array = array; } public ArrayList getArrayList() { return arrayList; } public void setArrayList(ArrayList arrayList) { System.out.println("setting arrlist"); this.arrayList = arrayList; } public List getArrayListStr() { return arrayListStr; } public void setArrayListStr(List arrayListStr) { System.out.println("setting arrliststr"); this.arrayListStr = arrayListStr; } } And the JSON: {"testChild": {"description":"kid"},"description":"whee", "name": "foo","array":["CA","SG"],"arrayListStr":["CA","SG"]} Thanks for your help! Shaun On Wed, Oct 10, 2012 at 11:33 PM, Chris Pratt wrote: > You *might* need to initialize the countries array. I wouldn't be > surprised if internally the JSON library is doing a > getCountries().add("CA") and throwing a null pointer exception because > getCountries is returning a null. > > Also, you should really be programming to interfaces, not implementations. > Define your methods to take and return the List interface instead > of the ArrayList specific implementation and your programs will be > much more flexible and reusable in the future. See if this works better: > (*Chris*) > > public class Test { > private String name; > private String description; > private List countries; > > public Test() { >countries = new ArrayList<>(); > } > > public String getName() { > return name; > } > > public void setName(String name) { > this.name = name; > } > > public String getDescription() { > return description; > } > > public void setDescription(String description) { > this.description = description; > } > > public List getCountries() { > return countries; > } > > public void setCountries(List countries) { > this.countries = countries; > } > } > > On Wed, Oct 10, 2012 at 11:23 PM, Shaun Lim > wrote: > > > My entity class: > > > > import java.util.ArrayList; > > > > > > public class Test { > > private String name; > > private String description; > > private ArrayList countries; > > > > public Test() { > > > > } > > > > public String getName() { > > return name; > > } > > > > public void setName(String name) { > > this.name = name; > > } > > > > public String getDescription() { > > return description; > > } > > > > public void setDescription(String description) { > > this.description = description; > > } > > > > public ArrayList getCountries() { > > return countries; > > } > > > > public void setCountries(ArrayList countries) { > > this.countries = countries; > > } > > } > > > > The JSON I'm trying to send: > > > > {"countries": ["CA", "SG"], "description":"whee", "name": "foo"} > > > > The error: > > > > 2345447 [http-bio-8080-exec-1] ERROR freemarker.runtime - Method > > public java.lang.String > > > org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) > > threw an exception when invoked on net.sf.json.JSONException: Error > > while setting property=countries type interface java.util.List > > > > Method public java.lang.String > > > org.apache.commons.lang.exception.Nestable
Re: Struts2 REST plugin: Passing array in JSON
You *might* need to initialize the countries array. I wouldn't be surprised if internally the JSON library is doing a getCountries().add("CA") and throwing a null pointer exception because getCountries is returning a null. Also, you should really be programming to interfaces, not implementations. Define your methods to take and return the List interface instead of the ArrayList specific implementation and your programs will be much more flexible and reusable in the future. See if this works better: (*Chris*) public class Test { private String name; private String description; private List countries; public Test() { countries = new ArrayList<>(); } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public List getCountries() { return countries; } public void setCountries(List countries) { this.countries = countries; } } On Wed, Oct 10, 2012 at 11:23 PM, Shaun Lim wrote: > My entity class: > > import java.util.ArrayList; > > > public class Test { > private String name; > private String description; > private ArrayList countries; > > public Test() { > > } > > public String getName() { > return name; > } > > public void setName(String name) { > this.name = name; > } > > public String getDescription() { > return description; > } > > public void setDescription(String description) { > this.description = description; > } > > public ArrayList getCountries() { > return countries; > } > > public void setCountries(ArrayList countries) { > this.countries = countries; > } > } > > The JSON I'm trying to send: > > {"countries": ["CA", "SG"], "description":"whee", "name": "foo"} > > The error: > > 2345447 [http-bio-8080-exec-1] ERROR freemarker.runtime - Method > public java.lang.String > org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) > threw an exception when invoked on net.sf.json.JSONException: Error > while setting property=countries type interface java.util.List > > Method public java.lang.String > org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) > threw an exception when invoked on net.sf.json.JSONException: Error > while setting property=countries type interface java.util.List > The problematic instruction: > -- > ==> ${msgs[0][0]} [on line 76, column 25 in > org/apache/struts2/dispatcher/error.ftl] > -- > > Java backtrace for programmers: > -- > freemarker.template.TemplateModelException: Method public > java.lang.String > org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) > threw an exception when invoked on net.sf.json.JSONException: Error > while setting property=countries type interface java.util.List > at > freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130) > at > freemarker.ext.beans.SimpleMethodModel.get(SimpleMethodModel.java:138) > at > freemarker.core.DynamicKeyName.dealWithNumericalKey(DynamicKeyName.java:111) > at > freemarker.core.DynamicKeyName._getAsTemplateModel(DynamicKeyName.java:90) > at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) > at freemarker.core.Expression.getStringValue(Expression.java:93) > at freemarker.core.DollarVariable.accept(DollarVariable.java:76) > at freemarker.core.Environment.visit(Environment.java:210) > at freemarker.core.MixedContent.accept(MixedContent.java:92) > at freemarker.core.Environment.visit(Environment.java:210) > at freemarker.core.IfBlock.accept(IfBlock.java:82) > at freemarker.core.Environment.visit(Environment.java:210) > at freemarker.core.IfBlock.accept(IfBlock.java:82) > at freemarker.core.Environment.visit(Environment.java:210) > at freemarker.core.MixedContent.accept(MixedContent.java:92) > at freemarker.core.Environment.visit(Environment.java:210) > at freemarker.core.Environment.process(Environment.java:190) > at freemarker.template.Template.process(Template.java:237) > at > org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:797) > at > org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:519) > at > org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) > at > org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) > at > org.apache.catalina.core.Standar
Re: Struts2 REST plugin problems
2011/7/4 Aelbery Lee : > Yes. I had set "struts.rest.namespace" in the struts.xml to "/ws". It must work, could you show your action's source code ? Do you map like these below: /ws/model -> ModelAction.index() /ws/mode/1 -> ModelAction.show() Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
Yes. I had set "struts.rest.namespace" in the struts.xml to "/ws". -- View this message in context: http://struts.1045723.n5.nabble.com/Struts2-REST-plugin-problems-tp3492324p4548572.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
Did you try to specify struts.rest.namespace constant ? It will change what kind of actions are created base on the namespace. http://struts.apache.org/2.2.3/docs/rest-plugin.html#RESTPlugin-Settings Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ 2011/7/2 Aelbery Lee : > Hi, all. > > I'm currently using struts 2.2.3. I want to mix normal action with > restful action in the same web app. I searched and found here. > > In my struts.mxl: > > > > > value="rest-default" /> > > > > value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/> > > > > > > > > /WEB-INF/content/{1}.jsp > > > > > If I removed the PrefixBasedActionMapper and prefixMapping two lines, > /myapp/mymodule works fine with restful action. > > But now /myapp/mymodule raise exception "method not found", execute(); > And /myapp/ws/mymodule raise exception "action not found", ws action. > > So I must make a mistake. Thanks for you help. > > -- > View this message in context: > http://struts.1045723.n5.nabble.com/Struts2-REST-plugin-problems-tp3492324p4544292.html > Sent from the Struts - User mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
Hi, all. I'm currently using struts 2.2.3. I want to mix normal action with restful action in the same web app. I searched and found here. In my struts.mxl: /WEB-INF/content/{1}.jsp If I removed the PrefixBasedActionMapper and prefixMapping two lines, /myapp/mymodule works fine with restful action. But now /myapp/mymodule raise exception "method not found", execute(); And /myapp/ws/mymodule raise exception "action not found", ws action. So I must make a mistake. Thanks for you help. -- View this message in context: http://struts.1045723.n5.nabble.com/Struts2-REST-plugin-problems-tp3492324p4544292.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
Hi folks, I've just resolved my issue. My goal is to add struts-restful-plugin to an struts2 existent app. So i needed to have an url handler If I request http://localhost:8080/myApp/login.action, it must be resolved by DefaultActionMapper If I request http://localhost:8080/myApp/service/client/324, it must be resolved by org.apache.struts2.rest. RestActionMapper So I have in my struts.xml Where rest is a bean defined in strus-config.xml (restful plugin) and it is mapped to org.apache.struts2.rest.RestActionMapper In my struts.properties struts.action.extension=action,xml,json,, And that's all. I hope it can help to someone having the same problem. Thanks for everything. p.d. I'm using struts2.2.1 Bye On Tue, Aug 31, 2010 at 5:24 PM, Dale Newfield wrote: > On 8/31/10 5:17 PM, Rafael Taboada wrote: > >> But I'm having the same problem "HTTP status 404" >> > > So it is failing to find any valid action mapping? What do your logs show? > This might help you figure out what's going on: > http://struts.apache.org/2.x/docs/config-browser-plugin.html > > > My struts.xml looks like : >> > > >> > > I don't know what's in that file--I'm guessing a package with the namespace > "/example"? Do you have any packages whose namespace is "/service"? > > > >> > > I've not looked into the details of the plugins you said you're using. Do > any of them provide packages that you need to extend instead of > struts-default to get their benefits? > > > >> HelloWorld >> /example >> > > So if you try to access /index.action, does it redirect to > /example/HellowWorld.action ? > > > And when I try to acces >> http://localhost:8080/struts221/example/HelloWorld.action, apparently it >> is driven by restful, because it shows "HTTP status 404" error >> > > Your configuration doesn't specify that this should be mapped by the > Restful2ActionMapper, so why do you assume this? > > > Maybe i'm missing another config? What am I doing wrong? >> > > I don't know how the Restful2ActionMapper does it's thing. When I looked > at the two provided Restful action mappers several years ago I found that > neither really did what I needed, so I ended up writing my own. I've > actually found that most of what people want when they say they want REST > style urls can be provided by the default action mapper with wildcards. > (Also, make sure that you have SlashesInActionNames set appropriately for > the rest of your config.) > > http://struts.apache.org/2.x/docs/restfulactionmapper.html and/or > http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.htmlshould > be helpful. > > -Dale > -- Rafael Taboada Software Engineer Cell : +511-992741026 "No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: Struts2 REST plugin problems
Hi folks, I've just resolved my issue. My goal is to add struts-restful-plugin to an struts2 existent app. So i needed to have an url handler If I request http://localhost:8080/myApp/login.action, it must be resolved by DefaultActionMapper If I request http://localhost:8080/myApp/service/client/324, it must be resolved by org.apache.struts2.rest. RestActionMapper So I have in my struts.xml Where rest is a bean defined in strus-config.xml (restful plugin) and it is mapped to org.apache.struts2.rest.RestActionMapper In my struts.properties struts.action.extension=action,xml,json,, And that's all. I hope it can help to someone having the same problem. Thanks for everything. p.d. I'm using struts2.2.1 Bye On Tue, Aug 31, 2010 at 5:24 PM, Dale Newfield wrote: > On 8/31/10 5:17 PM, Rafael Taboada wrote: > >> But I'm having the same problem "HTTP status 404" >> > > So it is failing to find any valid action mapping? What do your logs show? > This might help you figure out what's going on: > http://struts.apache.org/2.x/docs/config-browser-plugin.html > > > My struts.xml looks like : >> > > >> > > I don't know what's in that file--I'm guessing a package with the namespace > "/example"? Do you have any packages whose namespace is "/service"? > > > >> > > I've not looked into the details of the plugins you said you're using. Do > any of them provide packages that you need to extend instead of > struts-default to get their benefits? > > > >> HelloWorld >> /example >> > > So if you try to access /index.action, does it redirect to > /example/HellowWorld.action ? > > > And when I try to acces >> http://localhost:8080/struts221/example/HelloWorld.action, apparently it >> is driven by restful, because it shows "HTTP status 404" error >> > > Your configuration doesn't specify that this should be mapped by the > Restful2ActionMapper, so why do you assume this? > > > Maybe i'm missing another config? What am I doing wrong? >> > > I don't know how the Restful2ActionMapper does it's thing. When I looked > at the two provided Restful action mappers several years ago I found that > neither really did what I needed, so I ended up writing my own. I've > actually found that most of what people want when they say they want REST > style urls can be provided by the default action mapper with wildcards. > (Also, make sure that you have SlashesInActionNames set appropriately for > the rest of your config.) > > http://struts.apache.org/2.x/docs/restfulactionmapper.html and/or > http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.htmlshould > be helpful. > > -Dale > -- Rafael Taboada Software Engineer Cell : +511-992741026 "No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: Struts2 REST plugin problems
On 8/31/10 5:17 PM, Rafael Taboada wrote: But I'm having the same problem "HTTP status 404" So it is failing to find any valid action mapping? What do your logs show? This might help you figure out what's going on: http://struts.apache.org/2.x/docs/config-browser-plugin.html My struts.xml looks like : I don't know what's in that file--I'm guessing a package with the namespace "/example"? Do you have any packages whose namespace is "/service"? I've not looked into the details of the plugins you said you're using. Do any of them provide packages that you need to extend instead of struts-default to get their benefits? HelloWorld /example So if you try to access /index.action, does it redirect to /example/HellowWorld.action ? And when I try to acces http://localhost:8080/struts221/example/HelloWorld.action, apparently it is driven by restful, because it shows "HTTP status 404" error Your configuration doesn't specify that this should be mapped by the Restful2ActionMapper, so why do you assume this? Maybe i'm missing another config? What am I doing wrong? I don't know how the Restful2ActionMapper does it's thing. When I looked at the two provided Restful action mappers several years ago I found that neither really did what I needed, so I ended up writing my own. I've actually found that most of what people want when they say they want REST style urls can be provided by the default action mapper with wildcards. (Also, make sure that you have SlashesInActionNames set appropriately for the rest of your config.) http://struts.apache.org/2.x/docs/restfulactionmapper.html and/or http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.html should be helpful. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
Hi, I was debugging PrefixBasedActionMapper and a I noticed that: - It gets the right actionmappers "/service" -> org.apache.struts2.dispatcher.mapper.restful2actionmap...@34e6529c "" -> org.apache.struts2.dispatcher.mapper.defaultactionmap...@50e8709d - When I can access the uri /example/HelloWorld.action it takes the defaultActionMapper Using ActionMapper org.apache.struts2.dispatcher.mapper.defaultactionmap...@50e8709d - but in the line "ActionMapping actionMapping = actionMapper.getMapping(request, configManager);" it returns NULL ActionMapper org.apache.struts2.dispatcher.mapper.defaultactionmap...@50e8709d failed to return an ActionMapping And the log "no ActionMapper found" Any comment about this? Thanks in advance On Tue, Aug 31, 2010 at 4:17 PM, Rafael Taboada wrote: > Great, > > But I'm having the same problem "HTTP status 404" > > I've downloaded struts-blank2.2.1 and added jars about restful plugin > (struts2-rest-showcase-2.2.1) > > My struts.xml looks like : > > > > > > > name="pseudoRestful" > class="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper"/> > value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/> > value="service:pseudoRestful,:struts"/> > > > > > > > > > > > HelloWorld > /example > > > > > > > > > And when I try to acces > http://localhost:8080/struts221/example/HelloWorld.action, apparently it > is driven by restful, because it shows "HTTP status 404" error > > Maybe i'm missing another config? What am I doing wrong? > > > > On Tue, Aug 31, 2010 at 4:05 PM, Dale Newfield wrote: > >> On 8/31/10 4:40 PM, Rafael Taboada wrote: >> >>> I have in my struts.xml >>> >> name="pseudoRestful" >>> class="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper"/> >>> >> value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/> >>> >> value="/service:pseudoRestful,:struts"/> >>> >>> It means, every url that contains 'service' must be mapped with >>> Restful2ActionMapper, everything else use default mapping. >>> >>> Is that correct? What am i missing or doing wrong? >>> >> >> Almost. It means that every request that starts with "/service/" >> (ignoring context root) will first be mapped using the Restful2ActionMapper, >> if that fails, then it'll be mapped by the standard struts >> DefaultActionMapper. Anything that doesn't start with "/service/" will just >> be mapped by the standard struts DefaultActionMapper. >> >> -Dale >> > > > > -- > Rafael Taboada > Software Engineer > > Cell : +511-992741026 > > "No creo en el destino pues no me gusta tener la idea de controlar mi vida" > -- Rafael Taboada Software Engineer Cell : +511-992741026 "No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: Struts2 REST plugin problems
Great, But I'm having the same problem "HTTP status 404" I've downloaded struts-blank2.2.1 and added jars about restful plugin (struts2-rest-showcase-2.2.1) My struts.xml looks like : HelloWorld /example And when I try to acces http://localhost:8080/struts221/example/HelloWorld.action, apparently it is driven by restful, because it shows "HTTP status 404" error Maybe i'm missing another config? What am I doing wrong? On Tue, Aug 31, 2010 at 4:05 PM, Dale Newfield wrote: > On 8/31/10 4:40 PM, Rafael Taboada wrote: > >> I have in my struts.xml >> > name="pseudoRestful" >> class="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper"/> >> > value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/> >> > value="/service:pseudoRestful,:struts"/> >> >> It means, every url that contains 'service' must be mapped with >> Restful2ActionMapper, everything else use default mapping. >> >> Is that correct? What am i missing or doing wrong? >> > > Almost. It means that every request that starts with "/service/" (ignoring > context root) will first be mapped using the Restful2ActionMapper, if that > fails, then it'll be mapped by the standard struts DefaultActionMapper. > Anything that doesn't start with "/service/" will just be mapped by the > standard struts DefaultActionMapper. > > -Dale > -- Rafael Taboada Software Engineer Cell : +511-992741026 "No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: Struts2 REST plugin problems
On 8/31/10 4:40 PM, Rafael Taboada wrote: I have in my struts.xml It means, every url that contains 'service' must be mapped with Restful2ActionMapper, everything else use default mapping. Is that correct? What am i missing or doing wrong? Almost. It means that every request that starts with "/service/" (ignoring context root) will first be mapped using the Restful2ActionMapper, if that fails, then it'll be mapped by the standard struts DefaultActionMapper. Anything that doesn't start with "/service/" will just be mapped by the standard struts DefaultActionMapper. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
Hi, I've been looking at PrefixBasedActionMapper. What is the way to configure it? I have in my struts.xml It means, every url that contains 'service' must be mapped with Restful2ActionMapper, everything else use default mapping. Is that correct? What am i missing or doing wrong? On Tue, Aug 31, 2010 at 2:37 PM, Dale Newfield wrote: > On 8/31/10 3:15 PM, Rafael Taboada wrote: > >> I migrated my app to 2.1 because I need to use restful plugin, didn't >> think in 2.2 because it was released just a month ago (i think) and i >> don't know if it is a good option in production environment. >> > > Theoretically any GA (General Availability) release is of sufficient > quality to run in production, and the newer releases will have both more > capabilities as well as better performance characteristics. If you > experience any issues, please ask here and/or submit a detailed JIRA issue. > > -Dale > -- Rafael Taboada Software Engineer Cell : +511-992741026 "No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: Struts2 REST plugin problems
On 8/31/10 3:15 PM, Rafael Taboada wrote: I migrated my app to 2.1 because I need to use restful plugin, didn't think in 2.2 because it was released just a month ago (i think) and i don't know if it is a good option in production environment. Theoretically any GA (General Availability) release is of sufficient quality to run in production, and the newer releases will have both more capabilities as well as better performance characteristics. If you experience any issues, please ask here and/or submit a detailed JIRA issue. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
Thanks so much for your answer. I migrated my app to 2.1 because I need to use restful plugin, didn't think in 2.2 because it was released just a month ago (i think) and i don't know if it is a good option in production environment. I'll consider your advice. Thanks On Tue, Aug 31, 2010 at 1:21 PM, Dale Newfield wrote: > On 8/31/10 2:05 PM, Rafael Taboada wrote: > >> Is there a chance to my traditional actions can co-exist with restful >> controllers?... >> > > If you're looking to have different parts of your url space get processed > by different action mappers, the PrefixBasedActionMapper included in 2.2 > might be what you're looking for. Yes, if you include that class in your > own codebase you can use it in a 2.1 environment. > > https://issues.apache.org/jira/browse/WW-3260 > > -Dale > -- Rafael Taboada Software Engineer Cell : +511-992741026 "No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: Struts2 REST plugin problems
On 8/31/10 2:05 PM, Rafael Taboada wrote: Is there a chance to my traditional actions can co-exist with restful controllers?... If you're looking to have different parts of your url space get processed by different action mappers, the PrefixBasedActionMapper included in 2.2 might be what you're looking for. Yes, if you include that class in your own codebase you can use it in a 2.1 environment. https://issues.apache.org/jira/browse/WW-3260 -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
On 8/31/10 1:04 PM, Rafael Taboada wrote: I have an struts2.0.14 app working well and I decided to migrate to struts2.1.8. Migration worked well. But when I tried to include rest plugin, my current urls to process some actions don't work. I have a http 404 error as a result. My goal is using restful to publish some methods located in my service package, offcourse creating a controller first. Did you read through the 2.0 -> 2.1 migration document? In particular you might be affected by how you're getting the parameters into your action -- I believe there are now several params interceptors where there used to be just one. https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-ActionMappingParams Any reason if you're choosing to upgrade to target 2.1 instead of 2.2? -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST plugin problems
I've just noticed, that rest plugin change the way how i can access to a specific action. When i use http://localhost:8080/myApp/runLogin.action, action mapping is failing. It thinks it is a restful method. and I can access the action putting http://localhost:8080/myApp/runLogin!execute Is there a chance to my traditional actions can co-exist with restful controllers?... I mean, http://localhost:8080/myApp/runLogin.action goes to my login page... http://localhost:8080/myApp/service/folder/145 goes to my restful controller folderController calling the 'show' method. Thanks in advance On Tue, Aug 31, 2010 at 12:04 PM, Rafael Taboada wrote: > Hi folks, > > I have an struts2.0.14 app working well and I decided to migrate to > struts2.1.8. Migration worked well. > > But when I tried to include rest plugin, my current urls to process some > actions don't work. I have a http 404 error as a result. My goal is using > restful to publish some methods located in my service package, offcourse > creating a controller first. > > Do you know why my app doesn't work when I include restful plugin jar?. I > suppose it can't process current urls like > http://localhost:8080/myApp/runLogin.action > > I have noticed that struts2 blank app works well and struts2 rest showcase > too... But when I'm trying to include restful plugin in struts2 blank app, > it doesn't work. When I'm trying to access to > http://localhost:8080/strutsapp/index.action, a http 404 error happens. > > How can i solve this issue? My goal is to use restful in my actual struts > app. I googled and some opinions is that restful plugin is incompatible with > some traditional struts2 apps, is that true? > > Thanks in advance > > Bye > > -- > Rafael Taboada > Software Engineer > > Cell : +511-992741026 > > "No creo en el destino pues no me gusta tener la idea de controlar mi vida" > -- Rafael Taboada Software Engineer Cell : +511-992741026 "No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: STRUTS2 + REST + SPRING Problem
Are you using the struts-spring plugin? If so, I found I had to include: struts.objectFactory.spring.autoWire = name struts.objectFactory.spring.autoWire.alwaysRespect = true to get beans autowired by name. autowiring using auto or type wasn't working in my app so I had to do it by name. - Jonathan mailtolouis2020-str...@yahoo.com wrote: Hi All, Our requirement is use to use STRUTS + REST + SPRING. We are stuck with the below problem: Rest controllers are not able to autowire the spring beans. So i am not able to inject the spring beans to the rest controllers that are created using convention plugin. 1) We configured the struts configuration as below: < bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="myMapper" class="com.xxx.mapper.Struts2RestMapper" /> 2) Struts2RestMapper is a custom ActionMapper to invoke the struts mapper or Rest mapper based on the request url. This is working fine however, rest controller is not working correctly due to failed dependencies. 3) Rest controller is pasted below. @Results ({ @Result(name="success", type="redirectAction", params = {"actionName" , "userrest"}) }) public class UserrestController extends ValidationAwareSupport implements ModelDriven, Validateable { private UserDetails user = null; private String userSignInId; @Autowired private UserDetailsService userService; public void validate() { //if (user.getClientName() == null || model.getClientName().length() ==0) { // addFieldError("clientName", "The client name is empty"); //} System. out.println("validate Method invoked"); } // GET /userrest public HttpHeaders index() { //list = messagesService.getAll(); System. out.println("Index method invoked"); return new DefaultHttpHeaders("index").disableCaching(); } public Object getModel() { return user; } // GET /userrest/1 public HttpHeaders show() { System. out.println("show Method invoked"); return new DefaultHttpHeaders("show"); } public void setId(String id) { System. out.println("setID Method invoked"); if (id != null) { this.user = userService.loadUserByUsername(id); } this.userSignInId = id; } } Please can some one guide me on how to get the rest controller to pick the spring beans (ie., userService in the above example) correctly. Kind Regards LV - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2+ReST-plugin prolems need help!!!
Hi, I’m not an expert with the internals of the REST plugin, but am using it fairly extensively. By and large we use annotations in our classes to determine results (see org.apache.struts2.convention.annotation.Results) but it is certainly possible to define some globals and it is definitely possible to configure interceptors. Given that a picture is worth a thousand words, here is a snippet from our struts XML: login /site So you can see that our main package (globalPackage) is defined such that it extends rest-default. We then create a new interceptor stack and specify that as the default interceptor for the package. Finally, and perhaps most importantly, we ensure that the constant “struts.convention.default.parent.package” points to our globalPackage. Hope that helps you Regards Stuart On 28/05/2009 02:12, "xnpeng" wrote: can any one help? i use struts2.1.6. 在2009-05-20,xnpeng 写道: >I'm doing my project with struts2+rest-plugin for about 3 months.there is a >lot of problems unresolved. > >With rest-plugin and convention-plugin,all action-mapping are done >automatically,manual action-mapping in struts.xml cannot work.so, >1, I cannot define global-error-result; >2, I cannot do forward; >3, I cannot insert my own Interceptors. > >I 'm watching this mail-list day and day, there is not much discuss on >rest-plugin, neithere is enough materials on the internet. Does someone have >much experience on this topic? I need your help ergently! > > >
RE: Struts2+ReST-plugin prolems need help!!!
let the StrutsDispatcher handle the navigation details you'll have to fill in any necessary java classes as well as input/output jsps but the basic structure is outlined in struts.xml illustrated below Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Wed, 20 May 2009 18:36:57 +0800 > From: xnp...@163.com > To: user@struts.apache.org > Subject: Re:Re: Struts2+ReST-plugin prolems need help!!! > > > Hi Dave! >I'm using Struts2.1.6 and struts2-rest-plugin-2.1.6. > > first ,I need a global error page when exception happen like this: > > Stacktraces > java.lang.NoSuchMethodException: com.xunan.sitexa.rest.MainController.a() > java.lang.Class.getMethod(Unknown Source) > > org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75) > > org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47) > > com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) > > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) > > com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) > > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) > > org.apache.struts2.rest.ContentTypeInterceptor.intercept(ContentTypeInterceptor.java:67) > > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) > > and second,I want to forward request to action like the follow: > if(type=='1'){ > request.forward("action1); > }else if(type=='2'){ > request.forward("action1); > } struts.xml /error.jsp /action${ClassName.type}.action /index.jsp action1_success.jsp action1_error.jsp action2_success.jsp action2_error.jsp > third, a SimpleInterceptor doing login check, > > > class="com.xunan.framework.web.interceptor.SimpleInterceptor"/> > > > > > > > > > > > > > > > /error.jsp > > > > > > > > thank you very much. > > > 在2009-05-20,"Dave Newton" 写道: > >xnpeng wrote: > >> I'm doing my project with struts2+rest-plugin for about 3 months.there is > >> a lot of problems unresolved. > >> > >> With rest-plugin and convention-plugin,all action-mapping are done > >> automatically,manual action-mapping in struts.xml cannot work.so, > >> 1, I cannot define global-error-result; > >> 2, I cannot do forward; > >> 3, I cannot insert my own Interceptors. > >> > >> I 'm watching this mail-list day and day, there is not much discuss on > >> rest-plugin, neithere is enough materials on the internet. Does someone > >> have much experience on this topic? I need your help ergently! > >> > >> > >> > > > >It's definitely possible to combine REST and XML mappings. > > > >You might have better luck telling us what specific issues you're > >having, along with what version of S2 you're using. > > > >Dave > > > >- > >To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >For additional commands, e-mail: user-h...@struts.apache.org > > _ Hotmail® goes with you. http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
Re: Struts2+ReST-plugin prolems need help!!!
xnpeng wrote: I'm doing my project with struts2+rest-plugin for about 3 months.there is a lot of problems unresolved. With rest-plugin and convention-plugin,all action-mapping are done automatically,manual action-mapping in struts.xml cannot work.so, 1, I cannot define global-error-result; 2, I cannot do forward; 3, I cannot insert my own Interceptors. I 'm watching this mail-list day and day, there is not much discuss on rest-plugin, neithere is enough materials on the internet. Does someone have much experience on this topic? I need your help ergently! It's definitely possible to combine REST and XML mappings. You might have better luck telling us what specific issues you're having, along with what version of S2 you're using. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 REST
thanks maplye ~
Re: Struts2 REST
2009/3/23 Li : > Hey guys, > > I am a fan of REST and I am excited that Struts2 started supportting REST > architecture. I have used Struts REST plug-in to create a demo struts rest > application with the help of Struts 2 REST showcase. Interestingly I found > out the "content" under WEB-INF is a required setting, which you have to > name the folder of REST views (eg. jsp pages) as "content" otherwise it wont > work correctly. I haven't got chance to look deep into the source of REST > plug-in. I was wondering if there is an place to configure it? Thanks > > > > -- > Small win by playing smart > Big win by playing honest > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 rest plugin - making default response to xml
mahanare wrote: I am wondering if it is possible to use default response of the rest action using rest plugin to xml? instead of http://<>/orders.xml if i can make it http://<>/orders as the action for a POST method in a form submssion and the response should be xml. Essentially i do not want to have any JSPs or html files in my web application. It will be a plain rest based services which process forms and respond with xml. IIRC the default *is* XML; it's configured via struts.rest.defaultExtension. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 rest plugin :struts.convention.action.*, possible values
Thanks > These values, as well as the rest, are documented on the convention > plugin page: > > http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-Configurationreference > > Dave > > > -- View this message in context: http://www.nabble.com/Struts2-rest-plugin-%3Astruts.convention.action.*%2C-possible-values-tp22115906p22120182.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 rest plugin :struts.convention.action.*, possible values
mahanare wrote: I would like to know where can i get all possible values for structs constants? It's a string, you can make it anything you want. I'm almost positive the other possible value is "false". You can make it anything you want. These values, as well as the rest, are documented on the convention plugin page: http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-Configurationreference Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2-rest-plugin-2.1.5 problem
2009/1/5 Ercan Kayaonu : > Thank you for your quick reply. > I tried using maven, but it couldn't find 2.1.5 one. Summary of mvn > messages: Try to use that http://people.apache.org/builds/struts/2.1.5/ it works for me Regards -- Lukasz 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-plugin-2.1.5 problem
On Sun, Jan 4, 2009 at 7:25 PM, Ercan Kayaonu wrote: > Thank you for your quick reply. > I tried using maven, but it couldn't find 2.1.5 one. Summary of mvn > messages: Struts 2.1.5 has not been voted on and is not an official release -- standard disclaimers apply. :) If you didn't intend to venture out onto the bleeding edge, you can find the latest releases here: struts.apache.org/download.html That said, there may be a staging repo near where you downloaded the distribution; you can add that to your settings.xml to find the artifacts there. We usually keep discussion of unreleased bits on the dev list; you might want to subscribe and move the conversation over there. Thanks for helping to test it! :) -- Wendy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2-rest-plugin-2.1.5 problem
Thank you for your quick reply. I tried using maven, but it couldn't find 2.1.5 one. Summary of mvn messages: Downloading: http://repo1.maven.org/maven2/org/apache/struts/struts2-rest-plugin/2.1.5/struts2-rest-plugin-2.1.5.jar [WARNING] An error occurred during dependency resolution. Failed to retrieve org.apache.struts:struts2-rest-plugin-2.1.5 Caused by: Unable to download the artifact from any repository. Try downloading the file manually from the project website. -- I guess i know some of them. I checked the struts-plugin.xml file inside the rest... .jar Do you mean xstream, json-lib, etc. How can find all these dependencies. Thank you. Regards, On Mon, Jan 5, 2009 at 2:07 AM, Dave Newton wrote: > Have you included the dependencies of the REST plugin? > > > > - Original Message > > From: Ercan Kayaonu > > To: user@struts.apache.org > > Sent: Sunday, January 4, 2009 8:57:55 PM > > Subject: struts2-rest-plugin-2.1.5 problem > > > > Hi folks, > > > > I just registered to the user list and new to struts. I hope i can learn > > from you and help as much as i can. > > I would like to ask one question about rest plugin, but i want to detail > the > > steps i've taken in case this might help someone who want to start > similar > > project. > > > > I wanted to use the convention plugin and i downloaded struts2 from > > http://people.apache.org/builds/struts/2.1.5/ > > I copied main jar files and also struts2-convention-plugin-2.1.5.jar to > my > > lib folder. Everything, including package name and action mappings worked > > great as described in http://cwiki.apache.org/WW/convention-plugin.html > > > > Up to this point you don't need to use struts.xml file. It works without > > that. The default result directory for .jsp files is /WEB-INF/content/ > > To change this to "views", I created struts.xml file. This is my > struts.xml > > after that change. > > > > > > > > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > > "http://struts.apache.org/dtds/struts-2.0.dtd";> > > > > > > /> > > > > > > Everything is OK. > > > > I also added struts2-config-browser-plugin-2.1.5.jar to my lib folder, > and > > able to see action mappings. Cool plugin. > > But i want to also use rails like structure in my action (well > controller) > > classes. For this you need rest plugin (struts2-rest-plugin-2.1.5.jar) as > > described here: http://cwiki.apache.org/WW/rest-plugin.html > > You need to add the following lines to your struts.xml file: > > > > > > > > > > value="rest-default"/> > > > > > > > > > > When i tried to restart tomcat6.0 within eclipse, i got this error: > > > > Unable to load configuration. - bean - jar:file:/path/and path/and > > whatever/lib/struts2-rest-plugin-2.1.5.jar!/struts-plugin.xml:36:138. > > Has anybody faced the same problem. > > Thank you in advance. > > > > Regards, > > Ercan > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: struts2-rest-plugin-2.1.5 problem
Have you included the dependencies of the REST plugin? - Original Message > From: Ercan Kayaonu > To: user@struts.apache.org > Sent: Sunday, January 4, 2009 8:57:55 PM > Subject: struts2-rest-plugin-2.1.5 problem > > Hi folks, > > I just registered to the user list and new to struts. I hope i can learn > from you and help as much as i can. > I would like to ask one question about rest plugin, but i want to detail the > steps i've taken in case this might help someone who want to start similar > project. > > I wanted to use the convention plugin and i downloaded struts2 from > http://people.apache.org/builds/struts/2.1.5/ > I copied main jar files and also struts2-convention-plugin-2.1.5.jar to my > lib folder. Everything, including package name and action mappings worked > great as described in http://cwiki.apache.org/WW/convention-plugin.html > > Up to this point you don't need to use struts.xml file. It works without > that. The default result directory for .jsp files is /WEB-INF/content/ > To change this to "views", I created struts.xml file. This is my struts.xml > after that change. > > > > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > "http://struts.apache.org/dtds/struts-2.0.dtd";> > > > /> > > > Everything is OK. > > I also added struts2-config-browser-plugin-2.1.5.jar to my lib folder, and > able to see action mappings. Cool plugin. > But i want to also use rails like structure in my action (well controller) > classes. For this you need rest plugin (struts2-rest-plugin-2.1.5.jar) as > described here: http://cwiki.apache.org/WW/rest-plugin.html > You need to add the following lines to your struts.xml file: > > > > > value="rest-default"/> > > > > > When i tried to restart tomcat6.0 within eclipse, i got this error: > > Unable to load configuration. - bean - jar:file:/path/and path/and > whatever/lib/struts2-rest-plugin-2.1.5.jar!/struts-plugin.xml:36:138. > Has anybody faced the same problem. > Thank you in advance. > > Regards, > Ercan - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org