SpringMVC Form Validation doesn't work properly - spring

I have an issue with springMVC Form Validation .. I have an example in a project using maven and the same with gradle and when running each one , validation with gradle example work proberly but not working proberly with maven.
any help please?
I have attached the two projects
https://drive.google.com/drive/folders/1BXEuBebHecHagYLGvuzX0yqBgw6u_t1C?fbclid=IwAR24x9D3oCtcp_awdX8sb7CEm_uK2Ngx93vMTPuy_-3gIMpJIl14TctLANo

thanks , the problem wasn't from org.jetbrains.annotations.NotNull;
sometimes when you apply auto import , it make a problems. the problem is because I missed Hibernate Validation from my POM file so , auto import include this
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
which give a logical error (the validation doesn't work and go to next page even if condition not valid)
so the solution is to include this
<!-- Hibernate Validator -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.1.Final</version>
</dependency>
and don't apply auto import in intellij
thanks

Related

Getting "Finished Loading Resource Information. Rendering Swagger UI..." on loading swagger after migration from spring to sprinboot

We just migrated our application from Spring to Sprinboot (2.7.0). whenever i load swagger, all the apis dont get loaded and i get this line "Finished Loading Resource Information. Rendering Swagger UI..." on the top.
But http://host:port/v2/api-docs loads all the apis.
earlier we have below swagger related dependencies in our pom.xml
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${version.io.springfox}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.8</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.8</version>
</dependency>
dependencies. I tried with that, i got same issue.
Later i tried adding springfox-boot-starter dependency and commenting out specific swagger based spring dependencies but no luck. I tried to search for a solution but couldnt find anything concrete.
Any idea why this is happening?

NoClassDefFoundException while generating jhipster project

I am facing the same problem as many people did in the past. Can't build the spring boot application because i am getting the Exception which is mentioned in the title. Precisely it looks like this:
Error:java: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
I know that there was a topic about this before i have posted mine but none of the provided solutions helped me. Simply i am literally out of ideas. All i have wanted is to generate back-end and front-end with jhipster.I didnt even write one single line of code yet.
Let's mention that the project is Java 8 and that i tried to solve this by adding some dependencies as its mentioned in the similar topic which is here How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9
I have added this in my pom file becasue i use maven but the exception still occurs
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
Then i try to solve by adding this becasue its labeled as proper long term solution for all jdk versions
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
Any help or advice would be appreciated. Thanks in advance
Probably there is some problem either in your project configuration or in IntelliJ's Java Compiler settings.
Make sure that Java Compiler is set to 'Same as language level' or set it manually to desired version.
Make sure that all of the following project settings are set to Java 8:
Make sure modules are set to correct version as well:

BootsFaces annotation throwing errors

I have just started with BootsFaces and copied a showcase from the web.
I have added BootsFaces-OSP-1.0.2-dist.jar to my eclipse project with JSF 2.1
Problem I am facing is two annotations #Size and #NotEmpty is throwing error. I can guess its a setup issue, can anybody help?
With so little information, I can only guess. I suppose you're referring to compiler errors. Did you add the validation API and the hibernate validator?
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.2.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
This is the complete list of jars you have to add to run our showcase:

Maven Webjars - bootstrap-datepicker makes bootstrap invisible

I've tried to use Bootstrap and Bootstrap-Datepicker in my SpringMVC project:
GitHub repo
I trying to include both Bootstrap and Bootstrap-Datepicker via WebJars like this:
<!-- WebJars -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datepicker</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.10.2</version>
</dependency>
When I comment out the bootstrap-datepicker dependency in pom.xml, the browser is throwing errors in the console like this:
GET http://localhost:8080/finager/webjars/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js 404 (Not Found)
This is working as expected. When I leave boostrap-datepicker section uncommented, the browser starts to see bootstrap-datepicker files, also as expected. Unfortunately, the browser console starts to throw similar errors saying that now Bootstrap files are not visible! It seems that boostrap-datepicker is somehow overriding Bootstrap.
I've tried to change my includes order and still the same effect. All of my .jsp files (CSS and JS includes) seem to be valid, because Bootstrap is visible when Maven does not try to include the datepicker. Is there a simple way to check what is visible in my webjars folder after compilation?
I am very confused. I couldn't find any useful information on the Internet. I've spent whole day on this, so any help would be hugely appreciated. Thanks in advance!
As always, the solution came up to my mind right after posting the question. It seems that Maven detected that bootstrap-datepicker was depending on bootstrap. I suppose that it included Bootstrap in different version in result - that would explain everything.
However, this is the solution:
<!-- WebJars -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datepicker</artifactId>
<version>1.3.0</version>
<exclusions>
<exclusion>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.1.0</version>
</dependency>
Is anybody aware of simple solution to browse /webjars directory structure after the Maven compilation? This would prevent such issues.

Can not find the tag library descriptor for "http://tiles.apache.org/tags-tiles"

I am creating an application using Tiles, Spring and Hibernate.
When when running, it is showing following error:
Can not find the tag library descriptor for "http://tiles.apache.org/tags-tiles"
All the jars are included and mapping is also seeing fine. Where I am going wrong?
The url looks ok.
Your problem sounds a bit like you are missing some tiles jars. Make sure that a jar containing tiles-jsp.tld is added to your projects web libs folder.
One jar that contains this file is for example: tiles-jsp-2.2.1.jar.
In pom.xml file appended below artifacts and compiled well this time.
<!-- Tiles -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>2.1.2</version>
</dependency>
I copied the whole file with the taglib declaration from somewhere else and got the same compilation error. I deleted the file, created a new one and pasted the same contents. Sounds weird but worked! Hope it helps someone. :)
I had this problem even after having tiles-jsp.2.0.6.jar. So i found the solution by removing the jar manually from the maven dependencies and adding it as an external jar.. It worked, you may also try so..
Adding the tiles dependency in pom.xml of Spring project will help-
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>3.0.7</version>
</dependency>

Resources