Tuesday 10 November 2015

Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:

Exception :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeController': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 
[javax.persistence.EntityManagerFactory] is defined



Solution :

you are scanning wrong package for controller class change your package declaration.

Wednesday 19 August 2015

Maven dependencies Nature is not working in Eclipse

If you have enable the maven nature enables via eclipse and still 

All maven dependencies are not loading and its not showing up in the libraries then.

Add this entry in your classpath file of project .
Just after JRE entry in your classpath file.

1. Ctrl+Shift+R to open up resource .
2. search .classpath
3 .add entry after JRE.


<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>

Tuesday 18 August 2015

Exception java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter


Exception:
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
 at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy.instantiateWithMethodInjection(CglibSubclassingInstantiationStrategy.java:71)
 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:75)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948)
 ... 13 more
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.CallbackFilter
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 ... 16 more


Solution: 

If you get this exception, that means that you are using the earlier version than Spring 3.2 and missing the libraries for CGLIB

Beginning Spring 3.2, all net.sf.cglib classes moved to org.springframework.cglib and inline them directly within the spring-core JAR. CGLIB is a Byte Code Generation Library is high level API to generate and transform Java byte code. It is a third part library now merged to the Spring framework itself.



Monday 17 August 2015

Exception at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass)

You might end up with this exception while doing your one to one ,or many to one relationship in hibernate.

Exception:
Exception in thread "main" java.lang.NullPointerException
 at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:135)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
 at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
 at com.javatpoint.Test.main(Test.java:13)


To fix correct this exception Check following :

1. Your one to one mapping bean is pointing to correct column.
2. You have configured both table correctly.

Once you have correct these your exception will go away.


Friday 14 August 2015

Maven - Pom.xml Issues.

Maven -- > pom.xml error resolution


Problem 1. Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved.

Soultion :- 
1 . Just go to the path 

C:\Users\<username>\.m2\repository\org\apache\maven\plugins 
2.  Delete the plugin which is causing the issue .
3. In Eclipse clean and build your project again
4. choose Maven->Update Dependencies.



Problem 2 : Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled.

Solution :- 
Rightclick on your project in eclipse and choose Maven->Update Dependencies
Choose Force update of snapshot release.


Thursday 13 August 2015

How to hot deploy your code on Remote Debugging.

Make sure you have check this.

1) If you run your application in eclipse using the launch configuration
Is your "Project" - "Build Automatically" flag enabled? If not, the code is not compiled and ignored at runtime.

Follow these steps to debug in Remote debug mode.
Go to :-
yourProject  --> Debug as --> debug configuration...

1 .DoubleClick on Remote java application 
2. Set port in the connect Tab.








click OK and select the appropriate project you want to debug. Click Ok and then click debug.

Hot deploy has supported the code changes in the method implementation only. If you add a new class or a new method, restart is still required.

You are done with the Hot Deploy of remote application.


Sunday 18 January 2015

SessionFactory creation failed.org.hibernate.MappingException: An AnnotationConfiguration

You might have encountered this exception while mapping your POJO classes to tables in hibernate.


Exception:
SessionFactory creation failed.org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.javacodegeeks.enterprise.hibernate.Student"/>
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.javacodegeeks.enterprise.hibernate.utils.HibernateUtil.buildSessionFactory(HibernateUtil.java:17)
    at com.javacodegeeks.enterprise.hibernate.utils.HibernateUtil.<clinit>(HibernateUtil.java:8)
    at com.javacodegeeks.enterprise.hibernate.Test.main(Test.java:14)
Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.javacodegeeks.enterprise.hibernate.Student"/>
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1524)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1479)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1458)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1432)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1352)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1338)
    at com.javacodegeeks.enterprise.hibernate.utils.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
   
   
   
Solution:


If you see above exception it means you are not loading configuration from AnnotationConfiguration please load your configuration as below:

return new AnnotationConfiguration().configure().buildSessionFactory();

For loading configuration from XML file we use below code:

return new Configuration().configure().buildSessionFactory();

Spring boot with CORS

CORS (Cross-Origin Resource Sharing) errors occur when a web application running in a browser requests a resource from a different domain or...