• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts Validator Plugin in JDK 7 update 5 - Example not working - What is wrong here

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately there is no sample validator plugin project for Struts on MyEclipseIde.com (Should work similarly on Eclipse 3.7 and above though ) by example or similar project. I saw some mentions of the ValidatorPlugin but none of the suggested solutions fit this environment
JDK 7 update 5 with Struts 1.3 capabilities

(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
Download the following zip file containing sample code from: Struts1.3 Sample Code for Validator Plugin
extract the folders and copy and past over the existing src and webroot folders. You should be able to duplicate the problem.

and see if you can duplicate this problem.
I believe you can close MyEclipse or Eclipse 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)
 
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi "...."

Looking from the above log, there is no problem with any configuration as such. The first error in the above log is

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)

wherein, your line of code converts a string to Double unconditionally, and probably that String value [the 'price' from the BookForm] is NULL. Rectify this and let us know in case of any nested problems.

 
Jack Silver
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I replied earlier the problem was a really dumb one:
The bookForm name needed to match the ValidationForm and the and the names of the actions needed to be unique.
After that was changed things started working. If I left out the <html:errors property="fieldnameX" > tag between the <p class="error">,</p> tags in add-new-book.jsp then they should be added. Other than that it should be a good working example. The ValidatorPlugIn object should take care of the double conversion issue because it verifies that the value is required and Double or it won't submit.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic