Questions related to commons-chain.jar after upgrading from Struts 1.2 to Struts 1.3

2012-03-21 Thread joann luo
Hello,



After upgrading from Struts 1.2 to Struts 1.3, I copied
*commons-chain.jar*to the
*WEB**-**INF**\lib* directory.  I still got the following exception when I
logged into the application.



Note: The commons-chain.jar was *never *in the WEB-INF\lib directory when
this project was running using Struts 1.2.  If I don't have the
commons-chain.jar in the WEB-INF\lib directory, I still got the same
exception.

*
*

Also, I have updated all the DTD references to:

!DOCTYPE struts-config PUBLIC

-//Apache Software Foundation//DTD Struts Configuration 1.3//EN

http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd;

*
*

Could somebody let me know what I have missed here?



Thanks a lot

Joann







*[**3/21/12** 9:55:41:973 **EDT**] 0019 ActionServlet E
org.apache.struts.action.ActionServlet init Unable to initialize Struts
ActionServlet due to an unexpected exception or error thrown, so marking
the servlet as unavailable.  Most likely, this is due to an incorrect or
missing library dependency.*

* java.lang.NoClassDefFoundError:
org.apache.commons.chain.config.ConfigParser*

*at
org.apache.struts.action.ActionServlet.initChain(ActionServlet.java:1680)*

at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:350)

at javax.servlet.GenericServlet.init(GenericServlet.java:241)

at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:358)

at
com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:169)

at
com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1809)

at
com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:98)

at
com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:1037)

at
com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:958)

at
com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:637)

at
com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:435)

at
com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:304)

at
com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)

at
com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)

at
com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:731)

at
com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:616)

at
com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)

at
com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)

at
com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1122)

at
com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1319)

at
com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:610)

at
com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:944)

at
com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:725)

at
com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2046)

at
com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:439)

at
com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)

at
com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:382)

at
com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:110)

at
com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:949)

at
com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349)

at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)

Caused by: java.lang.ClassNotFoundException:
org.apache.commons.chain.config.ConfigParser

at java.net.URLClassLoader.findClass(URLClassLoader.java:434)

at
com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:150)

at java.lang.ClassLoader.loadClass(ClassLoader.java:653)

at
com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:90)

at java.lang.ClassLoader.loadClass(ClassLoader.java:619)

at
com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)

at
com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)

at

Re: Exception occurred after upgrading from Struts 1.2 to Struts 1.3.10

2012-03-20 Thread joann luo
Hello,

Thanks for your quick responses.

Yes. I changed the DTD definitions in all the relevant files:

!DOCTYPE struts-config PUBLIC
-//Apache Software Foundation//DTD Struts Configuration 1.3//EN
http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd;

!DOCTYPE tiles-definitions PUBLIC
-//Apache Software Foundation//DTD Tiles Configuration 1.3//EN
http://jakarta.apache.org/struts/dtds/tiles-config_1_3.dtd; 

!DOCTYPE form-validation PUBLIC
  -//Apache Software Foundation//DTD Commons Validator Rules
Configuration 1.3.0//EN
  http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd


Is there anything else I might have missed which causes this exception?


Thanks a lot.


2012/3/19 Łukasz Lenart lukasz.len...@googlemail.com

 Did you changed DTD definition ?


 Regards
 --
 Łukasz http://www.lenart.org.pl/
 mobile +48 606 323 122, office +27 11 0838747
 Warszawa JUG conference - Confitura http://confitura.pl/


 2012/3/19 joann luo joannlu...@gmail.com:
   hello,
 
 
  I downloaded the complete Struts 1.3.10 package from
  http://struts.apache.org/download.cgi\
  *struts-1.3.10-all.zip
 http://apache.mirrors.hoobly.com/struts/binaries/struts-1.3.10-all.zip
  *. I updated the existing JAR files in my application.
 
 
 
  jakarta-oro.jar
 
  commons-logging.jar
 
  commons-digester.jar
 
  commons-validator.jar
 
  commons-beanutils.jar
 
  commons-fileupload.jar
 
  struts.jar
 
 
 
  I added the 3 new JAR files as the dependencies.
 
  commons-chain.jar
 
  struts-taglib.jar
 
  struts-tiles.jar
 
 
 
  I was able to compile the code correctly.  I deployed the new EAR file.
  Once I logged into the application, I got the following exception in the
  log.
 
 
 
 
 
  org.apache.commons.chain.config.ConfigParser
 
  javax.servlet.UnavailableException:
  org.apache.commons.chain.config.ConfigParser
 
 at
 
 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:534)
 
 at
 
 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
 
 at
 
 com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
 
 at
  com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3933)
 
 at
  com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
 
 at
  com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
 
 at
 
 com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
 
 at
 
 com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
 
 at
 
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:445)
 
 at
 
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:504)
 
 at
 
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:301)
 
 at
 
 com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
 
 at
 
 com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
 
 at
 
 com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
 
 at
 
 com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
 
 at
 
 com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
 
 at
 com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
 
 at
  com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
 
 at
 
 com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
 
 at
 com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
 
 at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)
 
 
 
 
 
 
 
  I also tried to put commons-chain.jar either in the WEB-INF\classes or
 WEB-
  INF\lib directory.  I restarted the WAS server but I still got the same
  exception.
 
 
 
  Does anyone know what the cause of this issue is?
 
 
 
 
 
  --
  Best Regards,
  Joann

 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




-- 
Best Regards,
Joann


Re: Exception occurred after upgrading from Struts 1.2 to Struts 1.3.10

2012-03-20 Thread joann luo
Hello, Dave:

Could you please be more specific on what logging I need to set to DEBUG
level?  I am using WAS.  Which console in WAS I should set the DEBUG to
true for logging in this case?

In the project I am working on, I turned on the debug flag for the project
but that is the only exception I saw in the server log. The application
initialization was successful and I was able to launch the login page.  I
just got that exception as soon as I logged in.

Thanks a lot.
Joann


On Tue, Mar 20, 2012 at 9:57 AM, Dave Newton davelnew...@gmail.com wrote:

 Have you set the logging to DEBUG level and checked the logs on startup?

 Dave

 On Tue, Mar 20, 2012 at 9:48 AM, joann luo joannlu...@gmail.com wrote:

  Hello,
 
  Thanks for your quick responses.
 
  Yes. I changed the DTD definitions in all the relevant files:
 
  !DOCTYPE struts-config PUBLIC
  -//Apache Software Foundation//DTD Struts Configuration 1.3//EN
  http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd;
 
  !DOCTYPE tiles-definitions PUBLIC
  -//Apache Software Foundation//DTD Tiles Configuration 1.3//EN
  http://jakarta.apache.org/struts/dtds/tiles-config_1_3.dtd; 
 
  !DOCTYPE form-validation PUBLIC
   -//Apache Software Foundation//DTD Commons Validator Rules
  Configuration 1.3.0//EN
   http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd
 
 
  Is there anything else I might have missed which causes this exception?
 
 
  Thanks a lot.
 
 
  2012/3/19 Łukasz Lenart lukasz.len...@googlemail.com
 
   Did you changed DTD definition ?
  
  
   Regards
   --
   Łukasz http://www.lenart.org.pl/
   mobile +48 606 323 122, office +27 11 0838747
   Warszawa JUG conference - Confitura http://confitura.pl/
  
  
   2012/3/19 joann luo joannlu...@gmail.com:
 hello,
   
   
I downloaded the complete Struts 1.3.10 package from
http://struts.apache.org/download.cgi\
*struts-1.3.10-all.zip
   http://apache.mirrors.hoobly.com/struts/binaries/struts-1.3.10-all.zip
 
*. I updated the existing JAR files in my application.
   
   
   
jakarta-oro.jar
   
commons-logging.jar
   
commons-digester.jar
   
commons-validator.jar
   
commons-beanutils.jar
   
commons-fileupload.jar
   
