title: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation
body: <blockquote>
    <p>springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.navin.friends.config.JPAConfig: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1051) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:828) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) [tomcat-embed-core-7.0.30.jar:7.0.30]
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) [tomcat-embed-core-7.0.30.jar:7.0.30]
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.30.jar:7.0.30]
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [tomcat-embed-core-7.0.30.jar:7.0.30]
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [tomcat-embed-core-7.0.30.jar:7.0.30]
            at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_91]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_91]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_91]
            at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
        Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
            at org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver.addTransformer(InstrumentationLoadTimeWeaver.java:88) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:82) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:348) ~[eclipselink-2.5.0.jar:2.5.0.v20130507-3faac2b]
            at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
            ... 21 common frames omitted
        Jun 01, 2017 5:53:26 PM org.apache.catalina.core.StandardContext listenerStart
        SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.navin.friends.config.JPAConfig: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
            at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1051)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:828)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
            at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)
        Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
            at org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver.addTransformer(InstrumentationLoadTimeWeaver.java:88)
            at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:82)
            at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:348)
            at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
            ... 21 more</p>
  </blockquote>
  
  <pre><code>Jun 01, 2017 5:53:26 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Error listenerStart
  Jun 01, 2017 5:53:26 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [/remember-friends] startup failed due to previous errors
  Jun 01, 2017 5:53:26 PM org.apache.catalina.core.ApplicationContext log
  INFO: Closing Spring root WebApplicationContext
  Jun 01, 2017 5:53:26 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  SEVERE: The web application [/remember-friends] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
  Jun 01, 2017 5:53:26 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-9090"]
  
      @Bean
          public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws IOException {
              EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter();
              vendorAdapter.setShowSql(true);
              LocalContainerEntityManagerFactoryBean entityManagerFacotryBean= new LocalContainerEntityManagerFactoryBean();
              entityManagerFacotryBean.setJpaVendorAdapter(vendorAdapter);
              entityManagerFacotryBean.setDataSource(getDataSource());
              entityManagerFacotryBean.setPackagesToScan("com.navin.friends.domain.entity");
              entityManagerFacotryBean.setJpaProperties(getJPAProperties());
              entityManagerFacotryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
              entityManagerFacotryBean.setPersistenceUnitName("friends");
              entityManagerFacotryBean.setJpaDialect(new EclipseLinkJpaDialect());
              return entityManagerFacotryBean;
  
          }
  </code></pre>