Re: ClassCastException com.dev.model.Form cannot be cast to java.lang.String
2009/3/24 foward fow...@gmail.com: s:action name=createForm!getForm id=action namespace=default/ Method getForm() return object Form or String? Struts is expecting that action will return a String not an object. I think you should read some tutorial how to use Struts 2. 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: ClassCastException com.dev.model.Form cannot be cast to java.lang.String
lukaz, the method getForm() return a object Form where before with the respective id is obtained and returned. Yes I m reading a book struts in action, I don't know if you recomend me a good one. Regards Lukasz Lenart wrote: 2009/3/24 foward fow...@gmail.com: s:action name=createForm!getForm id=action namespace=default/ Method getForm() return object Form or String? Struts is expecting that action will return a String not an object. I think you should read some tutorial how to use Struts 2. 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 -- View this message in context: http://www.nabble.com/ClassCastException-com.dev.model.Form-cannot-be-cast-to-java.lang.String-tp22682861p22683750.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: ClassCastException com.dev.model.Form cannot be cast to java.lang.String
Look at your execute() method or whatever method you're calling from your JSP. I suspect that you are returning a com.dev.model.Form object instead of a String like success or input. jk On Tue, Mar 24, 2009 at 11:26 AM, foward fow...@gmail.com wrote: Hello, I don't know if I m right posting here this, but I have this problem with my webapp and I couldn't find a solution I hope you can help me please: ERROR [httpSSLWorkerThread-8080-1] ActionComponent.executeAction(259) java.lang.ClassCastException: com.dev.model.Form cannot be cast to java.lang.String at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:409) I did search looking for an answer but I didnt find nothing... the thing is when I call an action method in a view: s:action name=createForm!getForm id=action namespace=default/ div id=box pstrongSurvey : /strong ${form.name}/p pstrongIntroduction : /strong ${form.introduction}/p pstrongClose Date:/strong ${form.close_date}/p br/ /div to show information about one Form. Please if you can guide me to solve this, Thanks in advance! Best Regards -- View this message in context: http://www.nabble.com/ClassCastException-com.dev.model.Form-cannot-be-cast-to-java.lang.String-tp22682861p22682861.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 -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com
Re: ClassCastException com.dev.model.Form cannot be cast to java.lang.String
2009/3/24 foward fow...@gmail.com: the method getForm() return a object Form where before with the respective id is obtained and returned. You put method getForm() in s:form as a action, which means such method will be called by Struts 2 and the framework will expect a String - result name, which you have to define in struts.xml. You shouldn't return an object like Form. To do that, implement ModelDriven interface and return your Form object from method getModel() and in your jsp use ${name} instead ${form.name} Yes I m reading a book struts in action, I don't know if you recomend me a good one. That is good one 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: ClassCastException com.dev.model.Form cannot be cast to java.lang.String
you have 2 different tags you are implementing: form (tag) which creates a form http://struts.apache.org/2.1.6/docs/form-tag.html action (tag) which identifies ActionClass (and possible parameters) http://struts.apache.org/2.1.6/docs/action.html did you have a question on either implementation? Martin __ Disclaimer and confidentiality note This message is confidential and may be privileged. If you are not the intended recipient, we kindly ask you to please inform the sender. Any unauthorised dissemination or copying hereof is prohibited. This message serves for information purposes only and shall not have any legally binding effect. Given that e-mails can easily be subject to manipulation, we can not accept any liability for the content provided. Date: Tue, 24 Mar 2009 16:50:54 +0100 Subject: Re: ClassCastException com.dev.model.Form cannot be cast to java.lang.String From: lukasz.len...@googlemail.com To: user@struts.apache.org 2009/3/24 foward fow...@gmail.com: s:action name=createForm!getForm id=action namespace=default/ Method getForm() return object Form or String? Struts is expecting that action will return a String not an object. I think you should read some tutorial how to use Struts 2. 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 _ Internet Explorer 8 – Now Available. Faster, safer, easier. http://clk.atdmt.com/MRT/go/141323790/direct/01/
RE: ClassCastException
this line: newuser = (User)getSession().save(user); Hernandez, David wrote: What line's the Exception being thrown on? -Original Message- From: slideharmony [mailto:[EMAIL PROTECTED] Sent: Friday, November 16, 2007 9:35 AM To: user@struts.apache.org Subject: ClassCastException Hello, I have a problem saving a bean User. I use the following code: UserDao dao = new UserDao(); User user = new User(); Service.populate(user); dao.save(utente); if(user != null){ return SUCCESS; } here is the dao.save method: public User save(User user){ Utente newuser = null; begin(); newuser = (User)getSession().save(user); commit(); close(); return newuser; } this code throws a ClassCastException: java.lang.Long I have mapped all correctly, i have the same code that works perfectly in struts, but I get that exception with struts2. Can anybody help me? -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794339 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794434 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Re: ClassCastException
What's utente? In any case, you don't say where the exception is, but for whatever reason your DAO isn't getting a user (if that's where the exception is). d. --- slideharmony [EMAIL PROTECTED] wrote: Hello, I have a problem saving a bean User. I use the following code: UserDao dao = new UserDao(); User user = new User(); Service.populate(user); dao.save(utente); if(user != null){ return SUCCESS; } here is the dao.save method: public User save(User user){ Utente newuser = null; begin(); newuser = (User)getSession().save(user); commit(); close(); return newuser; } this code throws a ClassCastException: java.lang.Long I have mapped all correctly, i have the same code that works perfectly in struts, but I get that exception with struts2. Can anybody help me? -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794339 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException
What line's the Exception being thrown on? -Original Message- From: slideharmony [mailto:[EMAIL PROTECTED] Sent: Friday, November 16, 2007 9:35 AM To: user@struts.apache.org Subject: ClassCastException Hello, I have a problem saving a bean User. I use the following code: UserDao dao = new UserDao(); User user = new User(); Service.populate(user); dao.save(utente); if(user != null){ return SUCCESS; } here is the dao.save method: public User save(User user){ Utente newuser = null; begin(); newuser = (User)getSession().save(user); commit(); close(); return newuser; } this code throws a ClassCastException: java.lang.Long I have mapped all correctly, i have the same code that works perfectly in struts, but I get that exception with struts2. Can anybody help me? -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794339 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException
yes, it was the problem, I have solved it! thanks Nils-Helge Garli wrote: Assuming you're using Hibernate or something, the save method probably returns the generated identity of the stored object instance. So my guess is that you're getting the id of the user returned, which is a Long, and not a User object. Nils-H On 11/16/07, slideharmony [EMAIL PROTECTED] wrote: this line: newuser = (User)getSession().save(user); Hernandez, David wrote: What line's the Exception being thrown on? -Original Message- From: slideharmony [mailto:[EMAIL PROTECTED] Sent: Friday, November 16, 2007 9:35 AM To: user@struts.apache.org Subject: ClassCastException Hello, I have a problem saving a bean User. I use the following code: UserDao dao = new UserDao(); User user = new User(); Service.populate(user); dao.save(utente); if(user != null){ return SUCCESS; } here is the dao.save method: public User save(User user){ Utente newuser = null; begin(); newuser = (User)getSession().save(user); commit(); close(); return newuser; } this code throws a ClassCastException: java.lang.Long I have mapped all correctly, i have the same code that works perfectly in struts, but I get that exception with struts2. Can anybody help me? -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794339 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794434 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13795487 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException
Assuming you're using Hibernate or something, the save method probably returns the generated identity of the stored object instance. So my guess is that you're getting the id of the user returned, which is a Long, and not a User object. Nils-H On 11/16/07, slideharmony [EMAIL PROTECTED] wrote: this line: newuser = (User)getSession().save(user); Hernandez, David wrote: What line's the Exception being thrown on? -Original Message- From: slideharmony [mailto:[EMAIL PROTECTED] Sent: Friday, November 16, 2007 9:35 AM To: user@struts.apache.org Subject: ClassCastException Hello, I have a problem saving a bean User. I use the following code: UserDao dao = new UserDao(); User user = new User(); Service.populate(user); dao.save(utente); if(user != null){ return SUCCESS; } here is the dao.save method: public User save(User user){ Utente newuser = null; begin(); newuser = (User)getSession().save(user); commit(); close(); return newuser; } this code throws a ClassCastException: java.lang.Long I have mapped all correctly, i have the same code that works perfectly in struts, but I get that exception with struts2. Can anybody help me? -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794339 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/ClassCastException-tf4821639.html#a13794434 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException when usig multiple web applications
definition name=baseDef path=/am/WEB-INF/pages/mainLayout.jsp put name=menuPanel value=/am/amMenupanel.jsp/ change your tile-defs to not include the context name of your application ie definition name=baseDef path=/WEB-INF/pages/mainLayout.jsp put name=menuPanel value=/amMenupanel.jsp/ Also, why place your jsp's under WEB-INF ? Is there a security concern you are trying to overcome ? or were they just put there for no reason ? thanks Chris McCormack -Original Message- From: Mathew Joseph [mailto:[EMAIL PROTECTED] Sent: 06 July 2004 06:42 To: Struts Users Mailing List Subject: RE: ClassCastException when usig multiple web applications Hi The context name of my application is am . Here is the sample code of action class, struts-config, tiles-def web.xml ... ACTION CLASS *** //--- servlet --- import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; //--- struts --- import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; import org.apache.struts.actions.DispatchAction; public final class ClassifiersAction extends DispatchAction { public static final String SOURCEREFID = $Name: $; $Id: ClassifiersAction.java,v 1.0 2004/06/30 12:12:12 mathew Exp $; private Vector messageVector; /** * Initial method for redirecting and loading Add,Search pages */ public ActionForward generalView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String sOpr = (String)request.getParameter(qOpr); if (sOpr != null) { if (sOpr.equals(add)) { return mapping.findForward(addPage); } } return mapping.findForward(defaultPage); } . } **struts-config.xml * action-mappings action path=/Classifiers type=com.alopa.xyz.ui.am.action.ClassifiersAction scope=request parameter=method forward name=addPage path=addPage/ /action . /action-mappings ***tiles-defs.xml*** tiles-definitions !-- Base definition for AM pages -- definition name=baseDef path=/am/WEB-INF/pages/mainLayout.jsp put name=menuPanel value=/am/amMenupanel.jsp/ put name=headerPanel value=/am/psHeader.jsp/ put name=tabPanel value=/ put name=messagePanel value=/am/WEB-INF/pages/psMessagepanel.jsp/ put name=bodyPanel value=/ put name=listPanel value=/ /definition !-- Definition for Classifiers - add pages -- definition name=addPage extends=baseDef put name=tabPanel value=/am/WEB-INF/pages/clfrHeader.jsp/' put name=bodyPanel value=/am/WEB-INF/pages/amClassifiers.jsp/ /definition . /tiles-definitions ***web.xml* servlet servlet-nameaction/servlet-name servlet-class org.apache.struts.action.ActionServlet /servlet-class init-param param-nameconfig/param-name param-value/WEB-INF/config/struts-config.xml/param-value /init-param Thanks Mathew -Original Message- From: McCormack, Chris [mailto:[EMAIL PROTECTED] Sent: Monday, July 05, 2004 7:38 PM To: Struts Users Mailing List Subject: RE: ClassCastException when usig multiple web applications Please paste in a sample action and a sample tile-def. The more info the easier it is to help you out. Also the name of your deployed app (context name). Chris McCormack -Original Message- From: Mathew Joseph [mailto:[EMAIL PROTECTED] Sent: 05 July 2004 15:07 To: [EMAIL PROTECTED] Subject: ClassCastException when usig multiple web applications Hi, We have deployed a ROOT application and another application called 'AM' in Tomcat 4.1.30. Both applications use struts. In struts config file as well as tiles definition files we have given all paths relative to context. Following exception is thrown, when action class is accessed. java.lang.ClassCastException at org.apache.struts.tiles.TilesRequestProcessor.initDefinitionsMapping(TilesRequestProcessor.java:126) at org.apache.struts.tiles.TilesRequestProcessor.init(TilesRequestProcessor.java:116
RE: ClassCastException when usig multiple web applications
Hi The context name of my application is am . Here is the sample code of action class, struts-config, tiles-def web.xml ... ACTION CLASS *** //--- servlet --- import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; //--- struts --- import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; import org.apache.struts.actions.DispatchAction; public final class ClassifiersAction extends DispatchAction { public static final String SOURCEREFID = $Name: $; $Id: ClassifiersAction.java,v 1.0 2004/06/30 12:12:12 mathew Exp $; private Vector messageVector; /** * Initial method for redirecting and loading Add,Search pages */ public ActionForward generalView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String sOpr = (String)request.getParameter(qOpr); if (sOpr != null) { if (sOpr.equals(add)) { return mapping.findForward(addPage); } } return mapping.findForward(defaultPage); } . } **struts-config.xml * action-mappings action path=/Classifiers type=com.alopa.xyz.ui.am.action.ClassifiersAction scope=request parameter=method forward name=addPage path=addPage/ /action . /action-mappings ***tiles-defs.xml*** tiles-definitions !-- Base definition for AM pages -- definition name=baseDef path=/am/WEB-INF/pages/mainLayout.jsp put name=menuPanel value=/am/amMenupanel.jsp/ put name=headerPanel value=/am/psHeader.jsp/ put name=tabPanel value=/ put name=messagePanel value=/am/WEB-INF/pages/psMessagepanel.jsp/ put name=bodyPanel value=/ put name=listPanel value=/ /definition !-- Definition for Classifiers - add pages -- definition name=addPage extends=baseDef put name=tabPanel value=/am/WEB-INF/pages/clfrHeader.jsp/' put name=bodyPanel value=/am/WEB-INF/pages/amClassifiers.jsp/ /definition . /tiles-definitions ***web.xml* servlet servlet-nameaction/servlet-name servlet-class org.apache.struts.action.ActionServlet /servlet-class init-param param-nameconfig/param-name param-value/WEB-INF/config/struts-config.xml/param-value /init-param Thanks Mathew -Original Message- From: McCormack, Chris [mailto:[EMAIL PROTECTED] Sent: Monday, July 05, 2004 7:38 PM To: Struts Users Mailing List Subject: RE: ClassCastException when usig multiple web applications Please paste in a sample action and a sample tile-def. The more info the easier it is to help you out. Also the name of your deployed app (context name). Chris McCormack -Original Message- From: Mathew Joseph [mailto:[EMAIL PROTECTED] Sent: 05 July 2004 15:07 To: [EMAIL PROTECTED] Subject: ClassCastException when usig multiple web applications Hi, We have deployed a ROOT application and another application called 'AM' in Tomcat 4.1.30. Both applications use struts. In struts config file as well as tiles definition files we have given all paths relative to context. Following exception is thrown, when action class is accessed. java.lang.ClassCastException at org.apache.struts.tiles.TilesRequestProcessor.initDefinitionsMapping(TilesRequestProcessor.java:126) at org.apache.struts.tiles.TilesRequestProcessor.init(TilesRequestProcessor.java:116) at org.apache.struts.action.ActionServlet.getRequestProcessor(ActionServlet.java:872) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke