You are awesome, man! You might not know that how much you have helped people like me who does not have time to read bulky books to learn new technologies. Your videos are very neat and super easy to understand. You rock...! What's coming next?
For those of you who are getting the FormatException error "Cannot convert String to int" -> Make sure you used curly braces {} and not brackets (), as you can see at 9:17. For those of you who are getting the error: Error creating bean with name 'triangle' defined in class path resource [spring.xml]: ... Failed to convert property value of type [java.lang.String] to required type [int] for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "0;" -> Make sure you don't have semicolons ; for the values in your properties file.
I am still getting NumberFormatException. Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "${pointZero.pointX}"
Java Brains Hello Kaushik - I have one query on this, lets say I have 2 properties file and I want to take the values from either property file based on some session value. how do I do that? Here I have a multi language system, so based on the value of language session i want to get the text from corresponding properties file.
If you are getting TypeMismatchException try any of the 3 given solutions below : 1) Do not put properties values in Inverted comma ("") 2) Do not give semi colon at the end 3) Correct bean name is "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" .
Your tutorial explains the mechanics well but I don't get one thing: What is the point of a PostProcessor? I don't understand why it is important to know this. Can you give a practical example of how this is used?
+jeremy nagel maybe for you it's a late answer, for everyone else - think of the time you want to count how many times something was done: someone entered a page, someone requested a new calculation, etc.
@GhavleVivek Just maximize the player. Click the button at the bottom right corner of the player. You can click full screen and the text becomes crystal clear.
How can it be read that there is MyBeanFactoryPP class which implements the BeanFactoryPostProcessor interface and call the method inside it even before initializing the container? Because the Bean which is defined with class name MyBeanFactoryPP is inside the container right?
I am able to manage to get output as per the placeholders substitution..But i am not getting the same result statement as per your output that is "Before bean initialization placeholder sustitution takes place very early so that ready spring.xml will be used by post processor etc..the way you got in your output some logs so to double check the output which i got as per the placeholder features that i added newly..
If somebody's facing issue with, "Cannot convert from String to int" check in your property file, make sure you DONT use ";" after assigning the value to the variables in the file, if again you are having null pointer exception, then check that BeanFactoryPostProcessor should be implemented separately, it shouldn't be implemented along with any of the class.
you said "value" can be castered to primary types(include string).But "PropertiesLoaderSupport.setLocations(Resource ...)" the param is Resource , not string or primary type.
Also, is "locations" a keyword? i.e. I tried with But it gives a weird exception: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0' defined in class path resource [spring.xml]
Property configuration is not working. I am version 4.2.6. Error that I am getting Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0' defined in class path resource [Spring.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'peopertyFile' of bean class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]: Bean property 'peopertyFile' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Sir I have Question is that if make all java class in different packages like separate package for all POJO class and some more package for different functionality so in which package i should make class for BeanPostProcessor?Shouls I make it in different Package Also?.......Thanks in Advance
BeanFactoryPostProcessor gets called before beans are being instantiated, so because of that you can override or add properties. BeanPostProcessor gets called after beans have been instantiated.
Finally got the logs, after almost a year. I needed to use the earlier version of springs; used 4.2.2 instead of 5.2.2. Now I can see the info logs in the console. You can try with even older versions such as 3.2.
@@wilsoncardoso150 Finally got the logs, after almost a year. I needed to use the earlier version of springs; used 4.2.2 instead of 5.2.2. Now I can see the info logs in the console. You can try with even older versions such as 3.2.
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "${pointA.pointX}" Caused by: java.lang.NumberFormatException: For input string: "${pointA.pointX}" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
Hi, Thanks a lot for uploading such a nice video tutorial.... throwing NumberFormat Exception while geting value from config propety file. saying can not convert string to int, I applied int parser as well still the exception is not resolved please help me. "exception is .TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "${pointA.pointX}"
Oh sorry !!!!! The error in the below comment I have found. The error was I wrote the name of "PropertyPlaceholderConfigurer" class as "PropertPlaceholderConfigurer" I did not write the correct spelling
Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.spring.framework.beans.factory.config.PropertPlaceholderConfigurer] for bean with name 'org.spring.framework.beans.factory.config.PropertPlaceholderConfigurer#0' defined in class path resource [spring.xml]; nested exception is java.lang.ClassNotFoundException: org.spring.framework.beans.factory.config.PropertPlaceholderConfigurer
i got this error, can you please help .. spring.xml and properties file in next comment Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'triangle' defined in class path resource [spring.xml]: ... Failed to convert property value of type [java.lang.String] to required type [int] for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "0;"
It is used to perform certain operation pre and post the bean factory instantiation i.e when the bean factory setup is done, if we an operation to be performed, it can be added by using beanfactorypostprocessor. I Hope it helps!
One can throw all the books away and follow only your classes awesome teacher !!!!
You are awesome, man! You might not know that how much you have helped people like me who does not have time to read bulky books to learn new technologies. Your videos are very neat and super easy to understand. You rock...!
What's coming next?
Thanks Koushik, I find it very easy to understand.
Very good tutorial and it is simplified way to understand Spring.
+Bharath Kumar Lokaraj it is easy
Thank you for your videos koushks, really its help me a lot to get to know spring framework....once again Thanks koushks.
really love your videos, thanks man !
Koushik Kothagal Thanks for your videos. You made it simple and clear:)
Its a great video Koushik , thanks for the good work, God bless you!
Excellent Stuff.... very clear mind ....Really appreciate the efforts
I'll not stop thanking you! so Thank You Sir.
For those of you who are getting the FormatException error "Cannot convert String to int"
-> Make sure you used curly braces {} and not brackets (), as you can see at 9:17.
For those of you who are getting the error: Error creating bean with name 'triangle' defined in class path resource [spring.xml]: ... Failed to convert property value of type [java.lang.String] to required type [int] for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "0;"
-> Make sure you don't have semicolons ; for the values in your properties file.
+LeBadman Thanks a lot man
Nenad Nikolic You're welcome.
instead try using PropertySourcesPlaceholderConfigurer
I am still getting NumberFormatException.
Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "${pointZero.pointX}"
@@priyamalik9505 Please check the className definded in bean-
Is there a github repo where we can find the code?
Java Brains Hello Kaushik - I have one query on this, lets say I have 2 properties file and I want to take the values from either property file based on some session value. how do I do that?
Here I have a multi language system, so based on the value of language session i want to get the text from corresponding properties file.
Thank you for your videos koushks! It would be nice to have an updated version for the new Spring 3 framework.
I miss my non-spring java soo much after going thru all these spring config...
Man, you are great !!
If you are getting TypeMismatchException try any of the 3 given solutions below :
1) Do not put properties values in Inverted comma ("")
2) Do not give semi colon at the end
3) Correct bean name is "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" .
Thanks bro!
As of version 3.1 I think you should use org.springframework.context.support.PropertySourcesPlaceholderConfigurer
+Gerard Oei Thanks,it worked out for me.Was facing a issue due to this and not able to resolve
Thanks for the suggestion. It resolved the issue for the "Cannot convert from String to int".
Saved me from lot of toil googling! Thank you!
Thank you very much
Good stuff!
Great vidoes...can you recommend any good books for spring/hibernate? thanks
sorry about the last post, i had a silly mistake - its fixed now .. used ";" at the ned of value in properties file
Your tutorial explains the mechanics well but I don't get one thing: What is the point of a PostProcessor? I don't understand why it is important to know this. Can you give a practical example of how this is used?
You may need implement some logic, after the String container initializing a bean for example. :)
+jeremy nagel maybe for you it's a late answer, for everyone else - think of the time you want to count how many times something was done: someone entered a page, someone requested a new calculation, etc.
@GhavleVivek Just maximize the player. Click the button at the bottom right corner of the player. You can click full screen and the text becomes crystal clear.
How can it be read that there is MyBeanFactoryPP class which implements the BeanFactoryPostProcessor interface and call the method inside it even before initializing the container? Because the Bean which is defined with class name MyBeanFactoryPP is inside the container right?
I am able to manage to get output as per the placeholders substitution..But i am not getting the same result statement as per your output that is "Before bean initialization placeholder sustitution takes place very early so that ready spring.xml will be used by post processor etc..the way you got in your output some logs so to double check the output which i got as per the placeholder features that i added newly..
If somebody's facing issue with, "Cannot convert from String to int" check in your property file, make sure you DONT use ";" after assigning the value to the variables in the file, if again you are having null pointer exception, then check that BeanFactoryPostProcessor should be implemented separately, it shouldn't be implemented along with any of the class.
you said "value" can be castered to primary types(include string).But "PropertiesLoaderSupport.setLocations(Resource ...)" the param is Resource , not string or primary type.
Also, is "locations" a keyword? i.e. I tried with
But it gives a weird exception:
Error creating bean with name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0' defined in class path resource [spring.xml]
good one
Have you added PropertyPlaceholderConfigurer to your xml configuration file? I'm using the same version and it works fine.
Property configuration is not working. I am version 4.2.6. Error that I am getting
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0' defined in class path resource [Spring.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'peopertyFile' of bean class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]: Bean property 'peopertyFile' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Identified the problem. For OOTB class, should be location for which I gave my own name.
Properties path should b in forward slash then property file is readable
Is it mandatory to have bean factory post processor to use property place holder config
no, as you can see he removed it from spring.xml
Sir I have Question is that if make all java class in different packages like separate package for all POJO class and some more package for different functionality so in which package i should make class for BeanPostProcessor?Shouls I make it in different Package Also?.......Thanks in Advance
What purpose does BeanFactoryPostProcessor serve? Where would be a place that overriding the method in BFPP would benefit us the best?
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - this is working class path.
Thanks Ruslan!
Thanks Ruslan... :)
Need to put the config file under src, same hierarchy as spring.xml. it will solve the issue.
Hi,
Can you explain please what the different between BeanPostProcessor and BeanFactoryPostProcessor?
Thanks
BeanFactoryPostProcessor gets called before beans are being instantiated, so because of that you can override or add properties. BeanPostProcessor gets called after beans have been instantiated.
but im learing this too so i could be wrong
I am not able to see the logs as shown in video 06:32 after beanfactory post process executes.... what would be reason for this?
same here
Can somebody pls help with the logs?
Finally got the logs, after almost a year. I needed to use the earlier version of springs; used 4.2.2 instead of 5.2.2. Now I can see the info logs in the console. You can try with even older versions such as 3.2.
@@wilsoncardoso150 Finally got the logs, after almost a year. I needed to use the earlier version of springs; used 4.2.2 instead of 5.2.2. Now I can see the info logs in the console. You can try with even older versions such as 3.2.
nice
I too get the number format exception even though the properties files is in the same location as the spring.xml .please help
I am using spring 3.2.4, and I have the number format exception... I did exact what the video said. Is it because the framework version updated?
You probably forgot to add "$" while mentioning the variables in spring.xml - "${pointA.pointX}"
@@reachmanav I did exactly same. But i see type mismatch error :/
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "${pointA.pointX}"
Caused by: java.lang.NumberFormatException: For input string: "${pointA.pointX}"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
Hi,
Thanks a lot for uploading such a nice video tutorial....
throwing NumberFormat Exception while geting value from config propety file. saying can not convert string to int, I applied int parser as well still the exception is not resolved please help me.
"exception is .TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "${pointA.pointX}"
Oh sorry !!!!!
The error in the below comment I have found. The error was I wrote the name of "PropertyPlaceholderConfigurer" class as "PropertPlaceholderConfigurer"
I did not write the correct spelling
Please make font size big and bold
Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.spring.framework.beans.factory.config.PropertPlaceholderConfigurer] for bean with name 'org.spring.framework.beans.factory.config.PropertPlaceholderConfigurer#0' defined in class path resource [spring.xml]; nested exception is java.lang.ClassNotFoundException: org.spring.framework.beans.factory.config.PropertPlaceholderConfigurer
i got this error, can you please help .. spring.xml and properties file in next comment
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'triangle' defined in class path resource [spring.xml]: ... Failed to convert property value of type [java.lang.String] to required type [int] for property 'x'; nested exception is java.lang.NumberFormatException: For input string: "0;"
what is the use of beanfactorypostproccesor
It is used to perform certain operation pre and post the bean factory instantiation i.e when the bean factory setup is done, if we an operation to be performed, it can be added by using beanfactorypostprocessor. I Hope it helps!
does anyone get the same Value for triangle A as it is for triangle B
Buy Glasses LOL !
speak louder oufffff