struts.jar
   
   
   
I added the 3 new JAR files as the dependencies.
   
commons-chain.jar
   
struts-taglib.jar
   
struts-tiles.jar
   
   
   
I was able to compile the code correctly.  I deployed the new EAR
 file.
Once I logged into the application, I got the following exception in
  the
log.
   
   
   
   
   
org.apache.commons.chain.config.ConfigParser
   
javax.servlet.UnavailableException:
org.apache.commons.chain.config.ConfigParser
   
   at
   
  
 
 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:534)
   
   at
   
  
 
 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
   
   at
   
  
 
 com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
   
   at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3933)
   
   at
   
  com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
   
   at
   
  com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
   
   at
   
  
 
 com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
   
   at
   
  
 
 com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
   
   at
   
  
 
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:445)
   
   at
   
  
 
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:504)
   
   at
   
  
 
 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:301)
   
   at
   
  
 
 com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
   
   at
   
  
 
 com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
   
   at
   
  
 
 com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
   
   at
   
  
 
 com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
   
   at
   
  
 
 com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
   
   at
   com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
   
   at
com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
   
   at
   
  
 
 com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775

Exception occurred after upgrading from Struts 1.2 to Struts 1.3.10

2012-03-19 Thread joann luo
 hello,


I downloaded the complete Struts 1.3.10 package from
http://struts.apache.org/download.cgi\
*struts-1.3.10-all.ziphttp://apache.mirrors.hoobly.com/struts/binaries/struts-1.3.10-all.zip
*. I updated the existing JAR files in my application.



jakarta-oro.jar

commons-logging.jar

commons-digester.jar

commons-validator.jar

commons-beanutils.jar

commons-fileupload.jar

struts.jar



I added the 3 new JAR files as the dependencies.

commons-chain.jar

struts-taglib.jar

struts-tiles.jar



I was able to compile the code correctly.  I deployed the new EAR file.
Once I logged into the application, I got the following exception in the
log.





org.apache.commons.chain.config.ConfigParser

 javax.servlet.UnavailableException:
org.apache.commons.chain.config.ConfigParser

at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:534)

at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)

at
com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)

at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3933)

at
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)

at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)

at
com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)

at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)

at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:445)

at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:504)

at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:301)

at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)

at
com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)

at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)

at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)

at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)

at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)

at
com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)

at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)

at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)

at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)







I also tried to put commons-chain.jar either in the WEB-INF\classes or WEB-
INF\lib directory.  I restarted the WAS server but I still got the same
exception.



Does anyone know what the cause of this issue is?





-- 
Best Regards,
Joann


Could somebody please confirm the bundle attribute issue is fixed in Commons Validator 1.3.0?

2012-03-05 Thread joann luo
Hello,

Thanks so much for the responses to my previous question in this thread:
http://struts.1045723.n5.nabble.com/Validation-doesn-t-honor-the-bundle-attribute-in-http-jakarta-apache-org-commons-dtds-validator-1-3-d-td5528087.html

