Standalone maven package for hibernate validator annotations - hibernate-validator

A quick question: is there a stand-alone package for org.hibernate.validator.constraints.*?
I want to put these annotations on a DTO package, but don't want to force the user to have hibernate-validator on their class path.

I don't really know what you mean by standalone in this context but here is a link to the 4.3.1 version of hibernate-validator.
Adding this to your pom will give you access to all the annotations in org.hibernate.validator.constraints package:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
mvnrepository.com is a very good place to search for maven artifacts.
Edit
Ok now I understand your question, you only want the annotations in the org.hibernate.validator.constraints as a dependency w/o all the other validation stuff.
Then my answer is no, there is no such thin jar. You will have to use the hibernate-validator to get the annotations.

If you use custom Hibernate Validator constraints you would have to add the actual core classes as well anyways. As long as you rely on Bean Validation constraints (javax.validation.*) it is enough to add the Bean Validation API jar.
What is your concen with adding the hibernate Validator jar?

Related

I want to use CDI with Java SE 12, but start up failes (Main Class, JBoss or Payara, all the same error)

I got completely stuck. I want to use CDI2 with Servlets to write a simple web app. However, the beans not get loaded.
I get the following error in JBoss or Payara or Weld (if running as Main Application):
WELD-001524: Unable to load proxy class for bean Managed Bean [class MyBean] with qualifiers [#Any #Default]
Does anyone still use CDI2 or has a running modern example?
I compile with maven.
warm regards,
Alex
I found it out myself. I had the wrong dependencies. I got confused because of Jakarta. I used the CDI-2 maven dependency. So I updated to Jakarta. Right? This is the way to go, right?
I can deploy. Payara-Micro works. JBoss (WildFly should do the same)
However, Payara Micro does not get track of the URL patterns of simple Servlets, although still, one can call it over the client. (Intellij has a CDI tab, gives a nice overview itself)
...
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>

Throwing Validation Exception in Spring boot

I am creating a Spring boot project for testing my rest API (Very Very tiny Project). The Project contains three files.
1) App.java (Main Program)
2) AppConfig (Configuration file)
3) Main Controller (Simple Rest controller)
I added Spring-boot-starter-parent (1.4.0.RELEASE) and spring-boot-starter-web as dependency.
But While executing,getting an exception like follows.
"javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath."
I added the following dependency and the error gone.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.4.Final</version>
</dependency>
My question is, what is the root cause of the specific error message?
Why we are adding the validator?
It means the classloader could only find the API of bean validator. You have to add some implementation package into the classpath.
Like:
org.glassfish.jersey.ext:jersey-bean-validation

ClassMode cannot be resolved to a variable

In my java spring mvc app, I am trying to reset a bunch of records for test with Junit.
but in line:
#DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
It complains with:
ClassMode cannot be resolved to a variable
Update:
I have added
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5</version>
</dependency>
but then it complains with other lines
#ActiveProfiles("test")
#Sql(scripts="requests-dataset.sql")
#DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
the error is:
ActiveProfiles cannot be resolved to a type
Sql cannot be resolved to a type
Sql cannot be resolved to a type
First of all, the class name is DirtiesContext.ClassMode (it's a nested class of DirtiesContext).
Second, as any other class, it must be imported.
Third, as the javadoc shows, it exists since Spring 3.0. So you won't find it in Spring 2.5. Use the same version of spring-test as the version used for the rest of the spring framework libraries that you're using.

When Spring Boot application running by Intelij Idea views can`t be resolved

I have encountered a strange situation, the decision which I cant find.
I`m runnig simple demo application using Spring Boot 1.3.0 and Intelij Idea 14.1.3
The problem is that Spring MVC cant resolve the view:
javax.servlet.ServletException: Could not resolve view with name 'home' in servlet with name 'dispatcherServlet'
Oddity is that when I run application by Maven Spring Boot-plugin
mvn clean spring-boot:run
everythig works fine.
Both views ("home.jsp" - returning from Controller and "start.jsp" - described in Configuration class) resolve correctly.
Full source code you can see here
I`ve downloaded another demo project - the same situation.
So, I think that something wrong with my IDE configuration.
But what is going wrong - I don`t know.
In File->Project Structure
I have added Spring and web module in "Modules" tab, the same I`ve made in "Facets" tab.
What is possible to do to make application run correctly using IDE?
Problem was in dependecies configuration in pom.xml
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
I have change <scope>provided</scope> to <scope>compile</scope> and it works well.

How to secure RESTful interface in JBoss AS 7

After successfully migrating my RESTful application to JBoss AS7, I would like to re-enable authentication (I used BASIC auth over SSL). It seems that this is now possible without writing XML configuration, just by using annotations.
Unfortunately, I cannot find which maven dependency I need to use to import the #WebService and #SecurityContext annotations.
Or is this completely going the wrong way? Is there a working example somewhere?
Thanks for your help!
#javax.jws.WebService is part of JDK
you might also need:
org.jboss.ws.api.annotation.WebContext;
that has option to configure authMethod #WebContext(authMethod=AuthMethod.BASIC) and is part of
<dependency>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-api</artifactId>
<version>1.0.0.GA</version>
</dependency>

Resources