aspose file tools*
The moose likes Struts and the fly likes struts validation example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts validation example" Watch "struts validation example" New topic
Author

struts validation example

Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Hi,

I am new to struts framework. I am trying to do validation example which is using validation.xml. but it Http status -404 Servlet Action is not available. error is coming.
Can any body provide me full example witch using validation.xml? I try to search in tutorial and I follow it but same error is coming still. I am using struts 1.1.

Thanks,
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
I am using struts 1.1
Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 81
404 has nothing to do with the validation not working properly. the application itself is not deployed properly and your trying to view page/action that doesn't exist. get the app running first then it will be easier to see if the validation is working properly or not.
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Thanks for reply.

If I run the application without validation then its works fine. but when add validation.xml and plug-in then error is coming.


Thanks
Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 81
there should be some sort of console output showing the stacktrace of the error. can you post that? that should give an indication of what is causing the 404
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Consol is:
-------------

you are in input.jsp
Aug 3, 2010 4:37:52 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: Servlet action is currently unavailable
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Increase the logging level to DEBUG to see what's causing the error. Also check the log on startup.
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Hi,

You ask me to check log on startup, How can I check?

Thanks,
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
When I start my tomcat server ...below is my console.



Aug 4, 2010 10:31:02 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_18\bin;.;C:\WINNT\system32;C:\WINNT;C:/Program Files/Java/jdk1.5.0_18/bin/../jre/bin/client;C:/Program Files/Java/jdk1.5.0_18/bin/../jre/bin;C:/Program Files/Java/jdk1.5.0_18/bin/../jre/lib/i386;C:\Perl\site\bin;C:\Perl\bin;C:\Program Files\apache-ant-1.8.0\bin;C:\Program Files\Java\jdk1.5.0_18\bin;C:\Program Files\MKS\IntegrityClient\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Common Files\OTG;"C:\Program Files\PKWARE\pkzipc";C:\Program Files\Softricity\SoftGrid for Windows Desktops;C:\Program Files\Credant\CMG Shield;C:\Program Files\Attachmate\EXTRA!\;C:\Program Files\SSH Communications Security\SSH Tectia\SSH Tectia AUX;C:\Program Files\SSH Communications Security\SSH Tectia\SSH Tectia AUX/Support binaries;C:\Program Files\SSH Communications Security\SSH Tectia\SSH Tectia Broker;C:\Program Files\SSH Communications Security\SSH Tectia\SSH Tectia Client;C:\oracle\ora92\bin\;C:\Program Files\Oracle\jre\1.3.1\bin\;C:\Program Files\Oracle\jre\1.1.8\bin;C:\tools\db-derby-10.2.2.0-bin\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN
Aug 4, 2010 10:31:02 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ValidationStruts' did not find a matching property.
Aug 4, 2010 10:31:03 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Aug 4, 2010 10:31:03 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 597 ms
Aug 4, 2010 10:31:03 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 4, 2010 10:31:03 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.28
Aug 4, 2010 10:31:03 AM org.apache.struts.action.ActionServlet initChain
INFO: Loading chain catalog from jar:file:/C:/tools/apache-tomcat-6.0.28/wtpwebapps/ValidationStruts/WEB-INF/lib/struts-core-1.3.9.jar!/org/apache/struts/chain/chain-config.xml
Aug 4, 2010 10:31:03 AM org.apache.struts.validator.ValidatorPlugIn initResources
INFO: Loading validation rules file from '/WEB-INF/validation.xml'
Aug 4, 2010 10:31:05 AM org.apache.struts.validator.ValidatorPlugIn init
SEVERE: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:520)
at java.net.Socket.connect(Socket.java:470)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
at sun.net.www.http.HttpClient.New(HttpClient.java:304)
at sun.net.www.http.HttpClient.New(HttpClient.java:321)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:828)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:780)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:705)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:949)
at org.apache.commons.digester.Digester.createInputSourceFromURL(Digester.java:1938)
at org.apache.commons.digester.Digester.resolveEntity(Digester.java:1615)
at com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEntity(EntityResolverWrapper.java:148)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:701)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1019)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at org.apache.commons.digester.Digester.parse(Digester.java:1745)
at org.apache.commons.validator.ValidatorResources.<init>(ValidatorResources.java:242)
at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.java:244)
at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:164)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:871)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:359)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Aug 4, 2010 10:31:05 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet action as unavailable
Aug 4, 2010 10:31:05 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /ValidationStruts threw load() exception
javax.servlet.UnavailableException: Cannot load a validator resource from '/WEB-INF/validation.xml'
at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:174)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:871)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:359)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Aug 4, 2010 10:31:05 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
Aug 4, 2010 10:31:05 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
Aug 4, 2010 10:31:05 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Aug 4, 2010 10:31:05 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Aug 4, 2010 10:31:05 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Aug 4, 2010 10:31:05 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Aug 4, 2010 10:31:05 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Aug 4, 2010 10:31:05 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Aug 4, 2010 10:31:05 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Aug 4, 2010 10:31:05 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31 config=null
Aug 4, 2010 10:31:05 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2544 ms


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please show the Struts configuration file and the validation file. Include a directory structure.
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Validation.xml




struts_config.xml




i have attached directory structure .

Thanks



[Thumbnail for dirstruct.JPG]

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags (not quote tags) to include code and make sure it's indented properly; it's much easier to read. Also, for textual information like directory hierarchies, please just use text to save the folks trying to help you a step. Thanks!
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
I have edited in same posting for code. Directory structure is same it is.
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Hi,

Still i am facing same problem. Can anybody help me?

Thanks
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Is it necessary to have validation-rules.xml. I have validation.xml.
tushar bhasme
Ranch Hand

Joined: Feb 11, 2008
Posts: 50
well, clearly the server did not start correctly... something went awry while using the validations plugin as the stack shows... verify all the config files again and redeploy...

Is it necessary to have validation-rules.xml


yes, its necessary to have both... validation-rules.xml define the rules, while validation.xml maps the rules to the fields in the form...
Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
Finally, I solve problem

I defined validation-rules.xml in plug-in in struts-config.xml as value="/org/apache/struts/validator/validator-rules.xml. and
second in validation.xml docType defined as below.
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

so now its work.

Thanks for help me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts validation example