I am missing something really basic (related to class-loading in EAR or EAR configuration). I could not figure out, why my JSR 303 validations and Hibernate validations not triggers from inside an EAR... It does triggers if I create a new WAR project.
I am setting up a new project with Maven, JSF 2.0, Open-JPA, EJB 3.0 on Weblogic Server 10.3. I created all the projects using maven archetypes. I have a final EAR build which is structured as:
- PROJName
- ejb
- web
- lib
- META-INF
In the Web, I have a login.xhtml
with userName
and Password
fields mapped with TestMPB variables and poms having the dependencies: validation-api 1.0.0.GA, hibernate-validator 4.2.0.Final…
The page backing bean's (TestMPB) variable has @Pattern
and @NotEmpty
annotations, but they are never triggered by JSF validation phase. JSF validations works fine, but I want to use JSR 303 and Hibernate validations.
login.xhtml
contains following impt lines:
<h:messages layout="table" showDetail="false" showSummary="true"/>
<h:inputText class="textbox" id="userId" value="#{testMPB.userId}"></h:inputText>
<h:commandButton id="button" action="#{testMPB.login}" value="Login" ></h:commandButton>
TestMPB contains:
@Pattern(regexp = "^(?=.*[a-zA-Z])[a-zA-Z0-9_]{2,15}\\s*$", message = "userId invalid")
@NotEmpty(message = "userId empty")
private String userId = "";
public String login(){ System.out.println("User Login ::"+getUserId());
return "/web/ui/s/home/home.xhtml";
}
Application.xml contains
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">
<display-name>ear</display-name>
<module>
<web>
<web-uri>web</web-uri>
<context-root>/NewAccountsWeb</context-root>
</web>
</module>
<module>
<ejb>ejb</ejb>
</module>
<library-directory>lib</library-directory>
</application>
For debug, I made sure:
- The JSF managed page bean (TestMPB) initializes on page load (by adding SOP in constructor)
- On Page submit, the method is invoked and the userName value is printed.
- JARs dependencies are added in the POM are correct and they exists in the final EAR build.
- Same JSR 303 and Hibernate validations works with same set of
login.xhtml
and TestMPB.java when I create a WAR project. - Created a phase listener and printed all the phases to make sure the phases are invoked.
- For testing, I also added JSF validations (
required=true
), which works and show messages in h:message.
Can think of anything which might solve this issue?