default error message are not displaying

22 views
Skip to first unread message

Jim Richards

unread,
Jan 8, 2015, 3:07:52 AM1/8/15
to vt-middle...@googlegroups.com

Hi,

(I thought I'd posted this but it doesn't seem to have stuck.)

I'm finding that the default messages are not displaying. I'm getting output like

TOO_SHORT:{minimumLength=6, maximumLength=32}

My code is pretty normal. I checked the source and I can see in MessageResolver.java this

public static final String DEFAULT_MESSAGE_PATH = "/messages.properties";

and the file is in the .jar package. This should be loaded with new MessageResolver();

This is my code


MessageResolver resolver = new MessageResolver();

PasswordValidator validator = new PasswordValidator(resolver, ruleList);
PasswordData passwordData = new PasswordData(new Password(changePasswordForm.getPassword()));
RuleResult result = validator.validate(passwordData);

if (!result.isValid()) {
 
for (String message : validator.getMessages(result))

 LOG
.info("errors: " + message);
}

And my output is as above.

I've got the package loaded via maven calling in 

 <dependency>
 
<groupId>edu.vt.middleware</groupId>
 
<artifactId>vt-password</artifactId>
 
<version>3.1.2</version>
 
</dependency>


And although I'm using Spring, that "shouldn't" be affecting this.

Any ideas?

Thanks,
Jim











marvin.addison

unread,
Jan 8, 2015, 11:16:36 AM1/8/15
to vt-middle...@googlegroups.com
I'm finding that the default messages are not displaying. I'm getting output like

TOO_SHORT:{minimumLength=6, maximumLength=32}

That's the result of calling RuleResultDetail#toString().

MessageResolver resolver = new MessageResolver();

PasswordValidator validator = new PasswordValidator(resolver, ruleList);
PasswordData passwordData = new PasswordData(new Password(changePasswordForm.getPassword()));
RuleResult result = validator.validate(passwordData);

if (!result.isValid()) {
 
for (String message : validator.getMessages(result))

 LOG
.info("errors: " + message);
}


I added an equivalent block to the AbstractRuleTest class in trunk (3.1.3-SNAPSHOT) and confirmed it produces the human-readable message, "Password must be at least 8 characters in length." Can you please produce a simple working test case that we can use to attempt to reproduce? I typically do throwaway maven projects for this sort of thing, which facilitates us running the code exactly as it runs for you (including dependencies).

M

Jim Richards

unread,
Jan 8, 2015, 7:51:47 PM1/8/15
to vt-middle...@googlegroups.com

I worked it out. I have a messages.properties in my classpath for my application messages and this was clashing with MessageResolver's

public static final String DEFAULT_MESSAGE_PATH = "/messages.properties";

I'd suggest you change the vt-password .messages file to something else so there isn't a namespace clash like this.

My fix was to change the name of the file in my application.


Reply all
Reply to author
Forward
0 new messages