The customer requires us to add the customized error messages in a *totally
different resource bundle*.  This can't be done through this type
of configuration (
http://struts.apache.org/1.2.4/userGuide/dev_validator.html#i18n).

The latest version of Commons Validator is version 1.3.0.
http://commons.apache.org/dtds/

Accordingly to this site, Struts 1.3 has upgraded to Validator 1.3.0 (
http://wiki.apache.org/struts/StrutsUpgradeNotes12to13).  Could somebody
please confirm the bundle attribute issue is fixed in Commons Validator
1.3.0?

-- 
Best Regards,
Joann


Re: Validation doesn’t honor the bundle attribute in http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd

2012-03-01 Thread joann luo
Hello,

I am sorry about the confusion before.

I searched web app's component.xml file and found the following, therefore,
we are actually using Struts1.2.4 in this project.

dependency name=prereqs.sn/struts.minimal type=jar version=1.2.4 /
dependency name=prereqs.sn/struts.extra type=jar version=1.2.4 /

Per my previous email, even though I updated the validation.xml and
validator-rules.xml to point to validator_1_3_0.dtd, the bundle attribute
still does not work.

Is there any other way to provide customized error message for
errors.required, errors.invalid cases instead of using the out-of-box
ones?

Thanks a lot
Joann

On Thu, Mar 1, 2012 at 12:04 PM, Jeffrey Black jeffblack...@gmail.comwrote:

 Hi Joann,

 Can you please confirm what version of Struts you are using?

 You appear to be using Struts 2 for your application [1]; however it
 appears you are referencing Struts 1.x validation information.  Perhaps I'm
 missing something?

 [1]

 http://struts.1045723.n5.nabble.com/How-to-implement-alternate-error-messages-in-the-Struts-validation-framework-Struts-2-0-1-4-td5522076.html

 Best,

 jb

 On Thu, Mar 1, 2012 at 8:59 AM, joann luo joannlu...@gmail.com wrote:

  Hello,
  I am using http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtdbut
  I
  found it still does not honor ‘bundle” attribute in the validation.xml.
 
  I need to display an alternate error message defined in a custom
  bundle through the Struts validation framework instead of the default
  error message.  Based on the information provided from this early
  thread, it should have been available since Validator 1.1.4.
 
  http://www.mail-archive.com/user@struts.apache.org/msg23694.html
  If this is still not supported in validator_1_3_0.dtd, then is there any
  way to implement this?
 
 
 
 
  I appreciate any advice you may have.
 
 
 
  Thank you.
 



Re: Validation doesn’t honor the bundle attribute in http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd

2012-03-01 Thread joann luo
Hello, Dave:

Thanks for pointing this out.

I am working on a customer issue reported from a project that we released
quite a while ago. I won't be able to upgrade the struts JAR in this case.

Since I have to stay with validator 1.1.3 is there any other way to provide
customized error message for errors.required, errors.invalid cases
instead of using the out-of-box
ones?

Thanks again,
Joann

On Thu, Mar 1, 2012 at 3:41 PM, Dave Newton davelnew...@gmail.com wrote:

 You can't just update a validation DTD and expect everything to suddenly
 use a later version of the validation libraries. S1.2.4, AFAIK, uses
 validator 1.1.3. Hence all S1.2.4 code will be written assuming
 commons-validator 1.1.3.

 Capabilities introduced in later versions of commons-validator would
 require deploying said later version. Any S1 interactions with
 commons-validator, however, would remain at the 1.1.3 level. If it's a
 validator-only issue, it *may* still work, but if the new functionality
 relies on any S1 interaction, I'm pretty sure it wouldn't.

 Dave

 On Thu, Mar 1, 2012 at 3:33 PM, joann luo joannlu...@gmail.com wrote:

  Hello,
 
  I am sorry about the confusion before.
 
  I searched web app's component.xml file and found the following,
 therefore,
  we are actually using Struts1.2.4 in this project.
 
  dependency name=prereqs.sn/struts.minimal type=jar version=1.2.4
 /
  dependency name=prereqs.sn/struts.extra type=jar version=1.2.4 /
 
  Per my previous email, even though I updated the validation.xml and
  validator-rules.xml to point to validator_1_3_0.dtd, the bundle attribute
  still does not work.
 
  Is there any other way to provide customized error message for
  errors.required, errors.invalid cases instead of using the out-of-box
  ones?
 
  Thanks a lot
  Joann
 
  On Thu, Mar 1, 2012 at 12:04 PM, Jeffrey Black jeffblack...@gmail.com
  wrote:
 
   Hi Joann,
  
   Can you please confirm what version of Struts you are using?
  
   You appear to be using Struts 2 for your application [1]; however it
   appears you are referencing Struts 1.x validation information.  Perhaps
  I'm
   missing something?
  
   [1]
  
  
 
 http://struts.1045723.n5.nabble.com/How-to-implement-alternate-error-messages-in-the-Struts-validation-framework-Struts-2-0-1-4-td5522076.html
  
   Best,
  
   jb
  
   On Thu, Mar 1, 2012 at 8:59 AM, joann luo joannlu...@gmail.com
 wrote:
  
Hello,
I am using
  http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtdbut
I
found it still does not honor ‘bundle” attribute in the
 validation.xml.
   
I need to display an alternate error message defined in a custom
bundle through the Struts validation framework instead of the default
error message.  Based on the information provided from this early
thread, it should have been available since Validator 1.1.4.
   
http://www.mail-archive.com/user@struts.apache.org/msg23694.html
If this is still not supported in validator_1_3_0.dtd, then is there
  any
way to implement this?
   
   
   
   
I appreciate any advice you may have.
   
   
   
Thank you.
   
  
 



How to implement alternate error messages in the Struts validation framework. (Struts 2.0.1.4)

2012-02-28 Thread joann luo
Hello,

I am currently using the Struts2 validation framework for my project.  I
have Struts 2.0.14.   I have been trying to find a way to display alternate
error message through validator framework.

I tried two things.



   1. I added a bundle attribute in the following code in the web.xml but
   that did not work.  The com.mytest.strings bundle is located in the
   WEB-INF\classes folder.



field property=attribute(Number)
depends=required,mask,maxbytelength,nonce

msg name=required *bundle=”com.mytest.strings  *

”key=errors.required /
  2.   Based on the following information from Programming Jakarta
Struts Chapter 11 The Validator Framework
http://books.google.com/books?id=E874l0jaUGQCpg=PA260lpg=PA260dq=change+the+key+values+in+the+validation-rules.xml+if+you+plan+to+use+alternative+messagessource=blots=t5zzY8fSs4sig=wEOspEiq8XsU2su4yD1WlCz8H6whl=ensa=Xei=8_ZLT6TOHoPi0QGB4YiTDgved=0CCIQ6AEwAA#v=onepageq=change%20the%20key%20values%20in%20the%20validation-rules.xml%20if%20you%20plan%20to%20use%20alternative%20messagesf=false




*“You should add these to your application’s resource bundle, or change the
key values in the validation-rules.xml if you plan to use alternative
messages.”*



I have the following code in validator-rules.xml file.



validator   name=required

classname=StrutsValidators

   method=validateRequired

 methodParams=java.lang.Object,

   org.apache.commons.validator.ValidatorAction,

   org.apache.commons.validator.Field,

   org.apache.struts.action.ActionMessages,

   javax.servlet.http.HttpServletRequest

  msg=errors.required.new/



validator   name=mask

classname= StrutsValidators

   method=validateMask

 methodParams=java.lang.Object,

   org.apache.commons.validator.ValidatorAction,

   org.apache.commons.validator.Field,

   org.apache.struts.action.ActionMessages,

   javax.servlet.http.HttpServletRequest

  depends=

  msg=errors.invalid.new/





I added the following string to a separate bundle but with the same
properties file name. That bundle is located in a different directory.I
updated the values of these two entries in this new properties file.



errors.required.new={0} is required NEW.

errors.invalid.new={0} is not valid NEW.





My validation.xml file looks like this:



field property=attribute(Number)
depends=required,mask,maxbytelength,nonce

msg name=required key=errors.required /

msg name=maxbytelength key=errors.maxlength /

var

var-namemaxbytelength/var-name

var-value32/var-value

/var

var

var-nameform/var-name

var-valueInfo/var-value

/var

msg name=mask key=errors.invalid /

arg0 key=label.Number /

var

var-namemask/var-name

var-value^[0-9\-() ]*$/var-value

/var

/field



When I ran my test I still see the standard error messages such as the ones
listed below displayed on the UI.  It appears that the validation framework
still reads from the default bundle.  However, all other labels on the same
UI can read from the customized properties file.

errors.required.new={0} is required.

errors.invalid.new={0} is not valid.



Is this a Struts issue?  If not, what is the right way to implement
alternate validation message in this case?



Thanks a lot.