wood burning stoves 2.0*
The moose likes Struts and the fly likes Problems with Struts 1.3.8 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problems with Struts 1.3.8" Watch "Problems with Struts 1.3.8" New topic
Author

Problems with Struts 1.3.8

rahul khanna
Ranch Hand

Joined: Sep 14, 2005
Posts: 48
Hi All,
I am trying to develop a application using struts 1.3.8. I am getting a error when I am using the validation file. Looking around forums , it looks as if this has to do with the version of the validator jar or digester.jar
Follwing is the list of jars I have :

- antlr-2.7.2.jar
- commons-beanutils-1.7.0.jar
- commons-chain-1.1.jar
- commons-digester-1.8.jar
- commons-logging-1.0.4.jar
- commons-validator-1.3.1.jar
- jstl-1.0.2.jar
- jstl-1.0.2.jar
- struts-core-1.3.8.jar
- struts-taglib-1.3.8.jar
- struts-tiles-1.3.8.jar

I have also tried commons-validator-1.3.0.jar and commons-validator.jar but they don't work. Earlier I was getting errors with tiles and had to try all sorts of COMBINATIONS to get the above wroking set , only to get stuck with validator.
If I remove the lines ...

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/conf/struts/validation/validator-rules.xml,/WEB-INF/conf/struts/validation/validation-myproject.xml"/>
</plug-in>.

The code works fine .
Surprisingly , it should work with the default set of jars downloaded from the apache site but it doesn't. Probably because of the tomcat. I am using Tomcat 5.5.23.

I get two different stack traces with different versions of validator files.

and with commons-validator-1.3.1.jar I get :


SEVERE: Parse Error at line 15 column 41: Element type "arg0" must be declared.
org.xml.sax.SAXParseException: Element type "arg0" must be declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1960)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:816)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
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:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
10-Jul-2007 21:10:58 org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 16 column 69: Element type "arg1" must be declared.
org.xml.sax.SAXParseException: Element type "arg1" must be declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1960)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:816)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
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)

Thanks in advance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The problem here is that in Struts 1.3 and above, the validator-rules.xml file is contained in the struts-core-1.3.x.jar file, and is not provided separately like it was before. With Struts 1.3 and above, your plugin entry should look like this:

As you can see, this references the validator-rules.xml file in the org.apache.struts.validator package, which exists inside the struts-core-1.3.x.jar file.


Merrill
Consultant, Sima Solutions
rahul khanna
Ranch Hand

Joined: Sep 14, 2005
Posts: 48
Hi Merill,

Thanks for the reply .What you said is correct in a way .Even if the validor-rules is kept oustside and is reference from struts-config in a way that I have done , it will pick it up. Though it is redundant and is not advisable I guess..

I have fixed the issue. The problem was with my validation-myproject.xml file.

It had entries like ..


<form name="myForm">
<field property="userName" depends="required,maxlength">
<arg0 key="myForm.userName"/>
<arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
<arg2 name="mask" key="${var:mask}" resource="false"/>
<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z]*[0-9a-zA-Z]$</var-value>
</var>
<var>
<var-name>maxlength</var-name>
<var-value>128</var-value></var>
</field>
<field property="userPassword" depends="required">
<arg0 key="myForm.password"/>
</field>
</form>


I changed lines like
<arg0 key="myForm.password"/>

to

<arg key="myForm.password"/>

and it worked..
i,e arg0,arg1 and arg2 were replaced with arg.


Why did I write it like arg0,1,2 in first place ??
Well, I had copied one of my old code.. which was working fine with struts 1.1, it bonked with 1.3.8 because of this error.
Hope it helps someone.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with Struts 1.3.8
 
Similar Threads
Attribute "value" must be declared for element type "property"???
DocumentParseException
exception while trying to use <data-sources>
Exception while loading the validation.xml in strusts
An Error Occured while starting tomcat