MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
rss245b
Post subject: Problems with Struts Validator plugin sample project  PostPosted: Jun 25, 2012 - 04:55 PM
Registered Member
Registered Member


Joined: May 03, 2010
Posts: 45

Unfortunately there is no sample validator plugin project for Struts on MyEclipseIde.com by example or similar project. I saw some mentions of the ValidatorPlugin but none of the suggested solutions fit and some of the links were broken as well.

(While I think of it I would like to suggest MyEclipseIde.com provide another section of the site for proven user/subscriber supplied working sample projects. )
In the meantime I am supplying my sample here
Note this problem I am having is with JDK 7 update 5
Perhaps once this problem is solved the sample will serve as simple sample of Apache Validator in MyEclipse and Struts 1.3 running on JDK 7 update 5 or you can try it on
JDK 6 update 33 the two safest(Secure) JDK versions available.

To both reproduce and possibly fix this sample case to a working state
[Please create a new Workspace and a new Web Project.
call it StrutsValidate and enter package: com.anonymous.struts
add Struts 1.3 capabilities
Copy and paste the webroot and src folders contained in the attached zip
file: StrutsValidatorPluginSample.zip attached please
and see if you can duplicate this problem.
I believe you can close MyEclipse and copy and paste the whole folder within the work space and project you created on top of the src and webroot folders respectively

I looked on the support forum pages but there were no working examples of this plugin. Maybe its deprecated but I have been very frustrated trying to get this to work in any way] I already went through the login tutorial and got that working but that does not use the Validator plugin namely, org.apache.struts.validator.ValidatorPlugIn


I have been trying to learn how to use a PlugIn Validator for Struts 1.3 Framework.
It is not working. This is a basic sample. I would really appreciate it if there was a tutorial on this or a resolution.
I saw other support forum entries which has me confused because I tried swapping out the DTD Doctypes for example for the two validator files which only made things worse.
and ultimately extracted the validator-rules.xml file from one of the Apache jar files and created a basic required and Double validator-rules.xml and appvalidation.xml both placed in my WEB-INF folder as you will see.

I have MyEclipse project files which may make the task of figuring what is wrong out easier
Basically this program adds a book object that is provided in a input form, alled add-new-book.jsp
and the Action object AddNewBook.java basically creates the object from the request input data and as I understand it the validator plugin is supposed to catch the input filter like and redirect to forwarding mapping or back to the same page and display the errors from a message file however I get a clean build and when
I invoke the Plugin by entering just the price field all the required rules of the validator appear to be ignored
while if I leave all fields blank I get the following exception:

un 24, 2012 11:57:03 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jdk1.7.0_05\bin;C:\Users\Rob\AppData\Local\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin
Jun 24, 2012 11:57:03 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jun 24, 2012 11:57:03 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 204 ms
Jun 24, 2012 11:57:04 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jun 24, 2012 11:57:04 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
Jun 24, 2012 11:57:05 PM org.apache.struts.action.ActionServlet initChain
INFO: Loading chain catalog from jar:file:/C:/Users/Rob/Workspaces/StrutsV1.3c/.metadata/.me_tcat/webapps/Strutsch10/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml
Jun 24, 2012 11:57:05 PM org.apache.struts.validator.ValidatorPlugIn initResources
INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml'
Jun 24, 2012 11:57:05 PM org.apache.struts.validator.ValidatorPlugIn initResources
INFO: Loading validation rules file from '/WEB-INF/appvalidation.xml'
Jun 24, 2012 11:57:05 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jun 24, 2012 11:57:05 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jun 24, 2012 11:57:05 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/0 config=null
Jun 24, 2012 11:57:05 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1558 ms
Jun 24, 2012 11:57:23 PM org.apache.struts.chain.ComposableRequestProcessor init
INFO: Initializing composable request processor for module prefix ''
Jun 24, 2012 11:57:23 PM org.apache.commons.validator.ValidatorResources getForm
WARNING: Form 'BookForm' not found for locale 'en_US'
Jun 24, 2012 11:57:23 PM org.apache.struts.chain.commands.servlet.CreateAction createAction
INFO: Initialize action of type: com.anonymous.struts.AddBookAction
Jun 24, 2012 11:57:23 PM org.apache.struts.chain.commands.AbstractExceptionHandler execute
WARNING: Unhandled exception
java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011)
at java.lang.Double.valueOf(Double.java:504)
at java.lang.Double.<init>(Double.java:597)
at com.anonymous.struts.AddBookAction.execute(AddBookAction.java:25)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:722)

Jun 24, 2012 11:57:23 PM org.apache.struts.chain.commands.ExceptionCatcher postprocess
WARNING: Exception from exceptionCommand 'servlet-exception'
java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011)
at java.lang.Double.valueOf(Double.java:504)
at java.lang.Double.<init>(Double.java:597)
at com.anonymous.struts.AddBookAction.execute(AddBookAction.java:25)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:722)

Jun 24, 2012 11:57:23 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011)
at java.lang.Double.valueOf(Double.java:504)
at java.lang.Double.<init>(Double.java:597)
at com.anonymous.struts.AddBookAction.execute(AddBookAction.java:25)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:722)

Please let me know if you can duplicate the problems I am seeing here
 
 View user's profile Send private message  
Reply with quote Back to top
rss245b
Post subject: Problems with Struts Validator plugin sample project  PostPosted: Jun 28, 2012 - 12:07 AM
Registered Member
Registered Member


Joined: May 03, 2010
Posts: 45

Turns out the problem was really stupid:
In version Struts Version 1.2 I am not sure what is wrong but I suspect I have the wrong validator-rules.xml file Any idea where I can get an official Struts 1.2 and a 1.1 validator-rules.xml file then this should work with all three versions give proper validator-rules.xml
files.

Luckily in Struts 1.3 the validator-rules.xml is built into the struts.jar file. Sadly I do not see one in Version 1.1- through 1.2
The big problem here was the bookForm mentioned in the appvalidation.xml file
(Big thaanks to Richard Knowles of VirtualPairProgrammers.com" for his help on this problem)
did not match the name associated with the action namely BookForm within the struts-config.xml file and the names must also be unique
so I hence changed the name= in the action identified by path-"/all-books" to name="allBooksList" and t
finally I changed the first parameter of the plugin tag in the struts-config.xml file to use the built in validation-rules.xml in struts.jar by specifying the tag as:

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="[b]/org/apache/struts/validator/validator-rules.xml[/b],/WEB-INF/appvalidation.xml"/>
</plug-in>

Then the zipped code provided in this thread worked with my Struts 1.3 version. As I said. I still await the validator-rules.xml for versions 1.1 and 1.2 but it should work with them as well
Anyone viewing this can get my sample working for their own understanding of Struts - This sample handles messages/Internationalization and basic Struts Action processing as well
as basic Form Validation with the ValidatorPlugIn.

Bottom line: If you use Struts try and use a configuration(struts-config.xml) file validator or builder on a big project.
It is easy to see how this can drive people insane on a high pressure project.

I hope this helps the next person strugling with the org. Apache.struts.validator.ValidatorPlugIn and its usage.
 
 View user's profile Send private message  
Reply with quote Back to top
support-swapna
Post subject:   PostPosted: Jun 28, 2012 - 05:24 AM



Joined: Nov 11, 2010
Posts: 2491

rss245b,

Glad that you got it working. It will surely help other users.
Do let us know if you see any issues.

_________________
Swapna
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits