문제

I have some SessionBeans in a JEE Application and like to use BeanValidation to validate my Parameters. So the whole validation process is generic and encapsulated in one place.

The only disadvantage I see is that the client get's an EJBException and has to unwrap the main Exception. Are there some more problems or dirty things I don't see or even a better way to do it?

도움이 되었습니까?

해결책

Make ConstraintViolationException an ApplicationException.

If you don't have it yet, create a ejb-jar.xml file (in /WEB-INF if ejbs are packaged in a war, in /META-INF otherwise):

<ejb-jar>
    <assembly-descriptor>
        <application-exception>
            <exception-class>javax.validation.ConstraintViolationException</exception-class>
            <rollback>true</rollback>
        </application-exception>
    </assembly-descriptor>
</ejb-jar>

You can do it for EJB 3.0 or above

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top