eerriicc
eerriicc

Reputation: 1240

How can I make Seam Validation work outside a Java EE container?

I want to use Hibernate Validator's method parameter validation feature. From what I read in the documents, Hibernate Validator just offers an API, and I need the @AutoValidating annotation of Seam Validation to make things work.

However, I want to use the methd parameter validation outside a Java EE container, for plain methods, e.g. in utility classes.

What's the setup to get this to work?

Upvotes: 2

Views: 155

Answers (2)

Óscar López
Óscar López

Reputation: 236034

It is possible to build a Seam-based application living outside of a full-fledged Java EE container, for instance using a web container such as Tomcat. But anyway, Seam has to run in at least a web container, you can't use it outside for standalone applications (after all, Seam is a web applications framework). If you only need validations, consider using a simpler approach - for instance, try Apache's commons validator.

Upvotes: 0

Gunnar
Gunnar

Reputation: 18990

For using method validation you need some sort of container creating and managing your objects, it doesn't neccessarily have to be Java EE, though.

If you are running in Java SE, you could e.g. use CDI and Seam Validation (the CDI reference implementation Weld can be used on SE) or alternatively the Spring framework, this post gives a good overview.

On GitHub you can also find a project of mine, showing the integration of method validation with Google Guice and also JDK dynamic proxies.

Upvotes: 1

Related Questions